abbot.tester
Class ComponentTester

java.lang.Object
  extended by abbot.tester.Robot
      extended by abbot.tester.ComponentTester
All Implemented Interfaces:
AWTConstants
Direct Known Subclasses:
ArrowButtonTester, ButtonTester, CheckboxTester, ChoiceTester, ContainerTester, ListTester, TextComponentTester

public class ComponentTester
extends Robot

Provides basic programmatic operation of a Component and related UI objects such as windows, menus and menu bars throuh action methods. Also provides some useful assertions about properties of a Component.

There are two sets of event-generating methods. The internal, protected methods inherited from abbot.tester.Robot are for normal programmatic use within derived Tester classes. No event queue synchronization should be performed except when modifying a component for which results are required for the action itself.

The public actionXXX functions are meant to be invoked from a script or directly from a hand-written test. These actions are distinguished by name, number of arguments, and by argument type. The actionX methods will be synchronized with the event dispatch thread when invoked, so you should only do synchronization with waitForIdle when you depend on the results of a particular event prior to sending the next one (e.g. scrolling a table cell into view before selecting it). All public action methods should ensure that the actions they trigger are finished on return, or will be finished before any subsequent actions are requested.

Action methods generally represent user-driven actions such as menu selection, table selection, popup menus, etc. All actions should have the following signature:

public void actionSpinMeRoundLikeARecord(Component c, ...); public void actionPinchMe(Component c, ComponentLocation loc);

It is essential that the argument is of type Component; if you use a more-derived class, then the actual invocation becomes ambiguous since method parsing doesn't attempt to determine which identically-named method is the most-derived.

The ComponentLocation abstraction allows all derived tester classes to inherit click, popup menu, and drag variants without having to explicitly define new methods for component-specific substructures. The new class need only define the parseLocation(String) method, which should return a location specific to the component in question.

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. All assertions should have one of the following signatures:

public boolean assertMyself(...);
public boolean assertBorderIsAtrociouslyUgly(Component c, ...);
Note that these assertions do not throw exceptions but rather return a boolean value indicating success or failure. Normally these assertions will be wrapped by an abbot.script.Assert step if you want to cause a test failure, or you can manually throw the proper failure exception if the method returns false.

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(Component).

public Object getHairpiece(Component c);
public boolean isRighteouslyIndignant(Component c);
Any non-property methods with the property signature, should be added to the IGNORED_METHODS set, since property-like methods are scanned dynamically to populate the editor's action menus.

Extending ComponentTester

Following are the steps required to implement a Tester object for a custom class.

Method Naming Conventions

Action methods should be named according to the human-centric action that is being performed if at all possible. For example, use actionSelectRow in a List rather than actionSelectIndex. If there's no common usage, or if the usage is too vague or diverse, use the specific terms used in code. For example, JScrollBarTester uses actionScrollUnitUp() and actionScrollBlockUp(); since there is no common language usage for these concepts (line and page exist, but are not appropriate if what is scrolled is not text).

When naming a selection method, include the logical substructure target of the selection in the name (e.g. JTableTester.actionSelectCell(Component,JTableLocation) JTableTester.actionSelectCell()), since some components may have more than one type of selectable item within them.


Field Summary
protected static Set IGNORED_METHODS
          Add any method names here which should not show up in a dynamically generated list of property methods.
 
Fields inherited from class abbot.tester.Robot
componentDelay, defaultDelay, EM_AWT, EM_ROBOT, IDLE_TIMEOUT, MOUSELESS_MODIFIER, MOUSELESS_MODIFIER_MASK, popupDelay
 
Fields inherited from interface abbot.tester.AWTConstants
BUTTON_MASK, COPY_MASK, DRAG_THRESHOLD, LINK_MASK, MENU_SHORTCUT_KEYCODE, MENU_SHORTCUT_MASK, MENU_SHORTCUT_MODIFIER, MENU_SHORTCUT_STRING, MOVE_MASK, MULTI_CLICK_INTERVAL, POPUP_MASK, POPUP_MODIFIER, POPUP_ON_PRESS, TERTIARY_MASK, TERTIARY_MODIFIER
 
