|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Robot
Understands simulation of user events on a GUI
.
Component
Method Summary | |
---|---|
void |
cleanUp()
Cleans up any used resources (keyboard, mouse, open windows and ) used by this
robot. |
void |
cleanUpWithoutDisposingWindows()
Cleans up any used resources (keyboard, mouse and ) used by this robot. |
void |
click(Component c)
Simulates a user clicking once the given using the left mouse button. |
void |
click(Component c,
MouseButton button)
Simulates a user clicking once the given using the given mouse button. |
void |
click(Component c,
MouseButton button,
int times)
Simulates a user clicking the given mouse button, the given times on the given . |
void |
click(Component c,
Point where)
Simulates a user clicking at the given position on the given . |
void |
click(Component c,
Point where,
MouseButton button,
int times)
Simulates a user clicking the given mouse button, the given times at the given position on the given . |
void |
click(Point where,
MouseButton button,
int times)
Simulates a user clicking the given mouse button, the given times at the given absolute coordinates. |
void |
close(Window w)
Simulates a user closing the given window. |
void |
doubleClick(Component c)
Simulates a user double-clicking the given . |
void |
enterText(String text)
Simulates a user entering the given text. |
JPopupMenu |
findActivePopupMenu()
Returns the currently active pop-up menu, if any. |
ComponentFinder |
finder()
Returns the being used by this robot. |
void |
focus(Component c)
Gives input focus to the given . |
void |
focusAndWaitForFocusGain(Component c)
Gives input focus to the given and waits until the
has focus. |
ComponentHierarchy |
hierarchy()
Returns the being used by this robot. |
boolean |
isActive()
Indicates whether this Robot is active. |
boolean |
isDragging()
Indicates whether the robot is currently in a dragging operation. |
boolean |
isReadyForInput(Component c)
Indicates whether the given is ready for input. |
void |
jitter(Component c)
Makes the mouse pointer show small quick jumpy movements on the given . |
void |
jitter(Component c,
Point where)
Makes the mouse pointer show small quick jumpy movements on the given at the given
point. |
void |
moveMouse(Component c)
Simulates a user moving the mouse pointer to the center of the given . |
void |
moveMouse(Component c,
int x,
int y)
Simulates a user moving the mouse pointer to the given coordinates relative to the given . |
void |
moveMouse(Component c,
Point p)
Simulates a user moving the mouse pointer to the given coordinates relative to the given . |
void |
moveMouse(int x,
int y)
Simulates a user moving the mouse pointer to the given coordinates. |
void |
moveMouse(Point p)
Simulates a user moving the mouse pointer to the given coordinates. |
void |
pressAndReleaseKey(int keyCode,
int... modifiers)
Type the given key code with the given modifiers. |
void |
pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys. |
void |
pressKey(int keyCode)
Simulates a user pressing given key. |
void |
pressModifiers(int modifierMask)
Presses the appropriate modifiers corresponding to the given mask. |
void |
pressMouse(Component c,
Point where)
Simulates a user pressing the left mouse button on the given . |
void |
pressMouse(Component c,
Point where,
MouseButton button)
Simulates a user pressing the given mouse button on the given . |
void |
pressMouse(MouseButton button)
Simulates a user pressing a mouse button. |
void |
pressMouse(Point where,
MouseButton button)
Simulates a user pressing the given mouse button on the given coordinates. |
ComponentPrinter |
printer()
Returns the being used by this robot. |
void |
releaseKey(int keyCode)
Simulates a user releasing the given key. |
void |
releaseModifiers(int modifierMask)
Releases the appropriate modifiers corresponding to the given mask. |
void |
releaseMouse(MouseButton button)
Releases the given mouse button. |
void |
releaseMouseButtons()
Releases any mouse button(s) used by the robot. |
void |
requireNoJOptionPaneIsShowing()
Ensures that there is no showing, and potentially blocking GUI tests. |
void |
rightClick(Component c)
Simulates a user right-clicking the given . |
void |
rotateMouseWheel(Component c,
int amount)
Moves the mouse pointer over to the given and rotates the scroll wheel on
wheel-equipped mice. |
void |
rotateMouseWheel(int amount)
Rotates the scroll wheel on wheel-equipped mice. |
Settings |
settings()
Returns the configuration settings for this . |
JPopupMenu |
showPopupMenu(Component invoker)
Shows a pop-up menu. |
JPopupMenu |
showPopupMenu(Component invoker,
Point location)
Shows a pop-up menu at the given coordinates. |
void |
showWindow(Window w)
Safely display a window with proper EDT synchronization. |
void |
showWindow(Window w,
Dimension size)
Safely display a window with proper EDT synchronization. |
void |
showWindow(Window w,
Dimension size,
boolean pack)
Safely display a window with proper EDT synchronization. |
void |
type(char character)
Types the given character. |
void |
waitForIdle()
Wait for an idle AWT event queue. |
Method Detail |
---|
ComponentHierarchy hierarchy()
ComponentHierarchy
being used by this robot.
ComponentHierarchy
being used by this robot.ComponentFinder finder()
ComponentFinder
being used by this robot.
ComponentFinder
being used by this robot.ComponentPrinter printer()
BasicComponentPrinter
being used by this robot.
ComponentPrinter
being used by this robot.void showWindow(Window w)
Window
is showing and ready for input.
w
- the window to display.void showWindow(Window w, Dimension size)
Window
is showing and ready for input.
w
- the window to display.size
- the size of the window to display.void showWindow(Window w, Dimension size, boolean pack)
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
.
w
- the window to display.size
- the size of the window to display.pack
- flag that indicates if the window should be packed or not. By packed we mean calling
w.pack()
.void close(Window w)
w
- the window to close.void focus(Component c)
Component
. Note that the component may not yet have focus when
this method returns.
c
- the component to give focus to.void focusAndWaitForFocusGain(Component c)
Component
and waits until the Component
has focus.
c
- the component to give focus to.void cleanUp()
ScreenLock
) used by this
robot.
void cleanUpWithoutDisposingWindows()
ScreenLock
) used by this robot. This method
does not dispose any open windows.
Note: The preferred method to use to clean up resources is
. Using
cleanUp()
may leave many windows open after each test. Use it on very
special cases. Please read bug 138
for more details.
cleanUpWithoutDisposingWindows()
void click(Component c)
Component
using the left mouse button.
c
- the Component
to click on.
ActionFailedException
- if the component to click is out of the boundaries of the screen.void rightClick(Component c)
Component
.
c
- the Component
to click on.
ActionFailedException
- if the component to click is out of the boundaries of the screen.void click(Component c, MouseButton button)
Component
using the given mouse button.
c
- the Component
to click on.button
- the mouse button to use.
ActionFailedException
- if the component to click is out of the boundaries of the screen.void doubleClick(Component c)
Component
.
c
- the Component
to click on.
ActionFailedException
- if the component to click is out of the boundaries of the screen.void click(Component c, MouseButton button, int times)
Component
.
c
- the Component
to click on.button
- the mouse button to click.times
- the number of times to click the given mouse button.
ActionFailedException
- if the component to click is out of the boundaries of the screen.void click(Component c, Point where)
Component
.
c
- the Component
to click on.where
- the given coordinates, relative to the given Component
.
ActionFailedException
- if the component to click is out of the boundaries of the screen.void click(Component c, Point where, MouseButton button, int times)
Component
.
c
- the Component
to click on.where
- the given coordinates, relative to the given Component
.button
- the mouse button to click.times
- the number of times to click the given mouse button.
ActionFailedException
- if the component to click is out of the boundaries of the screen.void click(Point where, MouseButton button, int times)
where
- the coordinates where to click.button
- the mouse button to click.times
- the number of times to click the given mouse button.void pressMouse(MouseButton button)
button
- the mouse button to press.void pressMouse(Component c, Point where)
Component
.
c
- the Component
to click on.where
- the given coordinates, relative to the given Component
.void pressMouse(Component c, Point where, MouseButton button)
Component
.
c
- the Component
to click on.where
- the given coordinates, relative to the given Component
.button
- the mouse button to press.void pressMouse(Point where, MouseButton button)
where
- the position where to press the given mouse button.button
- the mouse button to press.void moveMouse(Component c)
Component
.
c
- the given Component
.void moveMouse(Component c, Point p)
Component
.
c
- the given Component
.p
- the given coordinates, relative to the given Component
.
ActionFailedException
- if the given component is not showing and ready for input.void moveMouse(Component c, int x, int y)
Component
.
c
- the given Component
.x
- X coordinate, relative to the given Component
.y
- Y coordinate, relative to the given Component
.
ActionFailedException
- if the given component is not showing and ready for input.void moveMouse(Point p)
p
- the given coordinates.void moveMouse(int x, int y)
x
- X coordinate.y
- Y coordinate.void releaseMouse(MouseButton button)
button
- the mouse button to release.void releaseMouseButtons()
void rotateMouseWheel(Component c, int amount)
Component
and rotates the scroll wheel on
wheel-equipped mice.
c
- the given Component
.amount
- number of "notches" to move the mouse wheel. Negative values indicate movement up/away from the user,
while positive values indicate movement down/towards the user.void rotateMouseWheel(int amount)
amount
- number of "notches" to move the mouse wheel. Negative values indicate movement up/away from the user,
while positive values indicate movement down/towards the user.void jitter(Component c)
Component
.
c
- the given Component
.void jitter(Component c, Point where)
Component
at the given
point.
c
- the given Component
.where
- the given point.void enterText(String text)
text
- the text to enter.void type(char character)
character
- the character to type.void pressAndReleaseKey(int keyCode, int... modifiers)
InputEvent
masks.
keyCode
- the code of the key to press.modifiers
- the given modifiers.
IllegalArgumentException
- if the given code is not a valid key code.void pressAndReleaseKeys(int... keyCodes)
keyCodes
- one or more codes of the keys to press.
IllegalArgumentException
- if any of the given codes is not a valid key code.KeyEvent
void pressKey(int keyCode)
keyCode
- the code of the key to press.
IllegalArgumentException
- if the given code is not a valid key code.KeyEvent
void releaseKey(int keyCode)
keyCode
- the code of the key to release.
IllegalArgumentException
- if the given code is not a valid key code.KeyEvent
void pressModifiers(int modifierMask)
InputEvent
.
modifierMask
- the given mask.InputEvent
void releaseModifiers(int modifierMask)
InputEvent
.
modifierMask
- the given mask.InputEvent
void waitForIdle()
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.
IllegalThreadStateException
- if this method is called from the event dispatch thread.boolean isDragging()
true
if the robot is currently in a dragging operation, false
otherwise.boolean isReadyForInput(Component c)
Component
is ready for input.
c
- the given Component
.
true
if the given Component
is ready for input, false
otherwise.
ActionFailedException
- if the given Component
does not have a Window
ancestor.JPopupMenu showPopupMenu(Component invoker)
invoker
- the component to invoke the pop-up menu from.
ComponentLookupException
- if a pop-up menu cannot be found.JPopupMenu showPopupMenu(Component invoker, Point location)
invoker
- the component to invoke the pop-up menu from.location
- the given coordinates for the pop-up menu.
ComponentLookupException
- if a pop-up menu cannot be found.JPopupMenu findActivePopupMenu()
null
.
null
, if no pop-up is currently showing.void requireNoJOptionPaneIsShowing()
JOptionPane
showing, and potentially blocking GUI tests.
AssertionError
- if there is one or more JOptionPane
s showing on the screen.Settings settings()
Robot
.
Robot
.boolean isActive()
Robot
is active. Being "active" means that cleanUp()
has
not been called yet.
true
if this Robot
is active, false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |