use of junit.extensions.jfcunit.finder.DialogFinder in project JMRI by JMRI.
the class LearnWarrantTest method confirmJOptionPane.
private void confirmJOptionPane(java.awt.Container frame, String title, String text) {
DialogFinder finder = new DialogFinder(title);
JUnitUtil.waitFor(() -> {
return (java.awt.Container) finder.find() != null;
}, "Found dialog + \"title\"");
java.awt.Container pane = (java.awt.Container) finder.find();
Assert.assertNotNull(title + " JOptionPane not found", pane);
pressButton(pane, text);
}
use of junit.extensions.jfcunit.finder.DialogFinder 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();
}
use of junit.extensions.jfcunit.finder.DialogFinder in project JMRI by JMRI.
the class TurnoutIconWindowTest method testPanelEditor.
@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("TurnoutIconWindowTest.testPanelEditor");
JComponent jf = panel.getTargetPanel();
TurnoutIcon icon = new TurnoutIcon(panel);
Turnout sn = jmri.InstanceManager.turnoutManagerInstance().provideTurnout("IT1");
icon.setTurnout(new NamedBeanHandle<Turnout>("IT1", sn));
icon.setDisplayLevel(Editor.TURNOUTS);
icon.setIcon("TurnoutStateClosed", new NamedIcon("resources/icons/smallschematics/tracksegments/os-lefthand-east-closed.gif", "resources/icons/smallschematics/tracksegments/os-lefthand-east-closed.gif"));
icon.setIcon("TurnoutStateThrown", new NamedIcon("resources/icons/smallschematics/tracksegments/os-lefthand-east-thrown.gif", "resources/icons/smallschematics/tracksegments/os-lefthand-east-thrown.gif"));
icon.setIcon("BeanStateInconsistent", new NamedIcon("resources/icons/smallschematics/tracksegments/os-lefthand-east-error.gif", "resources/icons/smallschematics/tracksegments/os-lefthand-east-error.gif"));
icon.setIcon("BeanStateUnknown", new NamedIcon("resources/icons/smallschematics/tracksegments/os-lefthand-east-unknown.gif", "resources/icons/smallschematics/tracksegments/os-lefthand-east-unknown.gif"));
panel.putItem(icon);
panel.setVisible(true);
Assert.assertEquals("initial state", Turnout.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", Turnout.CLOSED, sn.getState());
// Click icon change state to inactive
getHelper().enterClickAndLeave(new MouseEventData(this, icon));
Assert.assertEquals("state after two clicks", Turnout.THROWN, 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));
}
use of junit.extensions.jfcunit.finder.DialogFinder in project JMRI by JMRI.
the class NXFrameTest method testNXWarrant.
// For types from DialogFinder().findAll(..)
@SuppressWarnings("unchecked")
public void testNXWarrant() throws Exception {
if (GraphicsEnvironment.isHeadless()) {
// can't Assume in TestCase
return;
}
// load and display
File f = new File("java/test/jmri/jmrit/logix/valid/NXWarrantTest.xml");
InstanceManager.getDefault(ConfigureManager.class).load(f);
_OBlockMgr = InstanceManager.getDefault(OBlockManager.class);
_sensorMgr = InstanceManager.getDefault(SensorManager.class);
OBlock block = _OBlockMgr.getBySystemName("OB0");
NXFrame nxFrame = NXFrame.getDefault();
nxFrame.init();
nxFrame.setVisible(true);
nxFrame.setThrottleIncrement(0.075f);
nxFrame.setTimeInterval(1000);
nxFrame.setThrottleFactor(0.75f);
flushAWT();
pressButton(nxFrame, Bundle.getMessage("ButtonCancel"));
// wait to calm down after cancel
flushAWT();
flushAWT();
// after cancel, try again
nxFrame = NXFrame.getDefault();
nxFrame.init();
nxFrame.setVisible(true);
nxFrame._maxSpeedBox.setText("0.30");
nxFrame._origin.blockBox.setText("OB0");
nxFrame._destination.blockBox.setText("OB10");
pressButton(nxFrame, Bundle.getMessage("ButtonRunNX"));
confirmJOptionPane(null, Bundle.getMessage("WarningTitle"), Bundle.getMessage("NoLoco"), "OK");
nxFrame.setAddress("666");
nxFrame.setTrainName("Nick");
flushAWT();
pressButton(nxFrame, Bundle.getMessage("ButtonRunNX"));
DialogFinder finder = new DialogFinder(Bundle.getMessage("DialogTitle"));
java.awt.Container pickDia = (java.awt.Container) finder.find();
Assert.assertNotNull("PickRoute Dialog not found", pickDia);
pressButton(pickDia, Bundle.getMessage("ButtonReview"));
confirmJOptionPane(null, Bundle.getMessage("WarningTitle"), Bundle.getMessage("SelectRoute"), "OK");
List<JRadioButton> list = getRadioButtons(pickDia);
Assert.assertNotNull("Route RadioButtons not found", list);
Assert.assertEquals("Number of RadioButton Routes", 4, list.size());
getHelper().enterClickAndLeave(new MouseEventData(this, list.get(3)));
pressButton(pickDia, Bundle.getMessage("ButtonReview"));
getHelper().enterClickAndLeave(new MouseEventData(this, list.get(1)));
pressButton(pickDia, Bundle.getMessage("ButtonReview"));
nxFrame.setThrottleIncrement(0.05f);
pressButton(pickDia, Bundle.getMessage("ButtonSelect"));
//pause for NXFrame to make commands
flushAWT();
WarrantTableFrame tableFrame = WarrantTableFrame.getDefault();
Assert.assertNotNull("tableFrame", tableFrame);
WarrantTableModel model = tableFrame.getModel();
Assert.assertNotNull("tableFrame model", model);
JUnitUtil.waitFor(() -> {
return model.getRowCount() > 0;
}, "NXWarrant loaded into table");
Warrant warrant = tableFrame.getModel().getWarrantAt(0);
Assert.assertNotNull("warrant", warrant);
Assert.assertNotNull("warrant.getBlockOrders(", warrant.getBlockOrders());
List<BlockOrder> orders = warrant.getBlockOrders();
if (orders.size() != 7) {
System.out.println();
System.out.println(warrant.getSystemName() + " " + warrant.getUserName());
for (BlockOrder bo : orders) {
System.out.println(bo.toString());
}
List<ThrottleSetting> commands = warrant.getThrottleCommands();
for (ThrottleSetting ts : commands) {
System.out.println(ts.toString());
}
}
Assert.assertEquals("Num Blocks in Route", 7, warrant.getBlockOrders().size());
Assert.assertTrue("Num Comands", warrant.getThrottleCommands().size() > 5);
String name = block.getDisplayName();
jmri.util.JUnitUtil.waitFor(() -> {
return warrant.getRunningMessage().equals(Bundle.getMessage("waitForDelayStart", warrant.getTrainName(), name));
}, "Waiting message");
Sensor sensor0 = _sensorMgr.getBySystemName("IS0");
Assert.assertNotNull("Senor IS0 not found", sensor0);
jmri.util.ThreadingUtil.runOnLayout(() -> {
try {
sensor0.setState(Sensor.ACTIVE);
} catch (jmri.JmriException e) {
Assert.fail("Unexpected Exception: " + e);
}
});
jmri.util.JUnitUtil.releaseThread(this);
Assert.assertEquals("Start Block Active", (OBlock.ALLOCATED | OBlock.OCCUPIED | OBlock.RUNNING), block.getState());
JUnitUtil.waitFor(() -> {
return Bundle.getMessage("Halted", name, "0").equals(warrant.getRunningMessage());
}, "Warrant processed sensor change");
Assert.assertEquals("Halted/Resume message", warrant.getRunningMessage(), Bundle.getMessage("Halted", block.getDisplayName(), "0"));
jmri.util.ThreadingUtil.runOnGUI(() -> {
warrant.controlRunTrain(Warrant.RESUME);
});
jmri.util.JUnitUtil.waitFor(() -> {
String m = warrant.getRunningMessage();
return m.endsWith("Cmd #7.");
}, "Train starts to move at 7th command");
// OBlock sensor names
String[] route = { "OB0", "OB1", "OB2", "OB3", "OB7", "OB5", "OB10" };
block = _OBlockMgr.getOBlock("OB10");
// runtimes() in next line runs the train, then checks location
Assert.assertEquals("Train in last block", block.getSensor().getDisplayName(), runtimes(route).getDisplayName());
flushAWT();
// let calm down before running abort
flushAWT();
jmri.util.ThreadingUtil.runOnGUI(() -> {
warrant.controlRunTrain(Warrant.ABORT);
});
flushAWT();
// passed test - cleanup. Do it here so failure leaves traces.
TestHelper.disposeWindow(tableFrame, this);
ControlPanelEditor panel = (ControlPanelEditor) jmri.util.JmriJFrame.getFrame("NXWarrantTest");
// disposing this way allows test to be rerun (i.e. reload panel file) multiple times
panel.dispose(true);
// TestHelper.disposeWindow(panel, this);
// Dialog has popped up, so handle that. First, locate it.
// List<JDialog> dialogList = new DialogFinder(null).findAll(panel);
// TestHelper.disposeWindow(dialogList.get(0), this);
// confirm one message logged
jmri.util.JUnitAppender.assertWarnMessage("RosterSpeedProfile not found. Using default ThrottleFactor 0.75");
}
use of junit.extensions.jfcunit.finder.DialogFinder in project JMRI by JMRI.
the class LayoutEditorWindowTest 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 sample file
java.io.File f = new java.io.File("java/test/jmri/jmrit/display/layoutEditor/valid/SimpleLayoutEditorTest.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("My Layout");
// It's up at this point, and can be manipulated
// 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();
}
Aggregations