Constructor Summary
ComponentTester()
           
 
Method Summary
 void actionClick(Component comp)
          Click on the center of the component.
 void actionClick(Component c, ComponentLocation loc)
          Click on the component at the given location.
 void actionClick(Component c, ComponentLocation loc, int buttons)
          Click on the component at the given location with the given modifiers.
 void actionClick(Component c, ComponentLocation loc, int buttons, int count)
          Click on the component at the given location, with the given modifiers and click count.
 void actionClick(Component comp, int x, int y)
          Click on the component at the given location (mouse button 1).
 void actionClick(Component comp, int x, int y, int buttons)
          Click on the component at the given location.
 void actionClick(Component comp, int x, int y, int buttons, int count)
          Click on the component at the given location, specifying buttons and the number of clicks.
 void actionDelay(int ms)
          Delay the given number of ms.
 void actionDrag(Component dragSource)
          Perform a drag action.
 void actionDrag(Component dragSource, ComponentLocation loc)
          Perform a drag action.
 void actionDrag(Component dragSource, ComponentLocation loc, int buttons)
          Perform a drag action with the given modifiers.
 void actionDrag(Component dragSource, ComponentLocation loc, String buttons)
          Deprecated. Use the integer modifier mask version instead.
 void actionDrag(Component dragSource, int sx, int sy)
          Perform a drag action.
 void actionDrag(Component dragSource, int sx, int sy, String buttons)
          Deprecated. Use the ComponentLocation/ integer modifier mask version instead.
 void actionDragOver(Component target)
          Drag the current dragged object over the given component.
 void actionDragOver(Component target, ComponentLocation where)
          Drag the current dragged object over the given target/location.
 void actionDrop(Component dropTarget)
          Perform a basic drop action (implicitly causing preceding mouse drag motion).
 void actionDrop(Component dropTarget, ComponentLocation loc)
          Perform a basic drop action (implicitly causing preceding mouse drag motion).
 void actionDrop(Component dropTarget, int x, int y)
          Perform a basic drop action (implicitly causing preceding mouse drag motion).
 void actionFocus(Component comp)
          Set the focus on to the given component.
 void actionKeyPress(Component comp, int keyCode)
          Send a key press event for the given virtual key code to the given Component.
 void actionKeyPress(int keyCode)
          Generate a key press event for the given virtual key code.
 void actionKeyRelease(Component comp, int keyCode)
          Generate a key release event sent to the given component.
 void actionKeyRelease(int keyCode)
          Generate a key release event.
 void actionKeyString(Component c, String string)
          Send events required to generate the given string on the given component.
 void actionKeyString(String string)
          Send events required to generate the given string.
 void actionKeyStroke(Component c, int keyCode)
          Send the given keystroke, which must be the KeyEvent field name of a KeyEvent VK_ constant to the program.
 void actionKeyStroke(Component c, int keyCode, int modifiers)
          Send the given keystroke, which must be the KeyEvent field name of a KeyEvent VK_ constant to the program.
 void actionKeyStroke(int keyCode)
          Send the given keystroke, which must be the KeyEvent field name of a KeyEvent VK_ constant.
 void actionKeyStroke(int keyCode, int modifiers)
          Send the given keystroke, which must be the KeyEvent field name of a KeyEvent VK_ constant to the program.
 void actionMouseMove(Component comp, ComponentLocation loc)
          Move the mouse/pointer to the given location.
 void actionMousePress(Component comp, ComponentLocation loc)
          Press mouse button 1 at the given location.
 void actionMousePress(Component comp, ComponentLocation loc, int mask)
          Press mouse buttons corresponding to the given mask at the given location.
 void actionMouseRelease()
          Release any currently held mouse buttons.
 void actionSelectAWTMenuItem(Frame menuFrame, String path)
          Selects an AWT menu item (MenuItem) and returns when the invocation has triggered (though not necessarily completed).
 void actionSelectAWTMenuItemByLabel(Frame menuFrame, String path)
          Deprecated. Renamed to actionSelectAWTMenuItem(Frame,String).
 void actionSelectAWTPopupMenuItem(Component invoker, String path)
          Selects an AWT menu item and returns when the invocation has triggered (though not necessarily completed).
 void actionSelectAWTPopupMenuItemByLabel(Component invoker, String path)
          Deprecated. Renamed to actionSelectAWTPopupMenuItem(Component,String).
 void actionSelectMenuItem(Component item)
          Select the given menu item.
 void actionSelectMenuItem(Component sameWindow, String path)
          Select the given menu item, given its path and a component on the same window.
 void actionSelectPopupMenuItem(Component invoker, ComponentLocation loc, String path)
          Pop up a menu at the given location on the given component and select the given item.
 void actionSelectPopupMenuItem(Component invoker, int x, int y, String path)
          Pop up a menu at the given coordinates on the given component and select the given item.
 void actionSelectPopupMenuItem(Component invoker, String path)
          Pop up a menu at the center of the given component and select the given item.
 void actionSetModifiers(int mask, boolean pressed)
          Set the state of the given modifier keys.
 void actionShowPopupMenu(Component invoker)
          Pop up a menu in the center of the given component.
 void actionShowPopupMenu(Component invoker, ComponentLocation loc)
          Pop up a menu in the center of the given component.
 void actionShowPopupMenu(Component invoker, int x, int y)
          Pop up a menu at the given location on the given component.
 void actionWaitForIdle()
          Wait for an idle AWT event queue.
 boolean assertComponentShowing(ComponentReference ref)
          Return whether the Component represented by the given ComponentReference is available.
 boolean assertFrameShowing(Hierarchy h, String id)
          Returns whether a Window corresponding to the given String is showing.
 boolean assertFrameShowing(String id)
          Deprecated. This method does not specify the proper context for the lookup. Use assertFrameShowing(Hierarchy,String) instead.
 boolean assertImage(Component comp, File fileImage, boolean ignoreBorder)
          Return whether the component's contents matches the given image.
