use of org.netbeans.jemmy.operators.JFrameOperator in project JMRI by JMRI.
the class LocationsTableFrameTest method testTableCreationFrame.
@Test
public void testTableCreationFrame() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
LocationsTableFrame f = new LocationsTableFrame();
// should be 5 rows
Assert.assertEquals("number of rows", 5, f.locationsModel.getRowCount());
// default is sort by name
Assert.assertEquals("1st loc", "Test Loc A", f.locationsModel.getValueAt(0, LocationsTableModel.NAMECOLUMN));
Assert.assertEquals("2nd loc", "Test Loc B", f.locationsModel.getValueAt(1, LocationsTableModel.NAMECOLUMN));
Assert.assertEquals("3rd loc", "Test Loc C", f.locationsModel.getValueAt(2, LocationsTableModel.NAMECOLUMN));
Assert.assertEquals("4th loc", "Test Loc D", f.locationsModel.getValueAt(3, LocationsTableModel.NAMECOLUMN));
Assert.assertEquals("5th loc", "Test Loc E", f.locationsModel.getValueAt(4, LocationsTableModel.NAMECOLUMN));
// check location lengths
Assert.assertEquals("1st loc length", 1005, f.locationsModel.getValueAt(0, LocationsTableModel.LENGTHCOLUMN));
Assert.assertEquals("2nd loc length", 1004, f.locationsModel.getValueAt(1, LocationsTableModel.LENGTHCOLUMN));
Assert.assertEquals("3rd loc length", 1003, f.locationsModel.getValueAt(2, LocationsTableModel.LENGTHCOLUMN));
Assert.assertEquals("4th loc length", 1002, f.locationsModel.getValueAt(3, LocationsTableModel.LENGTHCOLUMN));
Assert.assertEquals("5th loc length", 1001, f.locationsModel.getValueAt(4, LocationsTableModel.LENGTHCOLUMN));
// close windows
JFrameOperator jfof = new JFrameOperator(f);
jfof.close();
}
use of org.netbeans.jemmy.operators.JFrameOperator in project JMRI by JMRI.
the class LocationsTableFrameTest method testLocationsEditFrame.
@Test
public void testLocationsEditFrame() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
LocationsTableFrame f = new LocationsTableFrame();
// create edit location frame
f.locationsModel.setValueAt(null, 2, LocationsTableModel.EDITCOLUMN);
// confirm location edit frame creation
JUnitUtil.waitFor(() -> {
return JmriJFrame.getFrame("Edit Location") != null;
}, "lef not null");
JmriJFrame lef = JmriJFrame.getFrame("Edit Location");
Assert.assertNotNull(lef);
// close windows
JFrameOperator jfolef = new JFrameOperator(lef);
jfolef.close();
JFrameOperator jfof = new JFrameOperator(f);
jfof.close();
Assert.assertNull(JmriJFrame.getFrame("Edit Location"));
}
use of org.netbeans.jemmy.operators.JFrameOperator in project JMRI by JMRI.
the class OperationsSetupFrameTest method testDirectionCheckBoxes.
@Test
public void testDirectionCheckBoxes() {
// it may be possible to make this a headless test by only initializing the panel, not the frame
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
OperationsSetupFrame f = new OperationsSetupFrame();
// entire panel must be visible for tests to work properly
f.setLocation(0, 0);
f.initComponents();
JFrameOperator jfo = new JFrameOperator(Bundle.getMessage("TitleOperationsSetup"));
// first confirm that setup has all directions selected
Assert.assertEquals("All directions selected", Setup.EAST + Setup.WEST + Setup.NORTH + Setup.SOUTH, Setup.getTrainDirection());
JCheckBoxOperator northCheckBoxOperator = new JCheckBoxOperator(jfo, Bundle.getMessage("northsouth"));
JCheckBoxOperator eastCheckBoxOperator = new JCheckBoxOperator(jfo, Bundle.getMessage("eastwest"));
// both east/west and north/south checkboxes should be set
Assert.assertTrue("North selected", northCheckBoxOperator.isSelected());
Assert.assertTrue("East selected", eastCheckBoxOperator.isSelected());
northCheckBoxOperator.push();
Assert.assertFalse("North deselected", northCheckBoxOperator.isSelected());
Assert.assertTrue("East selected", eastCheckBoxOperator.isSelected());
eastCheckBoxOperator.push();
Assert.assertTrue("North selected", northCheckBoxOperator.isSelected());
Assert.assertFalse("East deselected", eastCheckBoxOperator.isSelected());
eastCheckBoxOperator.push();
Assert.assertTrue("North selected", northCheckBoxOperator.isSelected());
Assert.assertTrue("East selected", eastCheckBoxOperator.isSelected());
// done
f.dispose();
}
use of org.netbeans.jemmy.operators.JFrameOperator 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.JFrameOperator 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