Search in sources :

Example 1 with JmriNamedPaneAction

use of jmri.util.swing.JmriNamedPaneAction 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)

Aggregations

JButton (javax.swing.JButton)1 JFrame (javax.swing.JFrame)1 JmriNamedPaneAction (jmri.util.swing.JmriNamedPaneAction)1 SamplePane (jmri.util.swing.SamplePane)1 MouseEventData (junit.extensions.jfcunit.eventdata.MouseEventData)1 AbstractButtonFinder (junit.extensions.jfcunit.finder.AbstractButtonFinder)1