abbot.tester
Class Robot

java.lang.Object
  extended by abbot.tester.Robot
All Implemented Interfaces:
AWTConstants
Direct Known Subclasses:
ComponentTester

public class Robot
extends Object
implements AWTConstants

Provide a higher level of abstraction for user input (A Better Robot). The Robot's operation may be affected by the following properties:

abbot.robot.auto_delay

Set this to a value representing the millisecond count in between generated events. Usually just set to 100-200 if you want to slow down the playback to simulate actual user input. The default is zero delay.
abbot.robot.mode

Set this to either "robot" or "awt" to designate the desired mode of event generation. "robot" uses java.awt.Robot to generate events, while "awt" stuffs events directly into the AWT event queue.
abbot.robot.event_post_delay

This is the maximum number of ms it takes the system to post an AWT event in response to a Robot-generated event.
abbot.robot.default_delay

Base delay setting, acts as default value for the next two.
abbot.robot.popup_delay

Set this to the maximum time to wait for a menu to appear or be generated.
abbot.robot.component_delay

Set this to the maximum time to wait for a Component to become available.

The Robot class provides a generic solution for dealing with asynchronous updates to the UI with the wait(Condition,long, int) method. This allows the testing thread to pause until a given component of data value in a component is ready.

NOTE: Only use event queue synchronization (e.g. invokeAndWait(Runnable) or waitForIdle() when a subsequent robot-level action is being applied to the results of a prior action (e.g. focus, deiconify, menu selection). Otherwise, don't introduce a mandatory delay (e.g. use invokeLater(Runnable)).

NOTE: If a robot action isn't reproduced properly, you may need to introduce either additional events or extra delay. Adding enforced delay for a given platform is usually preferable to generating additional events, so always try that first, but be sure to restrict it to the platform in question.

NOTE: Robot actions should never be invoked on the event dispatch thread.


Field Summary
static int componentDelay
          Delay before failing to find a component that should be visible.
static int defaultDelay
          Base delay setting.
static int EM_AWT
          Post events to the AWT event queue.
static int EM_ROBOT
          Use java.awt.Robot to generate events.
protected static long IDLE_TIMEOUT
           
static String MOUSELESS_MODIFIER
           
static int MOUSELESS_MODIFIER_MASK
           
protected static int popupDelay
          Delay before failing to find a popup menu that should appear.
 
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
Robot()
          Default constructor.
 
Method Summary
 void activate(Window win)
          Activate the given window.
static boolean canMoveWindows()
          Returns whether it is possible to move windows that are not an instance of Frame or Dialog.
static boolean canResizeWindows()
          Returns whether it is possible to resize windows that are not an instance of Frame or Dialog.
 BufferedImage capture(Component comp)
          Capture the contents of the given component, sans any border or insets.
 BufferedImage capture(Component comp, boolean ignoreBorder)
          Capture the contents of the given component, optionally including the border and/or insets.
 BufferedImage capture(Rectangle bounds)
          Capture the contents of the given rectangle.
 void click(Component comp)
          Click in the center of the given component.
 void click(Component comp, int mask)
          Click in the center of the given component, specifying which button.
 void click(Component comp, int x, int y)
          Click in the component at the given location.
 void click(Component comp, int x, int y, int mask)
          Click in the component at the given location with the given button.
 void click(Component comp, int x, int y, int mask, int count)
          Click in the given part of the component.
 void close(Window w)
          Invoke the window close operation.
 void deiconify(Frame frame)
           
 void delay(int ms)
          Sleep the given duration of ms.
protected static String descriptiveClassName(Class cls)
           
 void drag(Component src, int sx, int sy)
          Begin a drag operation using button 1.
 void drag(Component src, int sx, int sy, int buttons)
          Begin a drag operation using the given button mask.
 void dragOver(Component dst, int x, int y)
          Move the mouse appropriately to get from the source to the destination.
 void drop(Component target, int x, int y)
          End a drag operation, releasing the mouse button over the given target location.
 Component findFocusOwner()
          Return the Component which currently owns the focus.
protected  void fireAccessibleAction(Component context, AccessibleAction action, String name)
           
 void focus(Component comp)
          Move keyboard focus to the given component.
 void focus(Component comp, boolean wait)
          Move keyboard focus to the given component.
static int getAutoDelay()
           
static String getBorderTitle(Component c)
           
static Class getCanonicalClass(Class refClass)
           
protected  Point getCloseLocation(Container c)
           
static String getDescriptiveName(Component c)
          Return a descriptive name for the given component for use in UI text (may be localized if appropriate and need not be re-usable across locales.
static String getEventID(AWTEvent event)
          Return the symbolic name of the given event's ID.
static int getEventID(Class cls, String id)
          Return the numeric event ID corresponding to the given string.
static int getEventMode()
          Returns the current event-generation mode.
static String getEventModeDescription()
           
static int getEventPostDelay()
           
protected  EventQueue getEventQueue(Component c)
          Usually only needed when dealing with Applets.
protected  Point getIconifyLocation(Container c)
          Identify the coordinates of the iconify button where we can, returning (0, 0) if we can't.
static String getIconName(Component c)
           
static int getIndex(Container parent, Component comp)
          Returns the index of the given component within the given container.
static String getLabel(Component c)
           
protected  Point getMaximizeLocation(Container c)
          Identify the coordinates of the maximize button where possible, returning null if not.
protected  Point getMoveLocation(Container c)
          Return where the mouse usually grabs to move a window.
static String getName(Component c)
           
static int getPreferredRobotAutoDelay()
          Returns the appropriate auto delay for robot-generated events.
protected  Point getResizeLocation(Container c)
          Return where the mouse usually grabs to resize a window.
static Robot getRobot()
          Returns a functioning instance of java.awt.Robot.
static InputState getState()
          Return a singleton InputState object.
static String getText(Component c)
           
static String getTitle(Component c)
           
 void iconify(Frame frame)
          Iconify the given Frame.
 void invokeAction(Component c, Runnable action)
          Deprecated. Method renamed to invokeLater(Component, Runnable)
 void invokeAction(Runnable action)
          Deprecated. Method renamed to invokeLater(Runnable)
 void invokeAndWait(Component c, Runnable action)
          Post a runnable on the given component's event queue and wait for it to finish.
 void invokeAndWait(Runnable action)
          Run the given action on the event dispatch thread, but don't return until it's been run.
 void invokeLater(Component context, Runnable action)
          Post a runnable on the given component's event queue.
 void invokeLater(Runnable action)
          Run the given action on the event dispatch thread.
protected  boolean isReadyForInput(Component c)
          Is the given component ready for robot input?
protected  void jitter(Component comp, int x, int y)
           
protected  void jitter(int x, int y)
           
 void key(int keycode)
          Type the given keycode with no modifiers.
 void key(int keycode, int modifiers)
          Type the given keycode with the given modifiers.
 void keyPress(int keycode)
           
 void keyRelease(int keycode)
          Send a key release event.
 void keyString(String str)
          Type the given string.
 void keyStroke(char ch)
          Type the given character.
 void maximize(Frame frame)
          Make the window full size.
 void mouseMove(Component comp)
          Move the pointer to the center of the given component.
 void mouseMove(Component comp, int x, int y)
          Move the pointer to the given coordinates relative to the given component.
 void mousePress(Component comp)
           
 void mousePress(Component comp, int mask)
           
 void mousePress(Component comp, int x, int y)
           
 void mousePress(Component comp, int x, int y, int mask)
          Mouse down in the given part of the component.
 void mousePress(int buttons)
          Send a button press event.
 void mouseRelease()
          Send a button release event for button 1.
 void mouseRelease(int buttons)
          Send a button release event.
 void move(Container comp, int newx, int newy)
          Move the given Frame/Dialog to the requested location.
 void moveBy(Container comp, int dx, int dy)
          Move the given Window by the given amount.
 void normalize(Frame frame)
           
protected  void postEvent(Component comp, AWTEvent ev)
          Post the given event to the corresponding event queue for the given component.
protected  boolean postInvocationEvent(EventQueue eq, Toolkit toolkit, long timeout)
           
protected  boolean queueBlocked()
          Check for a blocked event queue (symptomatic of an active w32 AWT popup menu).
 void reset()
           
 void resize(Container comp, int width, int height)
          Resize the given Frame/Dialog to the given size.
 void resizeBy(Container comp, int dx, int dy)
          Resize the given Frame/Dialog by the given amounts.
 Color sample(Component c, ComponentLocation loc)
          Sample the color at the given location on the component.
 Color sample(Component c, int x, int y)
          Sample the color at the given point on the component.
 Color sample(int x, int y)
          Sample the color at the given point on the screen.
 void selectAWTMenuItem(Frame frame, String path)
          Select the given menu item from the given Frame.
 void selectAWTMenuItem(MenuComponent item)
          Select an AWT menu item.
 void selectAWTMenuItemByLabel(Frame frame, String path)
          Deprecated. Renamed to selectAWTMenuItem(Frame,String).
 void selectAWTPopupMenuItem(Component invoker, String path)
          Select the given menu item from a PopupMenu on the given Component.
 void selectAWTPopupMenuItem(MenuComponent item)
          Select an AWT popup menu item.
 void selectAWTPopupMenuItemByLabel(Component invoker, String path)
          Deprecated. Renamed to selectAWTPopupMenuItem(Component,String).
 void selectMenuItem(Component item)
          Find and select the given menu item.
 void selectMenuItem(Component sameWindow, String path)
          Find and select the given menu item, by path.
 void selectPopupMenuItem(Component invoker, ComponentLocation loc, String path)
           
 void sendEvent(AWTEvent event)
          Send the given event as appropriate to the event-generation mode.
static void setAutoDelay(int ms)
          Allow this to be adjusted, mostly for testing.
static void setEventMode(int mode)
          Set the event-generation mode.
static void setEventPostDelay(int delay)
           
 void setModifiers(int modifiers, boolean press)
          Press or release the appropriate modifiers corresponding to the given mask.
 Component showPopupMenu(Component invoker)
          Attempt to display a popup menu at center of the component.
 Component showPopupMenu(Component invoker, int x, int y)
          Attempt to display a popup menu at the given coordinates.
static String simpleClassName(Class cls)
          Strip the package from the class name.
 void sleep()
          Sleep for a little bit, measured in UI time.
static String toHierarchyPath(Component c)
          Provides the hierarchic path of the given component by component class, e.g.
static String toString(AWTEvent event)
          Provide a more concise representation of the event than the default AWTEvent.toString().
static String toString(Component comp)
          Provides a more concise representation of the component than the default Component.toString().
static String toString(Object obj)
          Provide a string representation of the given component (Component or MenuComponent.
protected  boolean userMovable(Component comp)
          Return whether it is possible for the user to move the given component.
protected  boolean userResizable(Component comp)
          Return whether it is possible for the user to resize the given component.
protected static boolean useScreenMenuBar()
          OS X using screenMenuBar actually uses an AWT menu as the live component.
 void wait(Condition condition)
          Wait for the given Condition to return true.
 void wait(Condition condition, long timeout)
          Wait for the given Condition to return true, waiting for timeout ms.
 void wait(Condition condition, long timeout, int interval)
          Wait for the given Condition to return true, waiting for timeout ms, polling at the given interval.
 void waitForIdle()
          Wait for an idle AWT event queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EM_ROBOT

public static int EM_ROBOT
Use java.awt.Robot to generate events.


EM_AWT

public static int EM_AWT
Post events to the AWT event queue.


MOUSELESS_MODIFIER_MASK

public static final int MOUSELESS_MODIFIER_MASK
See Also:
Constant Field Values

MOUSELESS_MODIFIER

public static final String MOUSELESS_MODIFIER

defaultDelay

public static int defaultDelay
Base delay setting.


IDLE_TIMEOUT

protected static long IDLE_TIMEOUT

popupDelay

protected static int popupDelay
Delay before failing to find a popup menu that should appear.


componentDelay

public static int componentDelay
Delay before failing to find a component that should be visible.

Constructor Detail

Robot

public Robot()
Default constructor.

Method Detail

useScreenMenuBar

protected static final boolean useScreenMenuBar()
OS X using screenMenuBar actually uses an AWT menu as the live component. The JXXX components exist, but are not effectively active.


getAutoDelay

public static int getAutoDelay()

getRobot

public static Robot getRobot()
Returns a functioning instance of java.awt.Robot. If this method returns null, it should be assumed that java.awt.Robot is unavailable or non-functional on the current system.


getState

public static InputState getState()
Return a singleton InputState object.


getEventMode

public static int getEventMode()
Returns the current event-generation mode.


getEventModeDescription

public static String getEventModeDescription()

setEventMode

public static void setEventMode(int mode)
Set the event-generation mode.

Throws:
IllegalStateException - if the requested mode is EM_ROBOT and java.awt.Robot is unavailable in the current environment.

getEventPostDelay

public static int getEventPostDelay()

setEventPostDelay

public static void setEventPostDelay(int delay)

setAutoDelay

public static void setAutoDelay(int ms)
Allow this to be adjusted, mostly for testing.


mousePress

public void mousePress(int buttons)
Send a button press event.


mouseRelease

public void mouseRelease()
Send a button release event for button 1.


mouseRelease

public void mouseRelease(int buttons)
Send a button release event.


focus

public void focus(Component comp)
Move keyboard focus to the given component. Note that the component may not yet have focus when this method returns.


focus

public void focus(Component comp,
                  boolean wait)
Move keyboard focus to the given component.


getEventQueue

protected EventQueue getEventQueue(Component c)
Usually only needed when dealing with Applets.


invokeLater

public void invokeLater(Component context,
                        Runnable action)
Post a runnable on the given component's event queue. Useful when driving multiple Applets, but is also useful to ensure an operation happens on the event dispatch thread.


invokeAndWait

public void invokeAndWait(Component c,
                          Runnable action)
Post a runnable on the given component's event queue and wait for it to finish.


invokeAction

public void invokeAction(Runnable action)
Deprecated. Method renamed to invokeLater(Runnable)

Parameters:
action -

invokeAction

public void invokeAction(Component c,
                         Runnable action)
Deprecated. Method renamed to invokeLater(Component, Runnable)

Parameters:
c -
action -

invokeLater

public void invokeLater(Runnable action)
Run the given action on the event dispatch thread. This should be used for any non-read-only methods invoked directly on a GUI component. NOTE: if you want to use the results of the action, use invokeAndWait instead.


invokeAndWait

public void invokeAndWait(Runnable action)
Run the given action on the event dispatch thread, but don't return until it's been run.


keyPress

public void keyPress(int keycode)

keyRelease

public void keyRelease(int keycode)
Send a key release event.


sleep

public void sleep()
Sleep for a little bit, measured in UI time.


delay

public void delay(int ms)
Sleep the given duration of ms.


queueBlocked

protected boolean queueBlocked()
Check for a blocked event queue (symptomatic of an active w32 AWT popup menu).

Returns:
whether the event queue is blocked.

postInvocationEvent

protected boolean postInvocationEvent(EventQueue eq,
                                      Toolkit toolkit,
                                      long timeout)
Returns:
whether we timed out waiting for the invocation to run

waitForIdle

public void waitForIdle()
Wait for an idle AWT event queue. Note that this is different from the implementation of java.awt.Robot.waitForIdle(), which may have events on the queue when it returns. Do NOT use this method if there are animations or other continual refreshes happening, since in that case it may never return.


sample

public Color sample(int x,
                    int y)
Sample the color at the given point on the screen.


sample

public Color sample(Component c,
                    int x,
                    int y)
Sample the color at the given point on the component.


sample

public Color sample(Component c,
                    ComponentLocation loc)
Sample the color at the given location on the component.


capture

public BufferedImage capture(Rectangle bounds)
Capture the contents of the given rectangle.


capture

public BufferedImage capture(Component comp)
Capture the contents of the given component, sans any border or insets. This should only be used on components that do not use a LAF UI, or the results will not be consistent across platforms.


capture

public BufferedImage capture(Component comp,
                             boolean ignoreBorder)
Capture the contents of the given component, optionally including the border and/or insets. This should only be used on components that do not use a LAF UI, or the results will not be consistent across platforms.


jitter

protected void jitter(Component comp,
                      int x,
                      int y)

jitter

protected void jitter(int x,
                      int y)

mouseMove

public void mouseMove(Component comp)
Move the pointer to the center of the given component.


mouseMove

public void mouseMove(Component comp,
                      int x,
                      int y)
Move the pointer to the given coordinates relative to the given component.


dragOver

public void dragOver(Component dst,
                     int x,
                     int y)
Move the mouse appropriately to get from the source to the destination. Enter/exit events will be generated where appropriate.


drag

public void drag(Component src,
                 int sx,
                 int sy)
Begin a drag operation using button 1.

This method is tuned for native drag/drop operations, so if you get odd behavior, you might try using a simple mousePress(Component,int,int) instead.


drag

public void drag(Component src,
                 int sx,
                 int sy,
                 int buttons)
Begin a drag operation using the given button mask.

This method is tuned for native drag/drop operations, so if you get odd behavior, you might try using a simple mousePress(Component,int,int,int) instead.


drop

public void drop(Component target,
                 int x,
                 int y)
End a drag operation, releasing the mouse button over the given target location.

This method is tuned for native drag/drop operations, so if you get odd behavior, you might try using a simple mouseMove(Component,int,int), mouseRelease() instead.


key

public void key(int keycode)
Type the given keycode with no modifiers.


setModifiers

public void setModifiers(int modifiers,
                         boolean press)
Press or release the appropriate modifiers corresponding to the given mask.


key

public void key(int keycode,
                int modifiers)
Type the given keycode with the given modifiers. Modifiers is a mask from the available InputEvent masks.


keyStroke

public void keyStroke(char ch)
Type the given character. Note that this sends the key to whatever component currently has the focus.


keyString

public void keyString(String str)
Type the given string.


mousePress

public void mousePress(Component comp)

mousePress

public void mousePress(Component comp,
                       int mask)

mousePress

public void mousePress(Component comp,
                       int x,
                       int y)

mousePress

public void mousePress(Component comp,
                       int x,
                       int y,
                       int mask)
Mouse down in the given part of the component. All other mousePress methods must eventually invoke this one.


click

public final void click(Component comp)
Click in the center of the given component.


click

public final void click(Component comp,
                        int mask)
Click in the center of the given component, specifying which button.


click

public final void click(Component comp,
                        int x,
                        int y)
Click in the component at the given location.


click

public final void click(Component comp,
                        int x,
                        int y,
                        int mask)
Click in the component at the given location with the given button.


click

public void click(Component comp,
                  int x,
                  int y,
                  int mask,
                  int count)
Click in the given part of the component. All other click methods must eventually invoke this one. This method sometimes needs to be redefined (i.e. JComponent to scroll before clicking).


selectAWTMenuItemByLabel

public void selectAWTMenuItemByLabel(Frame frame,
                                     String path)
Deprecated. Renamed to selectAWTMenuItem(Frame,String).


selectAWTMenuItem

public void selectAWTMenuItem(Frame frame,
                              String path)
Select the given menu item from the given Frame. The given String may be either a label or path of labels, but must uniquely identify the menu item. For example, "Copy" would be valid if there is only one instance of that menu label under the MenuBar, otherwise you would need to specify "Edit|Copy" to ensure the proper selection. Note that this method doesn't require referencing the MenuComponent directly as a parameter.


selectAWTPopupMenuItemByLabel

public void selectAWTPopupMenuItemByLabel(Component invoker,
                                          String path)
Deprecated. Renamed to selectAWTPopupMenuItem(Component,String).


selectAWTPopupMenuItem

public void selectAWTPopupMenuItem(Component invoker,
                                   String path)
Select the given menu item from a PopupMenu on the given Component. The given String may be either a label or path of labels, but must uniquely identify the menu item. For example, "Copy" would be valid if there is only one instance of that menu label under the MenuBar, otherwise you would need to specify "Edit|Copy" to ensure the proper selection. If there are more than one PopupMenu registerd on the invoking component, you will need to prefix the PopupMenu name as well, e.g. "popup0|Edit|Copy".


fireAccessibleAction

protected void fireAccessibleAction(Component context,
                                    AccessibleAction action,
                                    String name)

selectAWTMenuItem

public void selectAWTMenuItem(MenuComponent item)
Select an AWT menu item.


selectAWTPopupMenuItem

public void selectAWTPopupMenuItem(MenuComponent item)
Select an AWT popup menu item.


isReadyForInput

protected boolean isReadyForInput(Component c)
Is the given component ready for robot input?


selectMenuItem

public void selectMenuItem(Component sameWindow,
                           String path)
Find and select the given menu item, by path.


selectMenuItem

public void selectMenuItem(Component item)
Find and select the given menu item.


selectPopupMenuItem

public void selectPopupMenuItem(Component invoker,
                                ComponentLocation loc,
                                String path)

showPopupMenu

public Component showPopupMenu(Component invoker)
Attempt to display a popup menu at center of the component.


showPopupMenu

public Component showPopupMenu(Component invoker,
                               int x,
                               int y)
Attempt to display a popup menu at the given coordinates.


activate

public void activate(Window win)
Activate the given window.


getCloseLocation

protected Point getCloseLocation(Container c)

close

public void close(Window w)
Invoke the window close operation.


getMoveLocation

protected Point getMoveLocation(Container c)
Return where the mouse usually grabs to move a window. Center of the top of the frame is usually a good choice.


move

public void move(Container comp,
                 int newx,
                 int newy)
Move the given Frame/Dialog to the requested location.


moveBy

public void moveBy(Container comp,
                   int dx,
                   int dy)
Move the given Window by the given amount.


getResizeLocation

protected Point getResizeLocation(Container c)
Return where the mouse usually grabs to resize a window. The lower right corner of the window is usually a good choice.


userMovable

protected boolean userMovable(Component comp)
Return whether it is possible for the user to move the given component.


userResizable

protected boolean userResizable(Component comp)
Return whether it is possible for the user to resize the given component.


resize

public void resize(Container comp,
                   int width,
                   int height)
Resize the given Frame/Dialog to the given size.


resizeBy

public void resizeBy(Container comp,
                     int dx,
                     int dy)
Resize the given Frame/Dialog by the given amounts.


getIconifyLocation

protected Point getIconifyLocation(Container c)
Identify the coordinates of the iconify button where we can, returning (0, 0) if we can't.


getMaximizeLocation

protected Point getMaximizeLocation(Container c)
Identify the coordinates of the maximize button where possible, returning null if not.


iconify

public void iconify(Frame frame)
Iconify the given Frame. Don't support iconification of Dialogs at this point (although maybe should).


deiconify

public void deiconify(Frame frame)

normalize

public void normalize(Frame frame)

maximize

public void maximize(Frame frame)
Make the window full size. On 1.3.1, this is not reversible.


sendEvent

public void sendEvent(AWTEvent event)
Send the given event as appropriate to the event-generation mode.


getEventID

public static String getEventID(AWTEvent event)
Return the symbolic name of the given event's ID.


getCanonicalClass

public static Class getCanonicalClass(Class refClass)

toString

public static String toString(Component comp)
Provides a more concise representation of the component than the default Component.toString().


toString

public static String toString(Object obj)
Provide a string representation of the given component (Component or MenuComponent.


descriptiveClassName

protected static String descriptiveClassName(Class cls)

toHierarchyPath

public static String toHierarchyPath(Component c)
Provides the hierarchic path of the given component by component class, e.g. "JFrame:JRootPane:JPanel:JButton".


toString

public static String toString(AWTEvent event)
Provide a more concise representation of the event than the default AWTEvent.toString().


getEventID

public static int getEventID(Class cls,
                             String id)
Return the numeric event ID corresponding to the given string.


simpleClassName

public static String simpleClassName(Class cls)
Strip the package from the class name.


postEvent

protected void postEvent(Component comp,
                         AWTEvent ev)
Post the given event to the corresponding event queue for the given component.


wait

public void wait(Condition condition)
Wait for the given Condition to return true. The default timeout may be changed by setting abbot.robot.default_delay.

Throws:
WaitTimedOutError - if the default timeout (30s) is exceeded.
See Also:
Robot.wait For a description of the use of this function to support lazy loading in class files

wait

public void wait(Condition condition,
                 long timeout)
Wait for the given Condition to return true, waiting for timeout ms.

Throws:
WaitTimedOutError - if the timeout is exceeded.
See Also:
Robot.wait For a description of the use of this function to support lazy loading in class files

wait

public void wait(Condition condition,
                 long timeout,
                 int interval)
Wait for the given Condition to return true, waiting for timeout ms, polling at the given interval. This method can be used generically to support components that are lazily loaded in the context of writing testers or other testing code.

Take for example the simple case of trying to select an item in a list. If the model for this list is populate asynchronously then you may need to poll the list for a given amount of time until the item appears. This is very common in an application that contains many long running tasks.

A general solution to the problem can be seen in this pseudo code:

   wait(new Condition()
        {
           public boolean test()
           {
             return whether the ui element is avaliable
           }
        });
   performAction(ui element);
 

If you are writing a tester method then it is a good idea to use a standard timeout such as componentDelay to ensure they are consistently handled accross different testers.

Throws:
WaitTimedOutError - if the timeout is exceeded.

reset

public void reset()

findFocusOwner

public Component findFocusOwner()
Return the Component which currently owns the focus.


getDescriptiveName

public static String getDescriptiveName(Component c)
Return a descriptive name for the given component for use in UI text (may be localized if appropriate and need not be re-usable across locales.


getName

public static String getName(Component c)

getIndex

public static int getIndex(Container parent,
                           Component comp)
Returns the index of the given component within the given container.


getText

public static String getText(Component c)

getLabel

public static String getLabel(Component c)

getIconName

public static String getIconName(Component c)

getBorderTitle

public static String getBorderTitle(Component c)

getTitle

public static String getTitle(Component c)

canResizeWindows

public static boolean canResizeWindows()
Returns whether it is possible to resize windows that are not an instance of Frame or Dialog. Most X11 window managers will allow this, but stock Macintosh and Windows do not.


canMoveWindows

public static boolean canMoveWindows()
Returns whether it is possible to move windows that are not an instance of Frame or Dialog. Most X11 window managers will allow this, but stock Macintosh and Windows do not.


getPreferredRobotAutoDelay

public static int getPreferredRobotAutoDelay()
Returns the appropriate auto delay for robot-generated events.



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

SourceForge