protected  String deriveAccessibleTag(AccessibleContext context)
          Derive a tag from the given accessible context if possible, or return null.
 String deriveTag(Component comp)
          Determine a component-specific identifier not already defined in other component attributes.
 Method[] getActions()
          Return a list of all actions defined by this class that don't depend on a component argument.
 Method[] getAssertMethods()
          Return a list of all assertions defined by this class that don't depend on a component argument.
 Method[] getComponentActions()
          Return a list of all actions defined by this class that require a component argument.
 Method[] getComponentAssertMethods()
          Return a list of all assertions defined by this class that require a component argument.
 ComponentLocation getLocation(Component c, Point where)
          Return a ComponentLocation for the given Point.
 Method[] getPropertyMethods()
          Return an array of all property check methods defined by this class.
static String getTag(Component comp)
          Return a reasonable identifier for the given component.
 Class getTestedClass(Class cls)
          Return the Component class that corresponds to this ComponentTester class.
static ComponentTester getTester(Class componentClass)
          Return a shared instance of the corresponding ComponentTester object for the given Component class, chaining up the inheritance tree if no specific tester is found for that class.
static ComponentTester getTester(Component comp)
          Return a shared instance of the appropriate ComponentTester for the given Component.
protected  boolean isCustom(Class c)
          Returns whether the given class is not a core JRE class.
 boolean isExtension()
          Return whether this tester is an extension.
 ComponentLocation parseLocation(String encoded)
          Parse the String representation of a ComponentLocation into the actual ComponentLocation object.
static void setTester(Class forClass, ComponentTester tester)
          Establish the given ComponentTester as the one to use for the given class.
static String stripHTML(String str)
          Quick and dirty strip raw text from html, for getting the basic text from html-formatted labels and buttons.
protected  void waitAction(String desc, Condition cond)
          Wait for the given condition, throwing an ActionFailedException if it times out.
 void waitForComponentShowing(ComponentReference ref)
          Wait for the Component represented by the given ComponentReference to become available.
 void waitForFrameShowing(Hierarchy h, String identifier)
          Convenience wait for a window to be displayed.
 void waitForFrameShowing(String identifier)
          Deprecated. This method does not provide sufficient context to reliably find a component. Use waitForFrameShowing(Hierarchy,String) instead.
 
