Search in sources :

Example 6 with MouseEventData

use of junit.extensions.jfcunit.eventdata.MouseEventData in project JMRI by JMRI.

the class SensorIconWindowTest method testPanelEditor.

// DialogFinder not parameterized
@SuppressWarnings("unchecked")
public void testPanelEditor() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    jmri.jmrit.display.panelEditor.PanelEditor panel = new jmri.jmrit.display.panelEditor.PanelEditor("SensorIconWindowTest.testPanelEditor");
    JComponent jf = panel.getTargetPanel();
    SensorIcon icon = new SensorIcon(panel);
    panel.putItem(icon);
    Sensor sn = jmri.InstanceManager.sensorManagerInstance().provideSensor("IS1");
    icon.setSensor("IS1");
    icon.setIcon("BeanStateUnknown", new NamedIcon("resources/icons/smallschematics/tracksegments/circuit-error.gif", "resources/icons/smallschematics/tracksegments/circuit-error.gif"));
    //daboudreau added this for Win7
    icon.setDisplayLevel(Editor.SENSORS);
    panel.setVisible(true);
    //jf.setVisible(true);
    Assert.assertEquals("initial state", Sensor.UNKNOWN, sn.getState());
    // Click icon change state to Active
    java.awt.Point location = new java.awt.Point(icon.getLocation().x + icon.getSize().width / 2, icon.getLocation().y + icon.getSize().height / 2);
    getHelper().enterClickAndLeave(new MouseEventData(this, // component
    jf, // number clicks
    1, // modifiers
    EventDataConstants.DEFAULT_MOUSE_MODIFIERS, // isPopUpTrigger
    false, // sleeptime
    10, // position
    EventDataConstants.CUSTOM, location));
    Assert.assertEquals("state after one click", Sensor.INACTIVE, sn.getState());
    // Click icon change state to inactive
    getHelper().enterClickAndLeave(new MouseEventData(this, icon));
    Assert.assertEquals("state after two clicks", Sensor.ACTIVE, sn.getState());
    // if OK to here, close window
    TestHelper.disposeWindow(panel.getTargetFrame(), this);
    // that pops dialog, find and press Delete
    List<JDialog> dialogList = new DialogFinder(null).findAll(panel.getTargetFrame());
    JDialog d = dialogList.get(0);
    // Find the button that deletes the panel
    AbstractButtonFinder bf = new AbstractButtonFinder("Delete Panel");
    JButton button = (JButton) bf.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
    // that pops dialog, find and press Yes - Delete
    dialogList = new DialogFinder(null).findAll(panel.getTargetFrame());
    d = dialogList.get(0);
    // Find the button that deletes the panel
    bf = new AbstractButtonFinder("Yes - Dele");
    button = (JButton) bf.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) DialogFinder(junit.extensions.jfcunit.finder.DialogFinder) AbstractButtonFinder(junit.extensions.jfcunit.finder.AbstractButtonFinder) JDialog(javax.swing.JDialog) Sensor(jmri.Sensor)

Example 7 with MouseEventData

use of junit.extensions.jfcunit.eventdata.MouseEventData in project JMRI by JMRI.

the class SensorIconWindowTest method testLayoutEditor.

// DialogFinder not parameterized
@SuppressWarnings("unchecked")
public void testLayoutEditor() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    jmri.jmrit.display.layoutEditor.LayoutEditor panel = new jmri.jmrit.display.layoutEditor.LayoutEditor("SensorIconWindowTest.testLayoutEditor");
    JComponent jf = panel.getTargetPanel();
    SensorIcon icon = new SensorIcon(panel);
    panel.putItem(icon);
    Sensor sn = jmri.InstanceManager.sensorManagerInstance().provideSensor("IS1");
    icon.setSensor("IS1");
    icon.setIcon("BeanStateUnknown", new NamedIcon("resources/icons/smallschematics/tracksegments/circuit-error.gif", "resources/icons/smallschematics/tracksegments/circuit-error.gif"));
    //daboudreau added this for Win7
    icon.setDisplayLevel(Editor.SENSORS);
    panel.setVisible(true);
    //jf.setVisible(true);
    Assert.assertEquals("initial state", Sensor.UNKNOWN, sn.getState());
    // Click icon change state to Active
    java.awt.Point location = new java.awt.Point(icon.getLocation().x + icon.getSize().width / 2, icon.getLocation().y + icon.getSize().height / 2);
    getHelper().enterClickAndLeave(new MouseEventData(this, // component
    jf, // number clicks
    1, // modifiers
    EventDataConstants.DEFAULT_MOUSE_MODIFIERS, // isPopUpTrigger
    false, // sleeptime
    10, // position
    EventDataConstants.CUSTOM, location));
    Assert.assertEquals("state after one click", Sensor.INACTIVE, sn.getState());
    // Click icon change state to inactive
    getHelper().enterClickAndLeave(new MouseEventData(this, icon));
    Assert.assertEquals("state after two clicks", Sensor.ACTIVE, sn.getState());
    // if OK to here, close window
    TestHelper.disposeWindow(panel.getTargetFrame(), this);
    // that pops dialog, find and press Delete
    List<JDialog> dialogList = new DialogFinder(null).findAll(panel.getTargetFrame());
    JDialog d = dialogList.get(0);
    // Find the button that deletes the panel
    AbstractButtonFinder bf = new AbstractButtonFinder("Delete Panel");
    JButton button = (JButton) bf.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
    // that pops dialog, find and press Yes - Delete
    dialogList = new DialogFinder(null).findAll(panel.getTargetFrame());
    d = dialogList.get(0);
    // Find the button that deletes the panel
    bf = new AbstractButtonFinder("Yes - Dele");
    button = (JButton) bf.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) DialogFinder(junit.extensions.jfcunit.finder.DialogFinder) AbstractButtonFinder(junit.extensions.jfcunit.finder.AbstractButtonFinder) JDialog(javax.swing.JDialog) Sensor(jmri.Sensor)

Example 8 with MouseEventData

use of junit.extensions.jfcunit.eventdata.MouseEventData in project JMRI by JMRI.

the class SdiJfcUnitTest method testShowAndClose.

public void testShowAndClose() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // Can't assume in TestCase
        return;
    }
    JmriNamedPaneAction a = new JmriNamedPaneAction("Action", new JmriJFrameInterface(), jmri.util.swing.SamplePane.class.getName());
    a.actionPerformed(null);
    JFrame f1 = jmri.util.JmriJFrame.getFrame("SamplePane 1");
    Assert.assertTrue("found frame 1", f1 != null);
    // Find the button that opens another panel
    AbstractButtonFinder finder = new AbstractButtonFinder("Next1");
    JButton button = (JButton) finder.find(f1, 0);
    Assert.assertNotNull(button);
    // Click it and check for next frame
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
    JFrame f2 = jmri.util.JmriJFrame.getFrame("SamplePane 2");
    Assert.assertTrue("found frame 2", f2 != null);
    // Close 2 directly
    TestHelper.disposeWindow(f2, this);
    flushAWT();
    Assert.assertEquals("one pane disposed", 1, SamplePane.disposed.size());
    Assert.assertEquals("pane 2 disposed", Integer.valueOf(2), SamplePane.disposed.get(0));
    f2 = jmri.util.JmriJFrame.getFrame("SamplePane 2");
    Assert.assertTrue("frame 2 is no longer visible", f2 == null);
    // Close 1 directly
    TestHelper.disposeWindow(f1, this);
    flushAWT();
    Assert.assertEquals("one pane disposed", 2, SamplePane.disposed.size());
    Assert.assertEquals("pane 1 disposed", Integer.valueOf(1), SamplePane.disposed.get(1));
    f1 = jmri.util.JmriJFrame.getFrame("SamplePane 1");
    Assert.assertTrue("frame 1 is no longer visible", f1 == null);
}
Also used : JmriNamedPaneAction(jmri.util.swing.JmriNamedPaneAction) AbstractButtonFinder(junit.extensions.jfcunit.finder.AbstractButtonFinder) JFrame(javax.swing.JFrame) JButton(javax.swing.JButton) MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) SamplePane(jmri.util.swing.SamplePane)

Example 9 with MouseEventData

use of junit.extensions.jfcunit.eventdata.MouseEventData in project JMRI by JMRI.

the class TurnoutTableWindowTest method testShowAndClose.

public void testShowAndClose() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    // ask for the window to open
    TurnoutTableAction a = new TurnoutTableAction();
    a.actionPerformed(new java.awt.event.ActionEvent(a, 1, ""));
    // Find new table window by name
    JmriJFrame ft = JmriJFrame.getFrame(Bundle.getMessage("TitleTurnoutTable"));
    flushAWT();
    // Find the Automatic retry checkbox
    AbstractButtonFinder arfinder = new AbstractButtonFinder(Bundle.getMessage("AutomaticRetry"));
    JCheckBox ar = (JCheckBox) arfinder.find(ft, 0);
    Assert.assertNotNull(ar);
    // Click checkbox to select Automatic retry
    getHelper().enterClickAndLeave(new MouseEventData(this, ar));
    Assert.assertNotNull("AR selected", ar.getSelectedObjects());
    // Find the Show Feedback information checkbox
    AbstractButtonFinder fbfinder = new AbstractButtonFinder(Bundle.getMessage("ShowFeedbackInfo"));
    JCheckBox fb = (JCheckBox) fbfinder.find(ft, 0);
    Assert.assertNotNull(fb);
    // Click checkbox to select Show feedback information
    getHelper().enterClickAndLeave(new MouseEventData(this, fb));
    Assert.assertNotNull("FBbox selected", fb.getSelectedObjects());
    // Find the Show Lock information checkbox
    AbstractButtonFinder lkfinder = new AbstractButtonFinder(Bundle.getMessage("ShowLockInfo"));
    JCheckBox lk = (JCheckBox) lkfinder.find(ft, 0);
    Assert.assertNotNull(lk);
    // Click checkbox to select Show feedback information
    getHelper().enterClickAndLeave(new MouseEventData(this, lk));
    Assert.assertNotNull("LKbox selected", lk.getSelectedObjects());
    // Find the Show Turnout Speed details checkbox
    AbstractButtonFinder tsfinder = new AbstractButtonFinder(Bundle.getMessage("ShowTurnoutSpeedDetails"));
    JCheckBox ts = (JCheckBox) tsfinder.find(ft, 0);
    Assert.assertNotNull(ts);
    // Click checkbox to select Show feedback information
    getHelper().enterClickAndLeave(new MouseEventData(this, ts));
    Assert.assertNotNull("TSbox selected", ts.getSelectedObjects());
    // Find the Add... button
    AbstractButtonFinder abfinder = new AbstractButtonFinder(Bundle.getMessage("ButtonAdd"));
    JButton ad = (JButton) abfinder.find(ft, 0);
    Assert.assertNotNull(ad);
    // Click button to open Add Turnout pane
    getHelper().enterClickAndLeave(new MouseEventData(this, ad));
    // Find Add Turnout pane by name
    JmriJFrame fa = JmriJFrame.getFrame(Bundle.getMessage("TitleAddTurnout"));
    Assert.assertNotNull("Add window found", fa);
    // Find hardware number field
    NamedComponentFinder ncfinder = new NamedComponentFinder(JComponent.class, "sysName");
    JTextField sysNameField = (JTextField) ncfinder.find(fa, 0);
    Assert.assertNotNull(sysNameField);
    // set to "1"
    // The following line works on the CI servers, but not in some standalone cases
    //getHelper().sendString(new StringEventData(this, sysNameField, "1"));
    // workaround
    sysNameField.setText("1");
    flushAWT();
    Assert.assertEquals("name content", "1", sysNameField.getText());
    // Find system combobox
    ncfinder = new NamedComponentFinder(JComponent.class, "prefixBox");
    JComboBox<?> prefixBox = (JComboBox<?>) ncfinder.find(fa, 0);
    Assert.assertNotNull(prefixBox);
    // set to "Internal"
    prefixBox.setSelectedItem("Internal");
    // this connection type is always available
    Assert.assertEquals("Selected system item", "Internal", prefixBox.getSelectedItem());
    // Find the Add OK button
    AbstractButtonFinder okfinder = new AbstractButtonFinder(Bundle.getMessage("ButtonOK"));
    JButton okbutton = (JButton) okfinder.find(fa, 0);
    Assert.assertNotNull(okbutton);
    // Click button to add turnout
    getHelper().enterClickAndLeave(new MouseEventData(this, okbutton));
    // Ask to close Add pane
    TestHelper.disposeWindow(fa, this);
    // Open the Edit Turnout IT1 pane, how to find & click the LT1 Edit col button?
    // Find the Edit button in EDITCOL of line 0 (for LT1)
    //AbstractButtonFinder edfinder = new AbstractButtonFinder("Edit");
    //JButton editbutton = (JButton) edfinder.find(ft, 0);
    //Assert.assertNotNull(editbutton);
    // Click button to edit turnout
    //getHelper().enterClickAndLeave(new MouseEventData(this, editbutton));
    // open Edit pane by method instead
    Turnout it1 = InstanceManager.turnoutManagerInstance().getTurnout("IT1");
    // open edit pane
    a.editButton(it1);
    // Find Edit Turnout pane by name
    JmriJFrame fe = JmriJFrame.getFrame("Edit Turnout IT1");
    Assert.assertNotNull("Edit window", fe);
    // Find the Edit Cancel button
    AbstractButtonFinder canceleditfinder = new AbstractButtonFinder(Bundle.getMessage("ButtonCancel"));
    JButton cancelbutton = (JButton) canceleditfinder.find(fe, 0);
    Assert.assertNotNull(cancelbutton);
    // Click button to cancel edit turnout
    getHelper().enterClickAndLeave(new MouseEventData(this, cancelbutton));
    // Ask to close Edit pane
    TestHelper.disposeWindow(fe, this);
    // Ask to close turnout table window
    TestHelper.disposeWindow(ft, this);
    flushAWT();
    // check that turnout was created
    Assert.assertNotNull(jmri.InstanceManager.turnoutManagerInstance().getTurnout("IT1"));
}
Also used : NamedComponentFinder(junit.extensions.jfcunit.finder.NamedComponentFinder) JComboBox(javax.swing.JComboBox) JButton(javax.swing.JButton) JComponent(javax.swing.JComponent) MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) AbstractButtonFinder(junit.extensions.jfcunit.finder.AbstractButtonFinder) JmriJFrame(jmri.util.JmriJFrame) Turnout(jmri.Turnout)

