|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
junit.extensions.abbot.ResolverFixture
junit.extensions.abbot.ComponentTestFixture
Simple wrapper for testing 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
showFrame(Component)
when testing individual components, or
showWindow(Window)
when testing a Frame, Dialog, or Window.
Nested Class Summary |
Nested classes inherited from class junit.extensions.abbot.ResolverFixture |
ResolverFixture.ComponentMatcher |
Field Summary | |
static int |
EVENT_GENERATION_DELAY
Typical delay to wait for a robot event to be translated into a Java event. |
static int |
POPUP_DELAY
|
static int |
WINDOW_DELAY
|
Constructor Summary | |
ComponentTestFixture()
Default Constructor. |
|
ComponentTestFixture(String name)
Construct a test case with the given name. |
Method Summary | |
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 Robot |
getRobot()
Return an Abbot 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 boolean |
isShowing(String id)
Returns whether a Component is showing. |
void |
runBare()
If any exceptions are thrown on the event dispatch thread, they count as errors. |
protected Frame |
showFrame(Component comp)
This method should be invoked to display the component under test. |
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)
Deprecated. Use showModalDialog(Runnable)
instead. |
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. |
Methods inherited from class junit.extensions.abbot.ResolverFixture |
createHierarchy, getFinder, getHierarchy, getResolver |
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, toString |
Methods inherited from class junit.framework.Assert |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int EVENT_GENERATION_DELAY
public static final int WINDOW_DELAY
public static final int POPUP_DELAY
Constructor Detail |
public ComponentTestFixture(String name)
public ComponentTestFixture()
Method Detail |
protected Robot getRobot()
protected WindowTracker getWindowTracker()
protected Frame showFrame(Component comp)
protected Frame showFrame(Component comp, Dimension size)
protected void showWindow(Window w)
protected void showWindow(Window w, Dimension size)
protected void showWindow(Window w, Dimension size, boolean pack)
Modal dialogs may be shown with this method without blocking.
protected void hideWindow(Window w)
protected void disposeWindow(Window w)
protected void installPopup(Component invoker, JPopupMenu popup)
protected void showPopup(JPopupMenu popup, Component invoker)
protected void showPopup(JPopupMenu popup, Component invoker, int x, int y)
protected Dialog showModalDialog(Runnable showAction) throws Exception
showWindow()
method instead).The given Runnable should contain the code which will show the modal dialog (and thus block); it will be run on the event dispatch thread. This method will return when a dialog becomes visible which contains the given component (which may be any component which will appear on the dialog), or the standard timeout (10s) is reached, at which point a RuntimeException will be thrown.
For example,
Frame parent = ...;
showModalDialog(new Runnable) {
public void run() {
JOptionPane.showInputDialog(parent, "Hit me");
}
});
Exception
showWindow(java.awt.Window)
,
showWindow(java.awt.Window,java.awt.Dimension)
,
showWindow(java.awt.Window,java.awt.Dimension,boolean)
protected Dialog showModalDialog(Runnable showAction, Component contents) throws Exception
showModalDialog(Runnable)
instead.
showModalDialog(Runnable)
,
but provides for the case where some of the Dialog's contents are known
beforehand.
Exception
protected boolean isShowing(String id)
protected void fixtureSetUp() throws Throwable
fixtureSetUp
in class ResolverFixture
Throwable
protected void fixtureTearDown() throws Throwable
fixtureTearDown
in class ResolverFixture
Throwable
public void runBare() throws Throwable
runBare
in class ResolverFixture
Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |