public void testEventDispatchedWithEventHidden() { int listenerCount = documentListenerCount(); recorder.componentShown(textField); HierarchyEvent event = new HierarchyEvent( textField, HierarchyEvent.SHOWING_CHANGED, textField, new JPanel(), HierarchyEvent.DISPLAYABILITY_CHANGED); recorder.eventDispatched(event); assertEquals(listenerCount, documentListenerCount()); }
public void testEventDispatchedWithComponentShown() throws InterruptedException, InvocationTargetException { int listenerCount = documentListenerCount(); JTextField textField = textField(); HierarchyEvent event = new HierarchyEvent( textField, HierarchyEvent.DISPLAYABILITY_CHANGED, textField, new JPanel(), HierarchyEvent.SHOWING_CHANGED); recorder.eventDispatched(event); recorder.componentHidden(textField); assertEquals(listenerCount, documentListenerCount()); }
public void testAutomaticallyNamesTextFieldWithoutName() { textField.setName(null); new JFrame().getContentPane().add(textField); mockRecorder .expects(once()) .method("record") .with(eq(new EnterTextEvent("JTextField_1", "abc"))); recorder.componentShown(textField); mockVisibility.stubs().method("isShowingAndHasFocus").will(returnValue(true)); textField.setText("abc"); }
public void testEnteringTextPostsEnterEvent() { mockRecorder .expects(once()) .method("record") .with(eq(new EnterTextEvent("testTextField", "abc"))); recorder.componentShown(textField); mockVisibility.stubs().method("isShowingAndHasFocus").will(returnValue(true)); textField.setText("abc"); mockRecorder.expects(once()).method("record").with(eq(new EnterTextEvent("testTextField", ""))); mockRecorder .expects(once()) .method("record") .with(eq(new EnterTextEvent("testTextField", "def"))); textField.setText("def"); }
public void testMatchesComponentType() { assertTrue( recorder.matchesComponentType( new ComponentEvent(new JTextField(), ComponentEvent.COMPONENT_SHOWN))); }
public void testRemovesAwtEventListenerOnUnRegister() { int awtListenerCount = awtListenerCount(); recorder.register(); recorder.unregister(); assertEquals(awtListenerCount(), awtListenerCount); }
public void testAddsAwtEventListenerOnRegister() { int awtListenerCount = awtListenerCount(); recorder.register(); assertEquals(awtListenerCount(), awtListenerCount + 1); }
public void testRemovesListenerWhenTabbedPaneIsHidden() { int listenerCount = documentListenerCount(); recorder.componentShown(textField); recorder.componentHidden(textField); assertEquals(listenerCount, documentListenerCount()); }
public void testAddsListenerToTabbedPaneWhenTabbedPaneIsShown() { int listenerCount = documentListenerCount(); recorder.componentShown(textField); assertTrue(documentListenerCount() == listenerCount + 1); }