Example 10 with MouseEventData

use of junit.extensions.jfcunit.eventdata.MouseEventData in project JMRI by JMRI.

the class LEConnectivityTest method testShowAndClose.

@SuppressWarnings("unchecked")
public void testShowAndClose() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // Can't Assume in TestCase
        return;
    }
    jmri.configurexml.ConfigXmlManager cm = new jmri.configurexml.ConfigXmlManager() {
    };
    // load and display test panel file
    java.io.File f = new java.io.File("java/test/jmri/jmrit/display/layoutEditor/valid/LEConnectTest.xml");
    cm.load(f);
    // time for internal listeners to calm down
    sleep(100);
    // Find new window by name (should be more distinctive, comes from sample file)
    LayoutEditor le = (LayoutEditor) jmri.util.JmriJFrame.getFrame("Connectivity Test");
    Assert.assertNotNull(le);
    // Panel is up, continue set up for tests.
    ConnectivityUtil cu = new ConnectivityUtil(le);
    Assert.assertNotNull(cu);
    BlockManager bm = jmri.InstanceManager.getDefault(jmri.BlockManager.class);
    Assert.assertNotNull(bm);
    // Test right-handed crossover connectivity turnout settings
    Block cBlock = bm.getBlock("4");
    Block pBlock = bm.getBlock("6");
    Block nBlock = bm.getBlock("5");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    ArrayList<Integer> tsList = cu.getTurnoutSettingList();
    int setting = tsList.get(0).intValue();
    Assert.assertEquals("6_4_5Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("5");
    nBlock = bm.getBlock("6");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("5_4_6Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("5");
    nBlock = bm.getBlock("2");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("5_4_2Connect", setting, Turnout.THROWN);
    cBlock = bm.getBlock("2");
    pBlock = bm.getBlock("1");
    nBlock = bm.getBlock("3");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("1_2_3Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("3");
    nBlock = bm.getBlock("1");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("3_2_1Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("1");
    nBlock = bm.getBlock("4");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("1_2_4Connect", setting, Turnout.THROWN);
    // Test left-handed crossover connectivity turnout settings
    cBlock = bm.getBlock("14");
    pBlock = bm.getBlock("13");
    nBlock = bm.getBlock("17");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("13_14_17Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("17");
    nBlock = bm.getBlock("13");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("17_14_13Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("17");
    nBlock = bm.getBlock("12");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("17_14_12Connect", setting, Turnout.THROWN);
    cBlock = bm.getBlock("12");
    pBlock = bm.getBlock("11");
    nBlock = bm.getBlock("15");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("11_12_15Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("15");
    nBlock = bm.getBlock("11");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("15_12_11Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("15");
    nBlock = bm.getBlock("14");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("15_12_14Connect", setting, Turnout.THROWN);
    // Test double crossover connectivity turnout settings
    cBlock = bm.getBlock("21");
    pBlock = bm.getBlock("20");
    nBlock = bm.getBlock("22");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("20_21_22Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("22");
    nBlock = bm.getBlock("20");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("22_21_20Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("20");
    nBlock = bm.getBlock("26");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("20_21_26Connect", setting, Turnout.THROWN);
    cBlock = bm.getBlock("22");
    pBlock = bm.getBlock("23");
    nBlock = bm.getBlock("21");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("23_22_21Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("21");
    nBlock = bm.getBlock("23");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("21_22_23Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("23");
    nBlock = bm.getBlock("25");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("23_22_25Connect", setting, Turnout.THROWN);
    cBlock = bm.getBlock("26");
    pBlock = bm.getBlock("27");
    nBlock = bm.getBlock("25");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("27_26_25Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("25");
    nBlock = bm.getBlock("27");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("25_26_27Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("27");
    nBlock = bm.getBlock("21");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("27_26_21Connect", setting, Turnout.THROWN);
    cBlock = bm.getBlock("25");
    pBlock = bm.getBlock("24");
    nBlock = bm.getBlock("26");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("24_25_26Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("26");
    nBlock = bm.getBlock("24");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("26_25_24Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("24");
    nBlock = bm.getBlock("22");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("24_25_22Connect", setting, Turnout.THROWN);
    // Test right handed turnout (with "wings" in same block) connectivity turnout settings
    cBlock = bm.getBlock("62");
    pBlock = bm.getBlock("64");
    nBlock = bm.getBlock("61");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("64_62_61Connect", setting, Turnout.THROWN);
    pBlock = bm.getBlock("61");
    nBlock = bm.getBlock("64");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("61_62_64Connect", setting, Turnout.THROWN);
    pBlock = bm.getBlock("63");
    nBlock = bm.getBlock("61");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("63_62_61Connect", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("61");
    nBlock = bm.getBlock("63");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("61_62_63Connect", setting, Turnout.CLOSED);
    // Test extended track following connectivity turnout settings
    //   Each path must go through two turnouts, whose settings are tested in order
    cBlock = bm.getBlock("32");
    pBlock = bm.getBlock("31");
    nBlock = bm.getBlock("33");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("31_32_33ConnectA", setting, Turnout.CLOSED);
    setting = tsList.get(1).intValue();
    Assert.assertEquals("31_32_33ConnectB", setting, Turnout.THROWN);
    pBlock = bm.getBlock("33");
    nBlock = bm.getBlock("31");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("33_32_31ConnectA", setting, Turnout.THROWN);
    setting = tsList.get(1).intValue();
    Assert.assertEquals("33_32_31ConnectB", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("31");
    nBlock = bm.getBlock("34");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("31_32_34ConnectA", setting, Turnout.CLOSED);
    setting = tsList.get(1).intValue();
    Assert.assertEquals("31_32_34ConnectB", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("34");
    nBlock = bm.getBlock("31");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("34_32_31ConnectA", setting, Turnout.CLOSED);
    setting = tsList.get(1).intValue();
    Assert.assertEquals("34_32_31ConnectB", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("31");
    nBlock = bm.getBlock("35");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("31_32_35ConnectA", setting, Turnout.THROWN);
    setting = tsList.get(1).intValue();
    Assert.assertEquals("31_32_35ConnectB", setting, Turnout.CLOSED);
    pBlock = bm.getBlock("35");
    nBlock = bm.getBlock("31");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("35_32_31ConnectA", setting, Turnout.CLOSED);
    setting = tsList.get(1).intValue();
    Assert.assertEquals("35_32_31ConnectB", setting, Turnout.THROWN);
    pBlock = bm.getBlock("31");
    nBlock = bm.getBlock("36");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("31_32_36ConnectA", setting, Turnout.THROWN);
    setting = tsList.get(1).intValue();
    Assert.assertEquals("31_32_36ConnectB", setting, Turnout.THROWN);
    pBlock = bm.getBlock("36");
    nBlock = bm.getBlock("31");
    cu.getTurnoutList(cBlock, pBlock, nBlock);
    tsList = cu.getTurnoutSettingList();
    setting = tsList.get(0).intValue();
    Assert.assertEquals("36_32_31ConnectA", setting, Turnout.THROWN);
    setting = tsList.get(1).intValue();
    Assert.assertEquals("36_32_31ConnectB", setting, Turnout.THROWN);
    // Ask to close window
    TestHelper.disposeWindow(le, this);
    // Dialog has popped up, so handle that. First, locate it.
    List<JDialog> dialogList = new DialogFinder(null).findAll(le);
    JDialog d = dialogList.get(0);
    // Find the button that deletes the panel
    AbstractButtonFinder finder = new AbstractButtonFinder("Delete Panel");
    JButton button = (JButton) finder.find(d, 0);
    Assert.assertNotNull(button);
    // Click button to delete panel and close window
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
    // another dialog has popped up, so handle that by finding the "Yes - Delete" button.
    dialogList = new DialogFinder(null).findAll(le);
    d = dialogList.get(0);
    finder = new AbstractButtonFinder("Yes - Delete");
    button = (JButton) finder.find(d, 0);
    Assert.assertNotNull(button);
    // Click to say yes, I really mean it.
    getHelper().enterClickAndLeave(new MouseEventData(this, button));
    le.dispose();
}
Also used : JButton(javax.swing.JButton) MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) DialogFinder(junit.extensions.jfcunit.finder.DialogFinder) AbstractButtonFinder(junit.extensions.jfcunit.finder.AbstractButtonFinder) BlockManager(jmri.BlockManager) Block(jmri.Block) JDialog(javax.swing.JDialog)

Aggregations

MouseEventData (junit.extensions.jfcunit.eventdata.MouseEventData)23 AbstractButtonFinder (junit.extensions.jfcunit.finder.AbstractButtonFinder)14 JButton (javax.swing.JButton)11 DialogFinder (junit.extensions.jfcunit.finder.DialogFinder)8 JDialog (javax.swing.JDialog)7 PanelEditor (jmri.jmrit.display.panelEditor.PanelEditor)7 JComponent (javax.swing.JComponent)6 Turnout (jmri.Turnout)5 Sensor (jmri.Sensor)4 NamedIcon (jmri.jmrit.catalog.NamedIcon)4 JFrame (javax.swing.JFrame)3 JTextField (javax.swing.JTextField)3 NamedComponentFinder (junit.extensions.jfcunit.finder.NamedComponentFinder)3 JCheckBox (javax.swing.JCheckBox)2 JComboBox (javax.swing.JComboBox)2 JmriJFrame (jmri.util.JmriJFrame)2 File (java.io.File)1 JRadioButton (javax.swing.JRadioButton)1 Block (jmri.Block)1 BlockManager (jmri.BlockManager)1