use of jmri.util.swing.SamplePane 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);
}
Aggregations