|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.jemmy.EventDispatcher
public class EventDispatcher
Provides low level functions for reproducing user actions.
One dispatch model uses the managed component's event queue to dispatch
events. The other dispatch model uses java.awt.Robot
to
generate native events. It is an option in the Robot dispatch model
to wait for the managed component's event queue to empty before dispatching
events.
Timeouts used:
EventDispatcher.WaitQueueEmptyTimeout - to wait event queue empty.
EventDispatcher.RobotAutoDelay - param for java.awt.Robot.setAutoDelay method.
EventDispatcher.WaitComponentUnderMouseTimeout - time to wait component under mouse.
Timeouts
Field Summary | |
---|---|
protected Component |
component
Component to dispatch events to. |
Constructor Summary | |
---|---|
EventDispatcher(Component comp)
Constructor. |
Method Summary | |
---|---|
void |
checkComponentUnderMouse(boolean yesOrNo)
Wait (or not) for the mouse to move over a Java component before pressing. |
void |
delayRobot(long time)
Delays robot. |
void |
dispatchEvent(AWTEvent event)
Dispatches AWTEvent to component passed in constructor. |
void |
dispatchKeyEvent(int id,
int mods,
int keyCode)
Dispatches KeyEvent. |
void |
dispatchKeyEvent(int id,
int mods,
int keyCode,
char keyChar)
Dispatches KeyEvent. |
void |
dispatchMouseEvent(int id,
int mods,
int clickCount,
boolean popup)
Dispatches MouseEvent at the center of component. |
void |
dispatchMouseEvent(int id,
int mods,
int clickCount,
int x,
int y,
boolean popup)
Dispatches a MouseEvent. |
void |
dispatchWindowEvent(int id)
Dispatches WindowEvent. |
protected int |
getAbsoluteX(int x)
Bind horizontal relative cursor coordinate to screen coordinate. |
protected int |
getAbsoluteY(int y)
Bind vertical relative cursor coordinate to screen coordinate. |
int |
getDispatchingModel()
Gets the dispatching model value. |
Object |
getExistingField(String field_name)
Gets component field value through SwingUtilities.invokeAndWait(Runnable) . |
Object |
getExistingField(String field_name,
TestOut out)
Gets component field value through SwingUtilities.invokeAndWait(Runnable) . |
Object |
getField(String field_name)
Gets component field value through SwingUtilities.invokeAndWait(Runnable) . |
static String |
getKeyDescription(int keyCode)
Returns a string representation for a keyboard event. |
static String |
getModifiersString(int modifiers)
Get a string representation for key modifiers. |
static String |
getMouseButtonDescription(int button)
Returns a mouse button string representation. |
TestOut |
getOutput()
Returns print output streams or writers. |
Timeouts |
getTimeouts()
Return current timeouts. |
Object |
invokeExistingMethod(String method_name,
Object[] params,
Class[] params_classes)
Invokes component method through SwingUtilities.invokeAndWait(Runnable) . |
Object |
invokeExistingMethod(String method_name,
Object[] params,
Class[] params_classes,
TestOut out)
Invokes component method through SwingUtilities.invokeAndWait(Runnable) . |
Object |
invokeMethod(String method_name,
Object[] params,
Class[] params_classes)
Invokes component method through SwingUtilities.invokeAndWait(Runnable) . |
static void |
performInit()
|
void |
robotMoveMouse(int x,
int y)
Moves mouse by robot. |
void |
robotPressKey(int keyCode)
Press key with no modifiers using java.awt.Robot . |
void |
robotPressKey(int keyCode,
int modifiers)
Press a key using java.awt.Robot . |
void |
robotPressMouse(int button)
Press mouse button with 0 modifiers. |
void |
robotPressMouse(int button,
int modifiers)
Press mouse button by robot. |
void |
robotReleaseKey(int keyCode)
Releases key with 0 modifiers. |
void |
robotReleaseKey(int keyCode,
int modifiers)
Releases key by robot. |
void |
robotReleaseMouse(int button)
Releases mouse button with 0 modifiers. |
void |
robotReleaseMouse(int button,
int modifiers)
Releases mouse button by robot. |
void |
setDispatchingModel(int m)
Defines dispatching model. |
void |
setExistingField(String field_name,
Object newValue)
Sets component field value through SwingUtilities.invokeAndWait(Runnable) . |
void |
setExistingField(String field_name,
Object newValue,
TestOut out)
Sets component field value through SwingUtilities.invokeAndWait(Runnable) . |
void |
setField(String field_name,
Object newValue)
Sets component field value through SwingUtilities.invokeAndWait(Runnable) . |
void |
setOutput(TestOut out)
Defines print output streams or writers. |
void |
setTimeouts(Timeouts timeouts)
Defines current timeouts. |
void |
waitForIdle()
Waits until all events currently on the event queue have been processed. |
static void |
waitQueueEmpty()
Waits for the managed component's java.awt.EventQueue to empty. |
static void |
waitQueueEmpty(long emptyTime)
Waits for the managed component's java.awt.EventQueue to stay empty. |
static void |
waitQueueEmpty(long emptyTime,
TestOut output,
Timeouts timeouts)
Waits for the managed component's java.awt.EventQueue to stay empty. |
static void |
waitQueueEmpty(TestOut output,
Timeouts timeouts)
Waits for the managed component's java.awt.EventQueue to empty. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Component component
Constructor Detail |
---|
public EventDispatcher(Component comp)
comp
- Component to operate with.Method Detail |
---|
public static void waitQueueEmpty(TestOut output, Timeouts timeouts)
java.awt.EventQueue
to empty.
The timeout for this wait is EventDispatcher.WaitQueueEmptyTimeout.
output
- Output to print exception into.timeouts
- A collection of timeout assignments.
TimeoutExpiredException
QueueTool
public static void waitQueueEmpty()
java.awt.EventQueue
to empty.
Uses default output and timeouts. The timeout for this wait is
EventDispatcher.WaitQueueEmptyTimeout.
TimeoutExpiredException
QueueTool
public static void waitQueueEmpty(long emptyTime, TestOut output, Timeouts timeouts)
java.awt.EventQueue
to stay empty.
The timeout for this wait is EventDispatcher.WaitQueueEmptyTimeout.
emptyTime
- The time that the event queue has to stay empty to avoid
a TimeoutExpiredException.output
- Output to print exception intotimeouts
- A collection of timeout assignments.
TimeoutExpiredException
QueueTool
public static void waitQueueEmpty(long emptyTime)
java.awt.EventQueue
to stay empty.
Uses default output and timeouts. The timeout for this wait is
EventDispatcher.WaitQueueEmptyTimeout.
emptyTime
- The time that the event queue has to stay empty to avoid
a TimeoutExpiredException.
TimeoutExpiredException
QueueTool
public static String getModifiersString(int modifiers)
modifiers
- Bit mask of keyboard event modifiers.
public static String getKeyDescription(int keyCode)
keyCode
- Key code (KeyEvent.VK_*
value)
public static String getMouseButtonDescription(int button)
button
- Mouse button (InputEvent.BUTTON1/2/3_MASK
value).
public static void performInit()
public void checkComponentUnderMouse(boolean yesOrNo)
java.awt.Robot
to generate
mouse events. If a mouse press occurs at a position not occupied by a
known Java component then a NoComponentUnderMouseException
will be thrown.
yesOrNo
- if true
then the test system will wait for
the mouse to move over a Java component before pressing.
therwise, mouse presses can take place anywhere on the screen.public void setOutput(TestOut out)
setOutput
in interface Outputable
out
- Identify the streams or writers used for print output.Outputable
,
TestOut
,
getOutput()
public TestOut getOutput()
getOutput
in interface Outputable
Outputable
,
TestOut
,
setOutput(org.netbeans.jemmy.TestOut)
public void setTimeouts(Timeouts timeouts)
setTimeouts
in interface Timeoutable
timeouts
- A collection of timeout assignments.Timeoutable
,
Timeouts
,
getTimeouts()
public Timeouts getTimeouts()
getTimeouts
in interface Timeoutable
Timeoutable
,
Timeouts
,
setTimeouts(org.netbeans.jemmy.Timeouts)
public void setDispatchingModel(int m)
m
- New model value.getDispatchingModel()
,
JemmyProperties.QUEUE_MODEL_MASK
,
JemmyProperties.ROBOT_MODEL_MASK
,
JemmyProperties.getCurrentDispatchingModel()
,
JemmyProperties.setCurrentDispatchingModel(int)
,
JemmyProperties.initDispatchingModel(boolean, boolean)
,
JemmyProperties.initDispatchingModel()
public int getDispatchingModel()
setDispatchingModel(int)
,
JemmyProperties.QUEUE_MODEL_MASK
,
JemmyProperties.ROBOT_MODEL_MASK
,
JemmyProperties.getCurrentDispatchingModel()
,
JemmyProperties.setCurrentDispatchingModel(int)
,
JemmyProperties.initDispatchingModel(boolean, boolean)
,
JemmyProperties.initDispatchingModel()
public void dispatchEvent(AWTEvent event)
AWTEvent
to component passed in constructor.
If (getDispatchingModel & JemmyProperties.QUEUE_MODEL_MASK) == 0
dispatched event directly, otherwise uses
javax.swing.SwingUtilities.invokeAndWait(Runnable)
event
- AWTEvent instance to be dispatched.
ComponentIsNotVisibleException
ComponentIsNotFocusedException
public void dispatchMouseEvent(int id, int mods, int clickCount, int x, int y, boolean popup)
id
- MouseEvent.MOUSE_*
valuemods
- InputEvent.MOUSE1/2/3_BUTTON
| (modiviers value)clickCount
- Click countx
- Horizontal click point coordinate.y
- vertical click point coordinate.popup
- Difines if mouse event is popup event.dispatchEvent(AWTEvent)
public void dispatchMouseEvent(int id, int mods, int clickCount, boolean popup)
id
- MouseEvent.MOUSE_*
valuemods
- InputEvent.MOUSE1/2/3_BUTTON
| (modiviers value)clickCount
- Click countpopup
- Difines if mouse event is popup event.dispatchEvent(AWTEvent)
public void dispatchWindowEvent(int id)
id
- WindowEvent.WINDOW_*
valuedispatchEvent(AWTEvent)
public void dispatchKeyEvent(int id, int mods, int keyCode)
id
- KeyEvent.KEY_PRESSED
or KeyEvent.KEY_RELEASED
value.mods
- Modifiers.keyCode
- Key code,dispatchEvent(AWTEvent)
public void dispatchKeyEvent(int id, int mods, int keyCode, char keyChar)
id
- KeyEvent.KEY_TYPED
value.mods
- Modifiers.keyCode
- Key code,keyChar
- Char to be tipeddispatchEvent(AWTEvent)
public void waitForIdle()
protected int getAbsoluteX(int x)
x
- Relative coordinate
protected int getAbsoluteY(int y)
y
- Relative coordinate
public void delayRobot(long time)
time
- Time to dalay robot for.public void robotMoveMouse(int x, int y)
x
- Component relative horizontal coordinate.y
- Component relative vertical coordinate.
ComponentIsNotVisibleException
public void robotPressMouse(int button, int modifiers)
button
- Mouse button (InputEvent.MOUSE1/2/3_BUTTON value)modifiers
- Modifiers
ComponentIsNotVisibleException
public void robotPressMouse(int button)
button
- Mouse button (InputEvent.MOUSE1/2/3_BUTTON
value)robotPressMouse(int, int)
public void robotReleaseMouse(int button, int modifiers)
button
- Mouse button (InputEvent.MOUSE1/2/3_BUTTON
value)modifiers
- Modifiers
ComponentIsNotVisibleException
public void robotReleaseMouse(int button)
button
- Mouse button (InputEvent.MOUSE1/2/3_BUTTON
value)robotReleaseMouse(int, int)
public void robotPressKey(int keyCode, int modifiers)
java.awt.Robot
.
keyCode
- Key (KeyEvent.VK_*
value)modifiers
- Mask of KeyEvent modifiers.
ComponentIsNotVisibleException
ComponentIsNotFocusedException
public void robotPressKey(int keyCode)
java.awt.Robot
.
keyCode
- Key (KeyEvent.VK_*
value)robotPressKey(int, int)
public void robotReleaseKey(int keyCode, int modifiers)
keyCode
- Key (KeyEvent.VK_*
value)modifiers
- Mask of KeyEvent modifiers.
ComponentIsNotVisibleException
ComponentIsNotFocusedException
public void robotReleaseKey(int keyCode)
keyCode
- Key (KeyEvent.VK_*
value)robotPressKey(int, int)
public Object invokeMethod(String method_name, Object[] params, Class[] params_classes) throws InvocationTargetException, IllegalStateException, NoSuchMethodException, IllegalAccessException
SwingUtilities.invokeAndWait(Runnable)
.
method_name
- Name of a method to be invokedparams
- Method paramsparams_classes
- Method params' classes
IllegalAccessException
NoSuchMethodException
IllegalStateException
InvocationTargetException
ClassReference
public Object getField(String field_name) throws InvocationTargetException, IllegalStateException, NoSuchFieldException, IllegalAccessException
SwingUtilities.invokeAndWait(Runnable)
.
field_name
- Name of a field
IllegalAccessException
IllegalStateException
InvocationTargetException
NoSuchFieldException
setField(String, Object)
,
ClassReference
public void setField(String field_name, Object newValue) throws InvocationTargetException, IllegalStateException, NoSuchFieldException, IllegalAccessException
SwingUtilities.invokeAndWait(Runnable)
.
field_name
- Name of a fieldnewValue
- New field value
IllegalAccessException
IllegalStateException
InvocationTargetException
NoSuchFieldException
getField(String)
,
ClassReference
public Object invokeExistingMethod(String method_name, Object[] params, Class[] params_classes, TestOut out)
SwingUtilities.invokeAndWait(Runnable)
.
and catch all exceptions.
method_name
- Name of a method to be invokedparams
- Method paramsparams_classes
- Method params' classesout
- TestOut instance to print exceptions stack trace to.
invokeMethod(String, Object[], Class[])
,
ClassReference
public Object getExistingField(String field_name, TestOut out)
SwingUtilities.invokeAndWait(Runnable)
.
and catch all exceptions.
field_name
- Name of a fieldout
- TestOut instance to print exceptions stack trace to.
getField(String)
,
setExistingField(String, Object, TestOut)
,
ClassReference
public void setExistingField(String field_name, Object newValue, TestOut out)
SwingUtilities.invokeAndWait(Runnable)
.
and catch all exceptions.
field_name
- Name of a fieldnewValue
- New field valueout
- TestOut instance to print exceptions stack trace to.setField(String, Object)
,
getExistingField(String, TestOut)
,
ClassReference
public Object invokeExistingMethod(String method_name, Object[] params, Class[] params_classes)
SwingUtilities.invokeAndWait(Runnable)
.
and catch all exceptions.
Exceptions are printed into TestOut object defined
by setOutput(TestOut) method.
method_name
- Name of a method to be invokedparams
- Method paramsparams_classes
- Method params' classes
invokeExistingMethod(String, Object[], Class[], TestOut)
,
ClassReference
public Object getExistingField(String field_name)
SwingUtilities.invokeAndWait(Runnable)
.
and catch all exceptions.
Exceptions are printed into TestOut object defined
by setOutput(TestOut) method.
field_name
- Name of a field
getExistingField(String, TestOut)
,
setExistingField(String, Object)
,
ClassReference
public void setExistingField(String field_name, Object newValue)
SwingUtilities.invokeAndWait(Runnable)
.
and catch all exceptions.
Exceptions are printed into TestOut object defined
by setOutput(TestOut) method.
field_name
- Name of a fieldnewValue
- New field valuesetExistingField(String, Object, TestOut)
,
getExistingField(String)
,
ClassReference
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |