public void testRemovesInternalFrameListenerWhenFrameIsHidden() {
   JInternalFrame internalFrame = new JInternalFrame("title");
   int initialListenerCount = internalFrameListenerCount(internalFrame);
   mockRecorder.expects(once()).method("record").with(eq(new InternalFrameShownEvent("title")));
   recorder.componentShown(internalFrame);
   recorder.componentHidden(internalFrame);
   assertEquals(initialListenerCount, internalFrameListenerCount(internalFrame));
 }
 public void testRecordsFrameClosing()
     throws PropertyVetoException, InterruptedException, InvocationTargetException {
   JInternalFrame internalFrame = createInternalFrame();
   int initialListenerCount = internalFrameListenerCount(internalFrame);
   mockRecorder.expects(once()).method("record").with(eq(new InternalFrameShownEvent("title")));
   recorder.componentShown(internalFrame);
   mockRecorder.expects(once()).method("record").with(eq(new CloseInternalFrameEvent("title")));
   internalFrame.setClosed(true);
 }
 public void testRecordsFrameActivation()
     throws PropertyVetoException, InterruptedException, InvocationTargetException {
   final JInternalFrame internalFrame = createInternalFrame();
   int initialListenerCount = internalFrameListenerCount(internalFrame);
   mockRecorder.expects(once()).method("record").with(eq(new InternalFrameShownEvent("title")));
   recorder.componentShown(internalFrame);
   mockRecorder.expects(once()).method("record").with(eq(new ActivateInternalFrameEvent("title")));
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           try {
             internalFrame.setSelected(true);
           } catch (PropertyVetoException e) {
             e.printStackTrace();
           }
         }
       });
   waitForIdle();
 }