final CountingPanelListener l = new CountingPanelListener(); instance.addPanelListener(l);
/** * Shows and hides the EnhancedPanel instance several times in a * JOptionPane and counts these events. */ @Test public void testEvents4JOptionPane() throws Exception { final CountingPanelListener l = new CountingPanelListener(); instance.addPanelListener(l); final String title = EnhancedPanelIT.class.getSimpleName(); final Runnable makeVisible = new Runnable() { @Override public void run() { JOptionPane.showMessageDialog( null, instance, title, JOptionPane.INFORMATION_MESSAGE); } }; for (int i = 1; i <= 3; i++) { runOnEdt(makeVisible); final JDialogOperator dialog = new JDialogOperator(title); // wait for JOptionPane assertEquals(i, l.shown); assertEquals(i - 1, l.hidden); final JButtonOperator button = new JButtonOperator(dialog); button.push(); button.getQueueTool().waitEmpty(WAIT_EMPTY); assertEquals(i, l.shown); assertEquals(i, l.hidden); } }
assertEquals(0, listeners.length); listener = new CountingPanelListener();
assertEquals(0, listeners.length); listener = new CountingPanelListener();
@Test public void testFireAncestorWindowHidden() { final CountingPanelListener l = new CountingPanelListener(); instance.addPanelListener(l); instance.addPanelListener(l); // add again to receive same event twice! assertEquals(0, l.hidden); PanelEvent event = null; instance.fireAncestorWindowHidden(event); assertEquals(2, l.hidden); }
@Test public void testFireAncestorWindowShown() { final CountingPanelListener l = new CountingPanelListener(); instance.addPanelListener(l); instance.addPanelListener(l); // add again to receive same event twice! assertEquals(0, l.shown); PanelEvent event = null; instance.fireAncestorWindowShown(event); assertEquals(2, l.shown); }