Methods inherited from class abbot.tester.Robot
activate, canMoveWindows, canResizeWindows, capture, capture, capture, click, click, click, click, click, close, deiconify, delay, descriptiveClassName, drag, drag, dragOver, drop, findFocusOwner, fireAccessibleAction, focus, focus, getAutoDelay, getBorderTitle, getCanonicalClass, getCloseLocation, getDescriptiveName, getEventID, getEventID, getEventMode, getEventModeDescription, getEventPostDelay, getEventQueue, getIconifyLocation, getIconName, getIndex, getLabel, getMaximizeLocation, getMoveLocation, getName, getPreferredRobotAutoDelay, getResizeLocation, getRobot, getState, getText, getTitle, iconify, invokeAction, invokeAction, invokeAndWait, invokeAndWait, invokeLater, invokeLater, isReadyForInput, jitter, jitter, key, key, keyPress, keyRelease, keyString, keyStroke, maximize, mouseMove, mouseMove, mousePress, mousePress, mousePress, mousePress, mousePress, mouseRelease, mouseRelease, move, moveBy, normalize, postEvent, postInvocationEvent, queueBlocked, reset, resize, resizeBy, sample, sample, sample, selectAWTMenuItem, selectAWTMenuItem, selectAWTMenuItemByLabel, selectAWTPopupMenuItem, selectAWTPopupMenuItem, selectAWTPopupMenuItemByLabel, selectMenuItem, selectMenuItem, selectPopupMenuItem, sendEvent, setAutoDelay, setEventMode, setEventPostDelay, setModifiers, showPopupMenu, showPopupMenu, simpleClassName, sleep, toHierarchyPath, toString, toString, toString, userMovable, userResizable, useScreenMenuBar, wait, wait, wait, waitForIdle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IGNORED_METHODS

protected static Set IGNORED_METHODS
Add any method names here which should not show up in a dynamically generated list of property methods.

Constructor Detail

ComponentTester

public ComponentTester()
Method Detail

setTester

public static void setTester(Class forClass,
                             ComponentTester tester)
Establish the given ComponentTester as the one to use for the given class. This may be used to override the default tester for a given core class. Note that this will only work with components loaded by the framework class loader, not those loaded by the class loader for the code under test.


getTester

public static ComponentTester getTester(Component comp)
Return a shared instance of the appropriate ComponentTester for the given Component.

This method is primarily used by the scripting system, since the appropriate ComponentTester for a given Component is not known a priori. Coded unit tests should generally just create an instance of the desired type of ComponentTester for local use.


getTester

public static ComponentTester getTester(Class componentClass)
Return a shared instance of the corresponding ComponentTester object for the given Component class, chaining up the inheritance tree if no specific tester is found for that class.

The abbot tester package is searched first, followed by the tester extensions package.

This method is primarily used by the scripting system, since the appropriate ComponentTester for a given Component is not known a priori. Coded unit tests should generally just create an instance of the desired type of ComponentTester for local use.


isExtension

public final boolean isExtension()
Return whether this tester is an extension.


deriveAccessibleTag

protected String deriveAccessibleTag(AccessibleContext context)
Derive a tag from the given accessible context if possible, or return null.


getTag

public static String getTag(Component comp)
Return a reasonable identifier for the given component. Note that this should not duplicate information provided by existing attributes such as title, label, or text. This functionality is provided to assist in identification of non-standard GUI components only.


isCustom

protected boolean isCustom(Class c)
Returns whether the given class is not a core JRE class.


deriveTag

public String deriveTag(Component comp)
Determine a component-specific identifier not already defined in other component attributes. This method should be defined to something unique for custom UI components.


actionWaitForIdle

public void actionWaitForIdle()
Wait for an idle AWT event queue. Will return when there are no more events on the event queue.


actionDelay

public void actionDelay(int ms)
Delay the given number of ms.


actionSelectAWTMenuItemByLabel

public void actionSelectAWTMenuItemByLabel(Frame menuFrame,
                                           String path)
Deprecated. Renamed to actionSelectAWTMenuItem(Frame,String).


