Search in sources :

Example 1 with JLabelOperator

use of org.netbeans.jemmy.operators.JLabelOperator 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();
}
Also used : JRadioButtonOperator(org.netbeans.jemmy.operators.JRadioButtonOperator) JButtonOperator(org.netbeans.jemmy.operators.JButtonOperator) JComboBox(javax.swing.JComboBox) JLabelOperator(org.netbeans.jemmy.operators.JLabelOperator) JFrameOperator(org.netbeans.jemmy.operators.JFrameOperator) Test(org.junit.Test)

Aggregations

JComboBox (javax.swing.JComboBox)1 Test (org.junit.Test)1 JButtonOperator (org.netbeans.jemmy.operators.JButtonOperator)1 JFrameOperator (org.netbeans.jemmy.operators.JFrameOperator)1 JLabelOperator (org.netbeans.jemmy.operators.JLabelOperator)1 JRadioButtonOperator (org.netbeans.jemmy.operators.JRadioButtonOperator)1