コード例 #1
0
 public void testContextIsJDialogWhenJDialogIsShown() {
   JDialog dialog = new JDialog();
   JButton comp = new JButton();
   dialog.getContentPane().add(comp);
   windowContext.setActiveWindow(comp);
   assertSame(dialog, windowContext.activeWindow());
 }
コード例 #2
0
 public void testContextIsJFrameWhenJFrameIsShown() {
   JFrame frame = new JFrame();
   JButton comp = new JButton();
   frame.getContentPane().add(comp);
   windowContext.setActiveWindow(comp);
   assertSame(frame, windowContext.activeWindow());
 }
コード例 #3
0
 public void testContextIsJAppletWhenJAppletIsShown() {
   JApplet applet = new JApplet();
   JButton button = new JButton();
   applet.getContentPane().add(button);
   windowContext.setActiveWindow(applet);
   assertSame(applet, windowContext.activeWindow());
 }
コード例 #4
0
 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"));
 }
コード例 #5
0
 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"));
 }
コード例 #6
0
 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();
 }
コード例 #7
0
 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();
 }
コード例 #8
0
 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());
 }