| junit.extensions.abbot.ComponentTestFixture
All known Subclasses: abbot.tester.RobotAppletTest, abbot.tester.JSpinnerTesterTest, junit.extensions.abbot.ComponentTestFixtureTest, abbot.tester.JTableTesterTest, abbot.tester.JTreeTesterTest, abbot.tester.ListTesterTest, abbot.tester.WindowTrackerTest, abbot.tester.JSliderTesterTest, abbot.util.EventNormalizerTest, abbot.editor.widgets.AbstractComponentDecoratorTest, abbot.tester.JListTesterTest, example.ArrowButtonTest, abbot.editor.HierarchyWriterTest, abbot.editor.ScriptEditorTest, abbot.tester.InputStateTest, abbot.editor.LookAndFeelPreserverTest, abbot.tester.JTextComponentTesterTest, abbot.tester.TextComponentTesterTest, example.LabeledListTest, abbot.tester.RobotDragDropTest, abbot.finder.BasicFinderTest, abbot.editor.ScriptEditorFrameTest, abbot.util.AWTTest, abbot.tester.ButtonTesterTest, abbot.editor.ComponentTreeTest, example.CelsiusConverterTest, abbot.util.WeakAWTEventListenerTest, abbot.finder.AWTHierarchyTest, abbot.tester.RobotAWTModeTest, abbot.tester.AbstractButtonTesterTest, abbot.tester.JComponentTesterTest, abbot.PlatformTest, abbot.editor.widgets.ArrayEditorTest, abbot.tester.JComboBoxTesterTest, abbot.tester.FrameTesterTest, abbot.editor.CompactHierarchyTest, abbot.editor.ComponentPropertyModelTest, abbot.tester.JTextFieldTesterTest, junit.extensions.abbot.ResolverFixture, abbot.tester.KeyStrokeMapTest, abbot.tester.JFileChooserTesterTest, abbot.tester.CheckboxTesterTest, abbot.editor.ScriptTableTest, abbot.finder.TestHierarchyTest, abbot.util.BugsTest, abbot.tester.ComponentTesterTest, abbot.tester.JToolBarTesterTest, abbot.tester.FileDialogTesterTest, abbot.editor.ComponentNodeTest, abbot.tester.JInternalFrameTesterTest, abbot.tester.RobotTest, abbot.tester.ChoiceTesterTest, abbot.tester.JScrollBarTesterTest, abbot.tester.extensions.JGraphTesterTest, abbot.tester.JSplitPaneTesterTest, abbot.tester.JTabbedPaneTesterTest, abbot.editor.widgets.TextFieldTest,
ComponentTestFixture | abstract public class ComponentTestFixture extends TestCase (Code) | | Fixture for testing AWT and/or JFC/Swing components under JUnit. Ensures
proper setup and cleanup for a GUI environment. Provides methods for
automatically placing a GUI component within a frame and properly handling
Window showing/hiding (including modal dialogs). Catches exceptions thrown
on the event dispatch thread and rethrows them as test failures.
Use
ComponentTestFixture.showFrame(Component) when testing individual components, or
ComponentTestFixture.showWindow(Window) when testing a
Frame ,
Dialog , or
Window .
Any member fields you define which are classes derived from any of the
classes in
ComponentTestFixture.DISPOSE_CLASSES will be automatically set to null after
the test is run.
WARNING: Any tests which use significant or scarce resources
and reference them in member fields should explicitly null those fields in
the tearDown method if those classes are not included or derived from those
in
ComponentTestFixture.DISPOSE_CLASSES . Otherwise the resources will not be subject
to GC until the
TestCase itself and any containing
junit.framework.TestSuite is
disposed (which, in the case of the standard JUnit test runners, is
never).
|
Inner Class :protected class ComponentMatcher implements Matcher | |
Field Summary | |
final protected static Class[] | DISPOSE_CLASSES Any member data derived from these classes will be automatically set
to null after the test has run. | final public static int | EVENT_GENERATION_DELAY Typical delay to wait for a robot event to be translated into a Java
event. | final public static int | POPUP_DELAY | final public static int | WINDOW_DELAY |
Method Summary | |
protected Hierarchy | createHierarchy() Provide for derived classes to provide their own Hierarchy. | protected void | disposeAll() Dispose of all extant windows. | protected void | disposeWindow(Window w) Synchronous, safe dispose of a window. | protected void | fixtureSetUp() Ensure proper test harness setup and teardown that won't
be inadvertently overridden by a derived class. | protected void | fixtureTearDown() Handles restoration of system state. | protected ComponentFinder | getFinder() Obtain a component finder to look up components. | protected Hierarchy | getHierarchy() Obtain a consistent hierarchy. | protected Robot | getRobot() Return an Abbot
abbot.tester.Robot for basic event generation. | protected WindowTracker | getWindowTracker() Return a WindowTracker instance. | protected void | hideWindow(Window w) Synchronous, safe hide of a window. | protected void | installPopup(Component invoker, JPopupMenu popup) Install the given popup on the given component. | protected void | invokeAndWait(Runnable runnable) Convenience for getRobot().invokeAndWait(Runnable) . | protected void | invokeLater(Runnable runnable) Convenience for getRobot().invokeLater(Runnable) . | protected boolean | isShowing(String id) Returns whether a Component is showing. | public void | runBare() Override the default junit.framework.TestCase#RunBare()
to ensure proper test harness setup and teardown that won't
likely be accidentally overridden by a derived class.
If any exceptions are thrown on the event dispatch thread, they count
as errors. | protected void | setModifiers(int modifiers, boolean pressed) Convenience method to set key modifiers. | protected Frame | showFrame(Component comp) This method should be invoked to display the component under test.
The frame's size will be its preferred size. | protected Frame | showFrame(Component comp, Dimension size) This method should be invoked to display the component under test,
when a specific size of frame is desired. | protected Dialog | showModalDialog(Runnable showAction) Display a modal dialog and wait for it to show. | protected Dialog | showModalDialog(Runnable showAction, Component contents) | protected void | showPopup(JPopupMenu popup, Component invoker) Safely install and display a popup in the center of the given
component, returning when it is visible. | protected void | showPopup(JPopupMenu popup, Component invoker, int x, int y) Safely install and display a popup, returning when it is visible. | protected void | showWindow(Window w) Safely display a window with proper EDT synchronization. | protected void | showWindow(Window w, Dimension size) Safely display a window with proper EDT synchronization. | protected void | showWindow(Window w, Dimension size, boolean pack) Safely display a window with proper EDT synchronization. | protected void | sleep() Convenience method to sleep for a UI interval
(same as getRobot().sleep()). | protected void | waitForWindow(Window w, boolean visible) Return when the window is ready for input or times out waiting. |
DISPOSE_CLASSES | final protected static Class[] DISPOSE_CLASSES(Code) | | Any member data derived from these classes will be automatically set
to null after the test has run. This enables GC of said
classes without GC of the test itself (the default JUnit runners never
release their references to the tests) or requiring explicit
null -setting in the
TestCase.tearDown method.
|
EVENT_GENERATION_DELAY | final public static int EVENT_GENERATION_DELAY(Code) | | Typical delay to wait for a robot event to be translated into a Java
event.
|
POPUP_DELAY | final public static int POPUP_DELAY(Code) | | |
WINDOW_DELAY | final public static int WINDOW_DELAY(Code) | | |
ComponentTestFixture | public ComponentTestFixture(String name)(Code) | | Construct a test case with the given name.
|
ComponentTestFixture | public ComponentTestFixture()(Code) | | Default Constructor. The name will be automatically set from the
selected test method.
|
createHierarchy | protected Hierarchy createHierarchy()(Code) | | Provide for derived classes to provide their own Hierarchy.
|
disposeAll | protected void disposeAll()(Code) | | Dispose of all extant windows.
|
fixtureSetUp | protected void fixtureSetUp() throws Throwable(Code) | | Ensure proper test harness setup and teardown that won't
be inadvertently overridden by a derived class.
|
fixtureTearDown | protected void fixtureTearDown() throws Throwable(Code) | | Handles restoration of system state. Automatically disposes of any
Components used in the test.
|
getHierarchy | protected Hierarchy getHierarchy()(Code) | | Obtain a consistent hierarchy.
|
getWindowTracker | protected WindowTracker getWindowTracker()(Code) | | Return a WindowTracker instance.
|
installPopup | protected void installPopup(Component invoker, JPopupMenu popup)(Code) | | Install the given popup on the given component. Takes care of
installing the appropriate mouse handler to activate the popup.
|
invokeAndWait | protected void invokeAndWait(Runnable runnable)(Code) | | Convenience for getRobot().invokeAndWait(Runnable) .
|
invokeLater | protected void invokeLater(Runnable runnable)(Code) | | Convenience for getRobot().invokeLater(Runnable) .
|
isShowing | protected boolean isShowing(String id)(Code) | | Returns whether a Component is showing. The ID may be the component
name or, in the case of a Frame or Dialog, the title. Regular
expressions may be used, but must be delimited by slashes, e.g. /expr/.
Returns if one or more matches is found.
|
runBare | public void runBare() throws Throwable(Code) | | Override the default junit.framework.TestCase#RunBare()
to ensure proper test harness setup and teardown that won't
likely be accidentally overridden by a derived class.
If any exceptions are thrown on the event dispatch thread, they count
as errors. They will not, however supersede any failures/errors
thrown by the test itself unless thrown prior to the main test
failure.
|
setModifiers | protected void setModifiers(int modifiers, boolean pressed)(Code) | | Convenience method to set key modifiers. Using this method is
preferred to invoking
Robot.setModifiers(intboolean) or
Robot.keyPress(int) , since this method's effects will be
automatically undone at the end of the test. If you use the
Robot methods, you must remember to release any keys pressed
during the test.
Parameters: modifiers - mask indicating which modifier keys to use Parameters: pressed - whether the modifiers should be in the pressed state. |
showFrame | protected Frame showFrame(Component comp)(Code) | | This method should be invoked to display the component under test.
The frame's size will be its preferred size. This method will return
with the enclosing
Frame is showing and ready for input.
|
showFrame | protected Frame showFrame(Component comp, Dimension size)(Code) | | This method should be invoked to display the component under test,
when a specific size of frame is desired. The method will return when
the enclosing
Frame is showing and ready for input.
Parameters: comp - Parameters: size - Desired size of the enclosing frame, or null to make no explicit adjustments to its size. |
showPopup | protected void showPopup(JPopupMenu popup, Component invoker)(Code) | | Safely install and display a popup in the center of the given
component, returning when it is visible. Does not install any mouse
handlers not generate any mouse events.
|
showPopup | protected void showPopup(JPopupMenu popup, Component invoker, int x, int y)(Code) | | Safely install and display a popup, returning when it is visible.
Does not install any mouse handlers not generate any mouse events.
|
showWindow | protected void showWindow(Window w)(Code) | | Safely display a window with proper EDT synchronization. This method
blocks until the
Window is showing and ready for input.
|
showWindow | protected void showWindow(Window w, Dimension size)(Code) | | Safely display a window with proper EDT synchronization. This method
blocks until the
Window is showing and ready for input.
|
showWindow | protected void showWindow(Window w, Dimension size, boolean pack)(Code) | | Safely display a window with proper EDT synchronization. This method
blocks until the window is showing. This method will return even when
the window is a modal dialog, since the show method is called on the
event dispatch thread. The window will be packed if the pack flag is
set, and set to the given size if it is non-null .
Modal dialogs may be shown with this method without blocking.
|
sleep | protected void sleep()(Code) | | Convenience method to sleep for a UI interval
(same as getRobot().sleep()).
|
waitForWindow | protected void waitForWindow(Window w, boolean visible)(Code) | | Return when the window is ready for input or times out waiting.
Parameters: w - |
|
|