actionSelectAWTMenuItem

public void actionSelectAWTMenuItem(Frame menuFrame,
                                    String path)
Selects an AWT menu item (MenuItem) and returns when the invocation has triggered (though not necessarily completed).

Parameters:
menuFrame -
path - either a unique label or the menu path.
See Also:
Robot.selectAWTMenuItem(Frame,String)

actionSelectAWTPopupMenuItemByLabel

public void actionSelectAWTPopupMenuItemByLabel(Component invoker,
                                                String path)
Deprecated. Renamed to actionSelectAWTPopupMenuItem(Component,String).


actionSelectAWTPopupMenuItem

public void actionSelectAWTPopupMenuItem(Component invoker,
                                         String path)
Selects an AWT menu item and returns when the invocation has triggered (though not necessarily completed).

See Also:
Robot.selectAWTPopupMenuItem(Component,String)

actionSelectMenuItem

public void actionSelectMenuItem(Component item)
Select the given menu item.


actionSelectMenuItem

public void actionSelectMenuItem(Component sameWindow,
                                 String path)
Select the given menu item, given its path and a component on the same window.


actionSelectPopupMenuItem

public void actionSelectPopupMenuItem(Component invoker,
                                      String path)
Pop up a menu at the center of the given component and select the given item.


actionSelectPopupMenuItem

public void actionSelectPopupMenuItem(Component invoker,
                                      ComponentLocation loc,
                                      String path)
Pop up a menu at the given location on the given component and select the given item.


actionSelectPopupMenuItem

public void actionSelectPopupMenuItem(Component invoker,
                                      int x,
                                      int y,
                                      String path)
Pop up a menu at the given coordinates on the given component and select the given item.


actionShowPopupMenu

public void actionShowPopupMenu(Component invoker)
Pop up a menu in the center of the given component.


actionShowPopupMenu

public void actionShowPopupMenu(Component invoker,
                                ComponentLocation loc)
Pop up a menu in the center of the given component.


actionShowPopupMenu

public void actionShowPopupMenu(Component invoker,
                                int x,
                                int y)
Pop up a menu at the given location on the given component.


actionClick

public void actionClick(Component comp)
Click on the center of the component.


actionClick

public void actionClick(Component c,
                        ComponentLocation loc)
Click on the component at the given location.


actionClick

public void actionClick(Component c,
                        ComponentLocation loc,
                        int buttons)
Click on the component at the given location with the given modifiers.


actionClick

public void actionClick(Component c,
                        ComponentLocation loc,
                        int buttons,
                        int count)
Click on the component at the given location, with the given modifiers and click count.


actionClick

public void actionClick(Component comp,
                        int x,
                        int y)
Click on the component at the given location (mouse button 1).


actionClick

public void actionClick(Component comp,
                        int x,
                        int y,
                        int buttons)
Click on the component at the given location. The buttons mask should be the InputEvent masks for the desired button, e.g. InputEvent.BUTTON1_MASK. ComponentTester also defines AWTConstants.POPUP_MASK and AWTConstants.TERTIARY_MASK for platform-independent masks for those buttons. Key modifiers other than InputEvent.ALT_MASK and InputEvent.META_MASK may also be used as a convenience.


actionClick

public void actionClick(Component comp,
                        int x,
                        int y,
                        int buttons,
                        int count)
Click on the component at the given location, specifying buttons and the number of clicks. The buttons mask should be the InputEvent mask for the desired button, e.g. InputEvent.BUTTON1_MASK. ComponentTester also defines AWTConstants.POPUP_MASK and AWTConstants.TERTIARY_MASK for platform-independent masks for those buttons. Key modifiers other than InputEvent.ALT_MASK and InputEvent.META_MASK may also be used as a convenience.


actionKeyPress

public void actionKeyPress(Component comp,
                           int keyCode)
Send a key press event for the given virtual key code to the given Component.


actionKeyPress

public void actionKeyPress(int keyCode)
Generate a key press event for the given virtual key code.


actionKeyRelease

public void actionKeyRelease(Component comp,
                             int keyCode)
Generate a key release event sent to the given component.


actionKeyRelease

