|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--junit.extensions.awt.tester.ComponentTester
Provide basic actions and assertions for anything of class Component.
Derive from this class to implement actions and assertions specific to
a given component class. Actions are generally user-driven actions such
as menu selection, table selection, popup menus, etc. Assertions are
either independent of any component (and should be implemented in this
class), or take a component as the first argument, and perform some check
on that component. Extensions must be in the
junit.extensions.awt.tester
package and be named the name of
the Component subclass followed by "Tester". For example, the JButton
tester class is junit.extensions.awt.tester.JButtonTester
.
All actions should have the following signature:
public void actionWhat(Component c, ...);
All assertions should have one of the following signatures:
public boolean assertWhat(...);
public boolean assertWhat(Component c, ...);
Property checks may also be implemented in cases where the component
"property" might not be readily available or easily comparable, e.g.
see JPopupMenuTester.getMenuLabels()
.
public Object getProperty(Component c);
public boolean isProperty(Component c);
Be careful not to name any support methods with the property signature,
since these are scanned dynamically to populate the editor's action
menus.
Field Summary | |
protected static int |
EM_AWT
Post events to the AWT event queue. |
protected static int |
EM_PROG
Use programmatic control where possible. |
protected static int |
EM_ROBOT
Use java.awt.Robot to generate events. |
protected static int |
eventMode
Only robot mode is currently supported. |
Constructor Summary | |
ComponentTester(ComponentFinder finder)
|
Method Summary | |
(package private) static void |
Set up the underlying robot and initialize descriptions. |
void |
actionClick(java.awt.Component comp)
Click on the center of the component. |
void |
actionClick(java.awt.Component comp,
int x,
int y)
Click on the component at the given location. |
void |
actionClick(java.awt.Component comp,
int x,
int y,
int buttons)
Click on the component at the given location. |
void |
actionDelay(int ms)
Delay the given number of ms. |
void |
actionKeyStroke(java.lang.String kc,
java.lang.String mods)
Send the given keystroke to the program. |
void |
actionMenuItem(java.awt.Component item)
Select the given menu item. |
void |
actionPopupMenuItem(java.awt.Component invoker,
int x,
int y,
java.lang.String itemName)
Pop up a menu at the given location on the given component; Select the given item. |
void |
actionShowPopupMenu(java.awt.Component invoker)
Pop up a menu in the center of the given component. |
void |
actionShowPopupMenu(java.awt.Component invoker,
int x,
int y)
Pop up a menu at the given location on the given component. |
boolean |
assertFrameShowing(java.lang.String title)
Returns whether frame/dialog with the given title is showing. |
protected void |
click(java.awt.Component comp)
Click in the center of the given component. |
protected void |
click(java.awt.Component comp,
int buttons)
|
protected void |
click(java.awt.Component comp,
int x,
int y)
|
protected void |
click(java.awt.Component comp,
int x,
int y,
int buttons)
Click in the given part of the component. |
java.lang.String |
defaultTag(java.awt.Component comp)
Component names take precedence over other identifying tags. |
protected static void |
delay(int ms)
Sleep for the given duration of ms. |
java.lang.String |
deriveTag(java.awt.Component comp)
For a generic component, there's nothing we can really use to identify the component, except maybe toString, but that's probably too volatile. |
boolean |
equals(java.lang.Object obj1,
java.lang.Object obj2)
Perform piecewise comparisons of arrays in addition to regular comparisons. |
static java.lang.Object[] |
eval(Resolver resolver,
ComponentFinder finder,
java.lang.String[] args,
java.lang.Class[] params)
Evaluate the given set of arguments into the given set of types. |
static java.lang.Object |
eval(Resolver resolver,
ComponentFinder finder,
java.lang.String arg,
java.lang.Class cls)
Convert the given string into the given class, if possible, using any available converters if conversion to basic types fails. |
java.lang.reflect.Method[] |
getActions()
Return a list of all actions defined by this class that don't depend on a component argument. |
java.lang.reflect.Method[] |
getAssertions()
Return a list of all assertions defined by this class that don't depend on a component argument. |
static int |
getAutoDelay()
|
java.lang.reflect.Method[] |
getComponentActions()
Return a list of all actions defined by this class that require a component argument. |
java.lang.reflect.Method[] |
getComponentAssertions()
Return a list of all assertions defined by this class that require a component argument. |
static Converter |
getConverter(java.lang.Class cls)
Find a string converter for the given class. |
static java.lang.String |
getEventID(java.lang.Class cls,
int id,
java.lang.String prefix)
|
static int |
getEventID(java.lang.Class cls,
java.lang.String id)
Return the numeric event ID corresponding to the given string. |
protected ComponentFinder |
getFinder()
|
static java.lang.String |
getKeyCode(int keycode)
|
static int |
getKeyCode(java.lang.String code)
|
static javax.swing.KeyStroke |
getKeyStroke(char ch)
Return the keycode KeyStroke corresponding to the given character, as best we can guess it. |
static java.lang.String |
getModifiers(int flags)
Convert the integer flags into a string representation. |
static int |
getModifiers(java.lang.String mods)
Convert the string representation into the actual modifier mask. |
java.lang.reflect.Method[] |
getPropertyChecks()
Return a list of all property checks defined by this class. |
protected static void |
key(int keycode)
Type the given keycode with no modifiers. |
protected static void |
key(int keycode,
int modifiers)
Type the given keycode with the given modifiers. |
protected static void |
keyPress(int keycode)
Send a key press event. |
protected static void |
keyRelease(int keycode)
Send a key release event. |
protected void |
keyString(java.lang.String str)
Type the given string. |
protected void |
keyStroke(char ch)
Type the given character. |
protected static void |
mouseMove(java.awt.Component comp)
Move the pointer to the center of the given component. |
protected static void |
mouseMove(java.awt.Component comp,
int x,
int y)
Move the pointer to the given coordinates relative to the given component. |
protected static void |
mouseMove(int x,
int y)
Move the mouse to the given location. |
protected static void |
mousePress(int buttons)
Send a button press event. |
protected static void |
mouseRelease(int buttons)
Send a button release event. |
static java.lang.String[] |
parseArgs(java.lang.String value)
Convert the comma-separated list into individual strings. |
static void |
sendEvent(java.awt.AWTEvent event)
Send the given event as appropriate to the event-generation mode. |
protected static void |
setDocumentationProperties(java.lang.String base,
java.lang.String menuName,
java.lang.String desc,
java.lang.String argDesc)
Install the given documentation properties. |
static void |
setRobotDelay(int ms)
Allow this to be adjusted, mostly for testing. |
protected static java.lang.String |
simpleClassName(java.lang.Class cls)
|
boolean |
stringMatch(java.lang.String pattern,
java.lang.String actual)
|
protected static void |
waitForIdle()
Wait for an idle event queue. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static int EM_ROBOT
protected static int EM_AWT
protected static int EM_PROG
protected static int eventMode
Constructor Detail |
public ComponentTester(ComponentFinder finder)
Method Detail |
public static int getAutoDelay()
static void()
protected static void setDocumentationProperties(java.lang.String base, java.lang.String menuName, java.lang.String desc, java.lang.String argDesc)
protected ComponentFinder getFinder()
public java.lang.String defaultTag(java.awt.Component comp)
public java.lang.String deriveTag(java.awt.Component comp)
public static void setRobotDelay(int ms)
public void actionDelay(int ms)
public void actionMenuItem(java.awt.Component item)
public void actionPopupMenuItem(java.awt.Component invoker, int x, int y, java.lang.String itemName) throws ComponentNotFoundException
public void actionShowPopupMenu(java.awt.Component invoker)
public void actionShowPopupMenu(java.awt.Component invoker, int x, int y)
public void actionClick(java.awt.Component comp)
public void actionClick(java.awt.Component comp, int x, int y)
public void actionClick(java.awt.Component comp, int x, int y, int buttons)
public void actionKeyStroke(java.lang.String kc, java.lang.String mods)
public boolean assertFrameShowing(java.lang.String title)
public java.lang.reflect.Method[] getActions()
public java.lang.reflect.Method[] getComponentActions()
public java.lang.reflect.Method[] getPropertyChecks()
public java.lang.reflect.Method[] getAssertions()
public java.lang.reflect.Method[] getComponentAssertions()
protected static void mouseMove(int x, int y)
protected static void mousePress(int buttons)
protected static void mouseRelease(int buttons)
protected static void keyPress(int keycode)
protected static void keyRelease(int keycode)
protected static void delay(int ms)
protected static void waitForIdle()
protected static void mouseMove(java.awt.Component comp)
protected static void mouseMove(java.awt.Component comp, int x, int y)
protected static void key(int keycode)
protected static void key(int keycode, int modifiers)
protected void keyStroke(char ch)
protected void keyString(java.lang.String str)
protected void click(java.awt.Component comp)
protected void click(java.awt.Component comp, int buttons)
protected void click(java.awt.Component comp, int x, int y)
protected void click(java.awt.Component comp, int x, int y, int buttons)
public static void sendEvent(java.awt.AWTEvent event)
protected static java.lang.String simpleClassName(java.lang.Class cls)
public static Converter getConverter(java.lang.Class cls)
public static java.lang.String[] parseArgs(java.lang.String value)
public static java.lang.Object eval(Resolver resolver, ComponentFinder finder, java.lang.String arg, java.lang.Class cls) throws java.lang.IllegalArgumentException, ComponentNotFoundException
public static java.lang.Object[] eval(Resolver resolver, ComponentFinder finder, java.lang.String[] args, java.lang.Class[] params) throws java.lang.IllegalArgumentException, ComponentNotFoundException
public static javax.swing.KeyStroke getKeyStroke(char ch)
public static java.lang.String getEventID(java.lang.Class cls, int id, java.lang.String prefix)
public static int getEventID(java.lang.Class cls, java.lang.String id)
public static int getModifiers(java.lang.String mods)
public static java.lang.String getModifiers(int flags)
public static java.lang.String getKeyCode(int keycode)
public static int getKeyCode(java.lang.String code)
public boolean equals(java.lang.Object obj1, java.lang.Object obj2)
public boolean stringMatch(java.lang.String pattern, java.lang.String actual)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |