public void testContextIsJDialogWhenJDialogIsShown() {
   JDialog dialog = new JDialog();
   JButton comp = new JButton();
   dialog.getContentPane().add(comp);
   windowContext.setActiveWindow(comp);
   assertSame(dialog, 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 testContextIsJFrameWhenJFrameIsShown() {
   JFrame frame = new JFrame();
   JButton comp = new JButton();
   frame.getContentPane().add(comp);
   windowContext.setActiveWindow(comp);
   assertSame(frame, windowContext.activeWindow());
 }
 public void testWaitForDialogWithActiveWindowAsTargetDialog() throws InterruptedException {
   JFrame frame = new JFrame();
   JDialog testDialog = new JDialog(frame, "testDialog");
   setFocusManager(testDialog);
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, testDialog));
   windowContext.waitForDialogOpening("testDialog", 10);
   assertSame(testDialog, windowContext.activeWindow());
   testDialog.dispose();
   frame.dispose();
 }
 public void testContextIsJAppletWhenACompentInItHasFocus() {
   Frame frame = new Frame();
   JApplet applet = new JApplet();
   JButton button = new JButton();
   frame.add(applet);
   applet.getContentPane().add(button);
   setFocusManager(button);
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, button));
   assertSame(applet, windowContext.activeWindow());
 }
 public void testContextIsJFrameWhenInternalFrameIsShown() {
   JFrame frame = new JFrame();
   JInternalFrame internalFrame = new JInternalFrame();
   JTextField textField = new JTextField();
   setFocusManager(textField);
   internalFrame.getContentPane().add(textField);
   frame.getContentPane().add(internalFrame);
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, textField));
   assertSame(frame, windowContext.activeWindow());
   assertSame(frame, windowContext.activeTopLevelWindow());
 }
 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());
 }
 public void testWaitForActiveDialogWhenDialogIsNotReady() throws InterruptedException {
   final JDialog testDialog = new JDialog(new JFrame(), "testDialog");
   setFocusManager(testDialog);
   new Thread(
           new Runnable() {
             public void run() {
               windowContext.propertyChange(
                   new PropertyChangeEvent(this, "focusOwner", null, testDialog));
             }
           })
       .start();
   windowContext.waitForDialogOpening("testDialog", 10);
   assertEquals(testDialog, windowContext.activeWindow());
   testDialog.dispose();
 }
 public void testSetsActiveWindowToNullIfThereIsNoRootPaneContainer() {
   JButton button = new JButton();
   KeyboardFocusManager.setCurrentKeyboardFocusManager(new TestKeyboardFocusManager(button));
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, button));
   assertNull(windowContext.activeWindow());
 }
 public void testSetsActiveWindowWhenFocusChanges() {
   JFrame frame = new JFrame();
   KeyboardFocusManager.setCurrentKeyboardFocusManager(new TestKeyboardFocusManager(frame));
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, frame));
   assertSame(frame, windowContext.activeWindow());
 }