public void actionKeyRelease(int keyCode)
Generate a key release event.


actionSetModifiers

public void actionSetModifiers(int mask,
                               boolean pressed)
Set the state of the given modifier keys.


actionKeyStroke

public void actionKeyStroke(Component c,
                            int keyCode)
Send the given keystroke, which must be the KeyEvent field name of a KeyEvent VK_ constant to the program. Sends a key down/up, with no modifiers. The focus is changed to the target component.


actionKeyStroke

public void actionKeyStroke(int keyCode)
Send the given keystroke, which must be the KeyEvent field name of a KeyEvent VK_ constant. Sends a key press and key release, with no modifiers. Note that this method does not affect the current focus.


actionKeyStroke

public void actionKeyStroke(Component c,
                            int keyCode,
                            int modifiers)
Send the given keystroke, which must be the KeyEvent field name of a KeyEvent VK_ constant to the program. Sends a key down/up, with the given modifiers, which should be the InputEvent field name modifier masks optionally ORed together with "|". The focus is changed to the target component.


actionKeyStroke

public void actionKeyStroke(int keyCode,
                            int modifiers)
Send the given keystroke, which must be the KeyEvent field name of a KeyEvent VK_ constant to the program. Sends a key down/up, with the given modifiers, which should be the InputEvent field name modifier masks optionally ORed together with "|". Note that this does not affect the current focus.


actionKeyString

public void actionKeyString(Component c,
                            String string)
Send events required to generate the given string on the given component. This version is preferred over actionKeyString(String).


actionKeyString

public void actionKeyString(String string)
Send events required to generate the given string.


actionFocus

public void actionFocus(Component comp)
Set the focus on to the given component.


actionMouseMove

public void actionMouseMove(Component comp,
                            ComponentLocation loc)
Move the mouse/pointer to the given location.


actionMousePress

public void actionMousePress(Component comp,
                             ComponentLocation loc)
Press mouse button 1 at the given location.


actionMousePress

public void actionMousePress(Component comp,
                             ComponentLocation loc,
                             int mask)
Press mouse buttons corresponding to the given mask at the given location.


actionMouseRelease

public void actionMouseRelease()
Release any currently held mouse buttons.


actionDrag

public void actionDrag(Component dragSource,
                       ComponentLocation loc)
Perform a drag action. Derived classes may provide more specific identifiers for what is being dragged simply by deriving a new class from ComponentLocation which identifies the appropriate substructure. For instance, a JTreeLocation might encapsulate the expansion control location for the path [root, node A, child B].


actionDrag

public void actionDrag(Component dragSource)
Perform a drag action. Grabs the center of the given component.


actionDrag

public void actionDrag(Component dragSource,
                       ComponentLocation loc,
                       String buttons)
Deprecated. Use the integer modifier mask version instead.

Perform a drag action with the given modifiers.

Parameters:
dragSource - source of the drag
loc - identifies where on the given Component to begin the drag.
buttons - a String representation of key modifiers, e.g. "ALT|SHIFT", based on the InputEvent _MASK fields.

actionDrag

public void actionDrag(Component dragSource,
                       ComponentLocation loc,
                       int buttons)
Perform a drag action with the given modifiers.

Parameters:
dragSource - source of the drag
loc - identifies where on the given Component to begin the drag.
buttons - one or more of the InputEvent BUTTONN_MASK fields.

actionDrag

public void actionDrag(Component dragSource,
                       int sx,
                       int sy)
Perform a drag action. Grabs at the given explicit location.


actionDrag

public void actionDrag(Component dragSource,
                       int sx,
                       int sy,
                       String buttons)
Deprecated. Use the ComponentLocation/ integer modifier mask version instead.

Perform a drag action. Grabs at the given location with the given modifiers.

Parameters:
dragSource - source of the drag
sx - X coordinate
sy - Y coordinate
buttons - a String representation of key modifiers, e.g. "ALT|SHIFT", based on the InputEvent _MASK fields.

actionDragOver

public void actionDragOver(Component target)
Drag the current dragged object over the given component.


actionDragOver

public void actionDragOver(Component target,
                           ComponentLocation where)
