|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fest.swing.core.BasicRobot
public class BasicRobot
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 . |
static Robot |
robotWithCurrentAwtHierarchy()
Creates a new that has access to all the GUI components in the AWT hierarchy. |
static Robot |
robotWithNewAwtHierarchy()
Creates a new with a new AWT hierarchy. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Robot robotWithNewAwtHierarchy()
Robot
with a new AWT hierarchy. The created Robot
will not be able
to access any components that were created before it.
Robot
.public static Robot robotWithCurrentAwtHierarchy()
Robot
that has access to all the GUI components in the AWT hierarchy.
Robot
.public ComponentPrinter printer()
BasicComponentPrinter
being used by this robot.
printer
in interface Robot
ComponentPrinter
being used by this robot.public ComponentFinder finder()
ComponentFinder
being used by this robot.
finder
in interface Robot
ComponentFinder
being used by this robot.@RunsInEDT public void showWindow(Window w)
Window
is showing and ready for input.
showWindow
in interface Robot
w
- the window to display.@RunsInEDT public void showWindow(Window w, Dimension size)
Window
is showing and ready for input.
showWindow
in interface Robot
w
- the window to display.size
- the size of the window to display.@RunsInEDT public 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
.
showWindow
in interface Robot
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()
.@RunsInEDT public void close(Window w)
close
in interface Robot
w
- the window to close.@RunsInEDT public void focusAndWaitForFocusGain(Component c)
Component
and waits until the Component
has focus.
focusAndWaitForFocusGain
in interface Robot
c
- the component to give focus to.@RunsInEDT public void focus(Component c)
Component
. Note that the component may not yet have focus when
this method returns.
focus
in interface Robot
c
- the component to give focus to.@RunsInEDT public void cleanUp()
ScreenLock
) used by this
robot.
cleanUp
in interface Robot
@RunsInEDT public 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
Robot.cleanUp()
may leave many windows open after each test. Use it on very
special cases. Please read bug 138
for more details.
Robot.cleanUpWithoutDisposingWindows()
cleanUpWithoutDisposingWindows
in interface Robot
@RunsInEDT public void click(Component c)
Component
using the left mouse button.
click
in interface Robot
c
- the Component
to click on.@RunsInEDT public void rightClick(Component c)
Component
.
rightClick
in interface Robot
c
- the Component
to click on.@RunsInEDT public void click(Component c, MouseButton button)
Component
using the given mouse button.
click
in interface Robot
c
- the Component
to click on.button
- the mouse button to use.@RunsInEDT public void doubleClick(Component c)
Component
.
doubleClick
in interface Robot
c
- the Component
to click on.@RunsInEDT public void click(Component c, MouseButton button, int times)
Component
.
click
in interface Robot
c
- the Component
to click on.button
- the mouse button to click.times
- the number of times to click the given mouse button.@RunsInEDT public void click(Component c, Point where)
Component
.
click
in interface Robot
c
- the Component
to click on.where
- the given coordinates, relative to the given Component
.@RunsInEDT public void click(Point where, MouseButton button, int times)
click
in interface Robot
where
- the coordinates where to click.button
- the mouse button to click.times
- the number of times to click the given mouse button.@RunsInEDT public void click(Component c, Point where, MouseButton button, int times)
Component
.
click
in interface Robot
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.public void pressModifiers(int modifierMask)
InputEvent
.
pressModifiers
in interface Robot
modifierMask
- the given mask.InputEvent
public void releaseModifiers(int modifierMask)
InputEvent
.
releaseModifiers
in interface Robot
modifierMask
- the given mask.InputEvent
@RunsInEDT public void moveMouse(Component c)
Component
.
moveMouse
in interface Robot
c
- the given Component
.@RunsInEDT public void moveMouse(Component c, Point p)
Component
.
moveMouse
in interface Robot
c
- the given Component
.p
- the given coordinates, relative to the given Component
.@RunsInEDT public void moveMouse(Component c, int x, int y)
Component
.
moveMouse
in interface Robot
c
- the given Component
.x
- X coordinate, relative to the given Component
.y
- Y coordinate, relative to the given Component
.public void moveMouse(Point p)
moveMouse
in interface Robot
p
- the given coordinates.public void moveMouse(int x, int y)
moveMouse
in interface Robot
x
- X coordinate.y
- Y coordinate.public void pressMouse(MouseButton button)
pressMouse
in interface Robot
button
- the mouse button to press.public void pressMouse(Component c, Point where)
Component
.
pressMouse
in interface Robot
c
- the Component
to click on.where
- the given coordinates, relative to the given Component
.public void pressMouse(Component c, Point where, MouseButton button)
Component
.
pressMouse
in interface Robot
c
- the Component
to click on.where
- the given coordinates, relative to the given Component
.button
- the mouse button to press.public void pressMouse(Point where, MouseButton button)
pressMouse
in interface Robot
where
- the position where to press the given mouse button.button
- the mouse button to press.@RunsInEDT public void releaseMouse(MouseButton button)
releaseMouse
in interface Robot
button
- the mouse button to release.@RunsInEDT public void releaseMouseButtons()
releaseMouseButtons
in interface Robot
public void rotateMouseWheel(Component c, int amount)
Component
and rotates the scroll wheel on
wheel-equipped mice.
rotateMouseWheel
in interface Robot
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.public void rotateMouseWheel(int amount)
rotateMouseWheel
in interface Robot
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.@RunsInEDT public void jitter(Component c)
Component
.
jitter
in interface Robot
c
- the given Component
.@RunsInEDT public void jitter(Component c, Point where)
Component
at the given
point.
jitter
in interface Robot
c
- the given Component
.where
- the given point.@RunsInEDT public void enterText(String text)
enterText
in interface Robot
text
- the text to enter.@RunsInEDT public void type(char character)
type
in interface Robot
character
- the character to type.@RunsInEDT public void pressAndReleaseKey(int keyCode, int... modifiers)
InputEvent
masks.
pressAndReleaseKey
in interface Robot
keyCode
- the code of the key to press.modifiers
- the given modifiers.@RunsInEDT public void pressAndReleaseKeys(int... keyCodes)
pressAndReleaseKeys
in interface Robot
keyCodes
- one or more codes of the keys to press.KeyEvent
@RunsInEDT public void pressKey(int keyCode)
pressKey
in interface Robot
keyCode
- the code of the key to press.KeyEvent
@RunsInEDT public void releaseKey(int keyCode)
releaseKey
in interface Robot
keyCode
- the code of the key to release.KeyEvent
@RunsInEDT public 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.
waitForIdle
in interface Robot
public boolean isDragging()
isDragging
in interface Robot
true
if the robot is currently in a dragging operation, false
otherwise.@RunsInEDT public JPopupMenu showPopupMenu(Component invoker)
showPopupMenu
in interface Robot
invoker
- the component to invoke the pop-up menu from.
@RunsInEDT public JPopupMenu showPopupMenu(Component invoker, Point location)
showPopupMenu
in interface Robot
invoker
- the component to invoke the pop-up menu from.location
- the given coordinates for the pop-up menu.
@RunsInCurrentThread public boolean isReadyForInput(Component c)
Component
is ready for input.
Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.
isReadyForInput
in interface Robot
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.@RunsInEDT public JPopupMenu findActivePopupMenu()
null
.
findActivePopupMenu
in interface Robot
null
, if no pop-up is currently showing.@RunsInEDT public void requireNoJOptionPaneIsShowing()
JOptionPane
showing, and potentially blocking GUI tests.
requireNoJOptionPaneIsShowing
in interface Robot
public Settings settings()
Robot
.
settings
in interface Robot
Robot
.public ComponentHierarchy hierarchy()
ComponentHierarchy
being used by this robot.
hierarchy
in interface Robot
ComponentHierarchy
being used by this robot.public boolean isActive()
Robot
is active. Being "active" means that Robot.cleanUp()
has
not been called yet.
isActive
in interface Robot
true
if this Robot
is active, false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |