public void testContextIsJDialogWhenJDialogIsShown() { JDialog dialog = new JDialog(); JButton comp = new JButton(); dialog.getContentPane().add(comp); windowContext.setActiveWindow(comp); assertSame(dialog, windowContext.activeWindow()); }
public void testContextIsJFrameWhenJFrameIsShown() { JFrame frame = new JFrame(); JButton comp = new JButton(); frame.getContentPane().add(comp); windowContext.setActiveWindow(comp); assertSame(frame, windowContext.activeWindow()); }
public void testContextIsJAppletWhenJAppletIsShown() { JApplet applet = new JApplet(); JButton button = new JButton(); applet.getContentPane().add(button); windowContext.setActiveWindow(applet); assertSame(applet, windowContext.activeWindow()); }
public void testFiresDialogOpenedEventWhenDialogIsShown() { Mock mockWindowContextListener = mock(WindowContextListener.class); windowContext.addWindowContextListener( (WindowContextListener) mockWindowContextListener.proxy()); mockWindowContextListener.expects(once()).method("dialogShown"); windowContext.setActiveWindow(new JDialog((Frame) null, "test")); }
public void testListenerIsNotNotifiedWhenRemoved() { Mock mockWindowContextListener = mock(WindowContextListener.class); WindowContextListener listener = (WindowContextListener) mockWindowContextListener.proxy(); windowContext.addWindowContextListener(listener); windowContext.removeWindowContextListener(listener); mockWindowContextListener.expects(never()).method("dialogShown"); windowContext.setActiveWindow(new JDialog((Frame) null, "test")); }
public void testFindsTopLevelWindowIfActiveWindowIsInternalFrame() { JFrame frame = new JFrame("testTopLevelWindow"); JDesktopPane pane = new JDesktopPane(); JInternalFrame internalFrame = new JInternalFrame("Test"); pane.add(internalFrame); frame.setContentPane(pane); windowContext.setActiveWindow(internalFrame); assertSame(frame, windowContext.activeTopLevelWindow()); frame.dispose(); }
public void testClosesOpenDialogs() { final JDialog dialog = new JDialog(); windowContext.setActiveWindow(dialog); new Thread( new Runnable() { public void run() { windowContext.propertyChange( new PropertyChangeEvent(this, "focusOwner", null, dialog)); } }) .start(); windowContext.closeAllDialogs(); }
public void testWaitsForDialogToClose() { final JDialog dialog = new JDialog((Frame) null, "title"); setFocusManager(dialog); windowContext.setActiveWindow(dialog); final JFrame frame = new JFrame("newFocusOwner"); new Thread( new Runnable() { public void run() { windowContext.setActiveWindow(frame); } }) .start(); windowContext.waitForDialogClosing("title", 1000); assertSame(frame, windowContext.activeWindow()); }