Drag the current dragged object over the given target/location.


actionDrop

public void actionDrop(Component dropTarget)
Perform a basic drop action (implicitly causing preceding mouse drag motion). Drops in the center of the component.


actionDrop

public void actionDrop(Component dropTarget,
                       ComponentLocation loc)
Perform a basic drop action (implicitly causing preceding mouse drag motion).


actionDrop

public void actionDrop(Component dropTarget,
                       int x,
                       int y)
Perform a basic drop action (implicitly causing preceding mouse drag motion). The modifiers represents the set of active modifiers when the drop is made.


assertImage

public boolean assertImage(Component comp,
                           File fileImage,
                           boolean ignoreBorder)
Return whether the component's contents matches the given image.


assertFrameShowing

public boolean assertFrameShowing(Hierarchy h,
                                  String id)
Returns whether a Window corresponding to the given String is showing. The string may be a plain String or regular expression and may match either the window title (for Frames or Dialogs) or the value of Component.getName().


assertFrameShowing

public boolean assertFrameShowing(String id)
Deprecated. This method does not specify the proper context for the lookup. Use assertFrameShowing(Hierarchy,String) instead.

Returns whether a Window corresponding to the given String is showing. The string may be a plain String or regular expression and may match either the window title (for Frames or Dialogs) or the value of Component.getName().


waitForFrameShowing

public void waitForFrameShowing(Hierarchy h,
                                String identifier)
Convenience wait for a window to be displayed. The given string may be a plain String or regular expression and may match either the window title (for Frames and Dialogs) or the value of Component.getName(). This method is provided as a convenience for hand-coded tests, since scripts will use a wait step instead.

The property abbot.robot.component_delay affects the default timeout.


waitForFrameShowing

public void waitForFrameShowing(String identifier)
Deprecated. This method does not provide sufficient context to reliably find a component. Use waitForFrameShowing(Hierarchy,String) instead.

Convenience wait for a window to be displayed. The given string may be a plain String or regular expression and may match either the window title (for Frames and Dialogs) or the value of Component.getName(). This method is provided as a convenience for hand-coded tests, since scripts will use a wait step instead.

The property abbot.robot.component_delay affects the default timeout.


assertComponentShowing

public boolean assertComponentShowing(ComponentReference ref)
Return whether the Component represented by the given ComponentReference is available.


waitForComponentShowing

public void waitForComponentShowing(ComponentReference ref)
Wait for the Component represented by the given ComponentReference to become available. The timeout is affected by abbot.robot.component_delay, which defaults to 30s.


getActions

public Method[] getActions()
Return a list of all actions defined by this class that don't depend on a component argument.


getComponentActions

public Method[] getComponentActions()
Return a list of all actions defined by this class that require a component argument.


getPropertyMethods

public Method[] getPropertyMethods()
Return an array of all property check methods defined by this class. The first argument must be a Component.


getAssertMethods

public Method[] getAssertMethods()
Return a list of all assertions defined by this class that don't depend on a component argument.


getComponentAssertMethods

public Method[] getComponentAssertMethods()
Return a list of all assertions defined by this class that require a component argument.


stripHTML

public static String stripHTML(String str)
Quick and dirty strip raw text from html, for getting the basic text from html-formatted labels and buttons. Behavior is undefined for badly formatted html.


waitAction

protected void waitAction(String desc,
                          Condition cond)
                   throws ActionFailedException
Wait for the given condition, throwing an ActionFailedException if it times out.

Throws:
ActionFailedException

getTestedClass

public Class getTestedClass(Class cls)
Return the Component class that corresponds to this ComponentTester class. For example, JComponentTester.getTestedClass(JLabel.class) would return JComponent.class.


parseLocation

public ComponentLocation parseLocation(String encoded)
Parse the String representation of a ComponentLocation into the actual ComponentLocation object.


getLocation

public ComponentLocation getLocation(Component c,
                                     Point where)
Return a ComponentLocation for the given Point. Derived classes may provide something more suitable than an (x, y) coordinate. A JTree, for example, might provide a JTreeLocation indicating a path or row in the tree.



Copyright © 2002-2008 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge