use of org.netbeans.jemmy.operators.JButtonOperator in project JMRI by JMRI.
the class TurnoutTableActionTest method testAddAndInvoke.
/**
* Check Turnout Table GUI, menus and graphic state presentation.
* @since 4.7.4
*/
@Test
public void testAddAndInvoke() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
// show table
a.actionPerformed(null);
// create 2 turnouts and see if they exist
Turnout it1 = InstanceManager.turnoutManagerInstance().provideTurnout("IT1");
Turnout it2 = InstanceManager.turnoutManagerInstance().provideTurnout("IT2");
it1.setCommandedState(Turnout.THROWN);
it2.setCommandedState(Turnout.CLOSED);
// set graphic state column display preference to false, read by createModel()
InstanceManager.getDefault(GuiLafPreferencesManager.class).setGraphicTableState(false);
TurnoutTableAction _tTable;
_tTable = new TurnoutTableAction();
Assert.assertNotNull("found TurnoutTable frame", _tTable);
// prevent there are 2 menubars with the same name
_tTable.dispose();
// set to true, use icons
InstanceManager.getDefault(GuiLafPreferencesManager.class).setGraphicTableState(true);
TurnoutTableAction _t1Table;
_t1Table = new TurnoutTableAction();
Assert.assertNotNull("found TurnoutTable1 frame", _t1Table);
JFrame t1Frame = JFrameOperator.waitJFrame(Bundle.getMessage("TitleTurnoutTable"), true, true);
// test Add pane
_t1Table.addPressed(null);
JFrame af = JFrameOperator.waitJFrame(Bundle.getMessage("TitleAddTurnout"), true, true);
Assert.assertNotNull("found Add frame", af);
// close Add pane
_t1Table.cancelPressed(null);
// more Turnout Add pane tests are in TurnoutTableWindowTest
// Open Automation pane to test Automation menu
jmri.jmrit.turnoutoperations.TurnoutOperationFrame tof = new jmri.jmrit.turnoutoperations.TurnoutOperationFrame(null);
// create dialog (bypassing menu)
// TODO I18N using Bundle
JDialogOperator am = new JDialogOperator("Turnout Operation Editor");
Assert.assertNotNull("found Automation menu dialog", am);
// close pane
JButtonOperator jbo = new JButtonOperator(am, "OK");
// instead of .push();
jbo.pushNoBlock();
// Open Speed pane to test Speed menu, which displays a JOptionPane
//System.out.println("Speed pane started at " + java.time.LocalTime.now()); // debug
// method 1: open as method
//_t1Table.setDefaultSpeeds(null); // create dialog (bypassing menu, but is not found)
//_t1Table.setDefaultSpeeds(t1Frame); // create dialog by frame (bypassing menu, but is also not found)
// JFrameOperator main = new JFrameOperator(Bundle.getMessage("TitleTurnoutTable")); // create dialog (through menu)
// method 2: Alternatively, used GUI menu to open Speeds pane:
// pushMenuNoBlock is used, because dialog is modal
// JMenuBarOperator mainbar = new JMenuBarOperator(main);
// mainbar.pushMenuNoBlock("Speeds"); // stops at top level
// JMenuOperator jmo = new JMenuOperator(mainbar, "Speeds");
// JPopupMenu jpm = jmo.getPopupMenu();
// JMenuItem firstMenuItem = (JMenuItem)jpm.getComponent(0); // first item is [Defaults...]
// JMenuItemOperator jmio = new JMenuItemOperator(firstMenuItem);
// jmio.pushNoBlock();
// wait for Speeds dialog
// for Jemmy to work, we need the Turnout Speeds pane inside a JDialog
// TODO activate test when we manage to find pane:
// JDialogOperator as = new JDialogOperator(Bundle.getMessage("TurnoutGlobalSpeedMessageTitle"));
// Assert.assertNotNull("found Speeds menu dialog", as);
//System.out.println("Speed pane found at " + java.time.LocalTime.now()); // debug
// close pane
// JButtonOperator jbs = new JButtonOperator(as, "OK");
// jbs.pushNoBlock();
// clean up
af.dispose();
am.dispose();
//as.dispose(); // uncomment when test is Speeds menu activated
tof.dispose();
_t1Table.dispose();
}
use of org.netbeans.jemmy.operators.JButtonOperator in project JMRI by JMRI.
the class OperationsSwingTestCase method enterClickAndLeave.
protected void enterClickAndLeave(JButton comp) {
JButtonOperator jbo = new JButtonOperator(comp);
jbo.push();
}
use of org.netbeans.jemmy.operators.JButtonOperator in project JMRI by JMRI.
the class OperationsSwingTestCase method pressDialogButton.
protected void pressDialogButton(JmriJFrame f, String buttonName) {
JFrameOperator jfo = new JFrameOperator(f);
// wait for the first dialog.
JDialogOperator jdo = new JDialogOperator(jfo, 1);
NameComponentChooser bChooser = new NameComponentChooser(buttonName);
//JButtonOperator jbo = new JButtonOperator(jdo,buttonName);
JButtonOperator jbo = new JButtonOperator(jdo, bChooser);
// Click button
jbo.push();
}
use of org.netbeans.jemmy.operators.JButtonOperator in project JMRI by JMRI.
the class OperationsSetupFrameTest method testSetupFrameWrite.
@Test
public void testSetupFrameWrite() {
// it may be possible to make this a headless test by only initializing the panel, not the frame
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
// force creation of backup
Setup.setCarTypes(Setup.AAR);
OperationsSetupFrame f = new OperationsSetupFrame();
// entire panel must be visible for tests to work properly
f.setLocation(0, 0);
f.initComponents();
OperationsSetupPanel p = (OperationsSetupPanel) f.getContentPane();
JFrameOperator jfo = new JFrameOperator(Bundle.getMessage("TitleOperationsSetup"));
p.railroadNameTextField.setText("Test Railroad Name");
p.maxLengthTextField.setText("1234");
p.maxEngineSizeTextField.setText("6");
p.switchTimeTextField.setText("3");
p.travelTimeTextField.setText("4");
// Match 0 is HOn3.
(new JRadioButtonOperator(jfo, "HO", 1)).push();
(new JRadioButtonOperator(jfo, Bundle.getMessage("Descriptive"))).push();
p.panelTextField.setText("Test Panel Name");
((JComboBox) (new JLabelOperator(jfo, Bundle.getMessage("IconNorth")).getLabelFor())).setSelectedItem(LocoIcon.RED);
((JComboBox) (new JLabelOperator(jfo, Bundle.getMessage("IconEast")).getLabelFor())).setSelectedItem(LocoIcon.BLUE);
((JComboBox) (new JLabelOperator(jfo, Bundle.getMessage("IconWest")).getLabelFor())).setSelectedItem(LocoIcon.WHITE);
((JComboBox) (new JLabelOperator(jfo, Bundle.getMessage("IconSouth")).getLabelFor())).setSelectedItem(LocoIcon.GREEN);
((JComboBox) (new JLabelOperator(jfo, Bundle.getMessage("IconTerminate")).getLabelFor())).setSelectedItem(LocoIcon.GRAY);
((JComboBox) (new JLabelOperator(jfo, Bundle.getMessage("IconLocal")).getLabelFor())).setSelectedItem(LocoIcon.YELLOW);
(new JButtonOperator(jfo, Bundle.getMessage("ButtonSave"))).push();
// dialog window should appear regarding train lengths
pressDialogButton(f, java.text.MessageFormat.format(Bundle.getMessage("MaxTrainLengthIncreased"), new Object[] { 1234, "feet" }), "OK");
// dialog window should appear regarding railroad name
/*pressDialogButton(f,java.text.MessageFormat.format(Bundle
.getMessage("ChangeRailroadName"), new Object[]{"My Jmri Railroad", "Test Railroad Name"}) ,"No");
// done*/
f.dispose();
jfo.dispose();
// it may be possible to make this a headless test by only initializing the panel, not the frame
OperationsSetupFrame frameRead = new OperationsSetupFrame();
// entire panel must be visible for tests to work properly
frameRead.setLocation(0, 0);
frameRead.initComponents();
OperationsSetupPanel panelRead = (OperationsSetupPanel) frameRead.getContentPane();
JFrameOperator jfo2 = new JFrameOperator(Bundle.getMessage("TitleOperationsSetup"));
Assert.assertEquals("railroad name", "Test Railroad Name", panelRead.railroadNameTextField.getText());
Assert.assertEquals("max length", "1234", panelRead.maxLengthTextField.getText());
Assert.assertEquals("max engines", "6", panelRead.maxEngineSizeTextField.getText());
Assert.assertEquals("switch time", "3", panelRead.switchTimeTextField.getText());
Assert.assertEquals("travel time", "4", panelRead.travelTimeTextField.getText());
// Assert.assertEquals("owner", "Bob J", f.ownerTextField.getText());
Assert.assertTrue("HO scale", (new JRadioButtonOperator(jfo2, "HO", 1)).isSelected());
Assert.assertFalse("N scale", (new JRadioButtonOperator(jfo2, "N")).isSelected());
Assert.assertFalse("Z scale", (new JRadioButtonOperator(jfo2, "Z")).isSelected());
Assert.assertFalse("TT scale", (new JRadioButtonOperator(jfo2, "TT")).isSelected());
Assert.assertFalse("HOn3 scale", (new JRadioButtonOperator(jfo2, "HOn3")).isSelected());
Assert.assertFalse("OO scale", (new JRadioButtonOperator(jfo2, "OO")).isSelected());
Assert.assertFalse("Sn3 scale", (new JRadioButtonOperator(jfo2, "Sn3")).isSelected());
Assert.assertFalse("S scale", (new JRadioButtonOperator(jfo2, "S", 1)).isSelected());
Assert.assertFalse("On3 scale", (new JRadioButtonOperator(jfo2, "On3")).isSelected());
Assert.assertFalse("O scale", (new JRadioButtonOperator(jfo2, "O", 1)).isSelected());
Assert.assertFalse("G scale", (new JRadioButtonOperator(jfo2, "G")).isSelected());
Assert.assertTrue("descriptive", (new JRadioButtonOperator(jfo2, Bundle.getMessage("Descriptive"))).isSelected());
Assert.assertFalse("AAR", (new JRadioButtonOperator(jfo2, Bundle.getMessage("AAR"))).isSelected());
Assert.assertEquals("panel name", "Test Panel Name", panelRead.panelTextField.getText());
Assert.assertEquals("east color", LocoIcon.RED, ((JComboBox) (new JLabelOperator(jfo2, Bundle.getMessage("IconNorth")).getLabelFor())).getSelectedItem());
Assert.assertEquals("west color", LocoIcon.BLUE, ((JComboBox) (new JLabelOperator(jfo2, Bundle.getMessage("IconEast")).getLabelFor())).getSelectedItem());
Assert.assertEquals("north color", LocoIcon.WHITE, ((JComboBox) (new JLabelOperator(jfo2, Bundle.getMessage("IconWest")).getLabelFor())).getSelectedItem());
Assert.assertEquals("south color", LocoIcon.GREEN, ((JComboBox) (new JLabelOperator(jfo2, Bundle.getMessage("IconSouth")).getLabelFor())).getSelectedItem());
Assert.assertEquals("terminate color", LocoIcon.GRAY, ((JComboBox) (new JLabelOperator(jfo2, Bundle.getMessage("IconTerminate")).getLabelFor())).getSelectedItem());
Assert.assertEquals("local color", LocoIcon.YELLOW, ((JComboBox) (new JLabelOperator(jfo2, Bundle.getMessage("IconLocal")).getLabelFor())).getSelectedItem());
// done
frameRead.dispose();
}
Aggregations