Package org.netbeans.jemmy
Class EventTool
- java.lang.Object
-
- org.netbeans.jemmy.EventTool
-
- All Implemented Interfaces:
Outputable,Timeoutable
public class EventTool extends java.lang.Object implements Timeoutable, Outputable
Provides methods to check last dispatched events, to wait for events of specific types, or to guarantee that events of specific types are not dispatched during some time frame.
All possible listeners are added during this class initialization in case if "jemmy.event_listening" system property is not equal to "no", so, by default, all events are listened. Uses timeouts:
EventTool.WaitEventTimeout - time to wait for AWT events.
EventTool.WaitNoEventTimeout - when checking for the absence of incoming AWT events.
EventTool.EventCheckingDelta - time delta between checks for AWT events.- Author:
- Alexandre Iline (alexandre.iline@sun.com)
-
-
Constructor Summary
Constructors Constructor Description EventTool()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddListeners()Adds listeners to listen all types of events.static voidaddListeners(long eventMask)Adds listeners to listen events under mask.booleancheckNoEvent(long waitTime)Check that no event will be dispatched during time specified.booleancheckNoEvent(long eventMask, long waitTime)Check that no event under mask will be dispatched during time specified.static longgetCurrentEventMask()Returns event mask last time used byaddListeners(long)method.static java.awt.AWTEventgetLastEvent()Returns last dispatched event.static java.awt.AWTEventgetLastEvent(long eventMask)Returns last dispatched event under mask.static longgetLastEventTime()Returns time of the last dispatched event.static longgetLastEventTime(long eventMask)Returns time of the last dispatched event under mask.TestOutgetOutput()Returns print output streams or writers.static longgetTheWholeEventMask()Returns a combination of allAWTEvent.*_EVENT_MASKfields..TimeoutsgetTimeouts()Return current timeouts.static voidremoveListeners()Removes all listeners.voidsetOutput(TestOut out)Defines print output streams or writers.voidsetTimeouts(Timeouts ts)Defines current timeouts.java.awt.AWTEventwaitEvent()Waits for the first event.java.awt.AWTEventwaitEvent(long eventMask)Waits for the first event under mask.voidwaitNoEvent(long waitTime)DuringEventTool.WaitNoEventTimeouttime waits for true result ofcheckNoEvent(long)method.voidwaitNoEvent(long eventMask, long waitTime)DuringEventTool.WaitNoEventTimeouttime waits for true result of checkNoEvent(long, long) method.
-
-
-
Method Detail
-
getLastEventTime
public static long getLastEventTime(long eventMask)
Returns time of the last dispatched event under mask.- Parameters:
eventMask- Events types to be searched.AWTEvent.*_EVENT_MASKfields combination.- Returns:
- time in milliseconds
- See Also:
addListeners(long)
-
getLastEvent
public static java.awt.AWTEvent getLastEvent(long eventMask)
Returns last dispatched event under mask.- Parameters:
eventMask- Events types to be searched.AWTEvent.*_EVENT_MASKfields combination.- Returns:
- AWTEvent
- See Also:
addListeners(long)
-
getLastEventTime
public static long getLastEventTime()
Returns time of the last dispatched event.- Returns:
- time in milliseconds
- See Also:
addListeners(long)
-
getLastEvent
public static java.awt.AWTEvent getLastEvent()
Returns last dispatched event.- Returns:
- AWTEvent
- See Also:
addListeners(long)
-
addListeners
public static void addListeners(long eventMask)
Adds listeners to listen events under mask. InvokesremoveListeners()first, so any event history is lost.- Parameters:
eventMask- Mask to listen events under.AWTEvent.*_EVENT_MASKfields combination.- See Also:
addListeners(),removeListeners()
-
addListeners
public static void addListeners()
Adds listeners to listen all types of events. InvokesremoveListeners()first, so any event history is lost. This method is invoked during static section of this class.
-
removeListeners
public static void removeListeners()
Removes all listeners.- See Also:
addListeners(long),addListeners()
-
getCurrentEventMask
public static long getCurrentEventMask()
Returns event mask last time used byaddListeners(long)method. In case ifaddListeners()method was used last,getTheWholeEventMask()result is returned.- Returns:
- a long representing the current event mask value
- See Also:
getTheWholeEventMask()
-
getTheWholeEventMask
public static long getTheWholeEventMask()
Returns a combination of allAWTEvent.*_EVENT_MASKfields..- Returns:
- a combination of all
AWTEvent.*_EVENT_MASKfields.
-
setTimeouts
public void setTimeouts(Timeouts ts)
Defines current timeouts.- Specified by:
setTimeoutsin interfaceTimeoutable- Parameters:
ts- ?t? A collection of timeout assignments.- See Also:
Timeouts,Timeoutable,getTimeouts()
-
getTimeouts
public Timeouts getTimeouts()
Return current timeouts.- Specified by:
getTimeoutsin interfaceTimeoutable- Returns:
- the collection of current timeout assignments.
- See Also:
Timeouts,Timeoutable,setTimeouts(org.netbeans.jemmy.Timeouts)
-
setOutput
public void setOutput(TestOut out)
Defines print output streams or writers.- Specified by:
setOutputin interfaceOutputable- Parameters:
out- Identify the streams or writers used for print output.- See Also:
Outputable,TestOut,getOutput()
-
getOutput
public TestOut getOutput()
Returns print output streams or writers.- Specified by:
getOutputin interfaceOutputable- Returns:
- an object that contains references to objects for printing to output and err streams.
- See Also:
Outputable,TestOut,setOutput(org.netbeans.jemmy.TestOut)
-
waitEvent
public java.awt.AWTEvent waitEvent(long eventMask)
Waits for the first event under mask. Waits duringEventTool.WaitEventTimeoutmilliseconds.- Parameters:
eventMask- Mask to wait events under.AWTEvent.*_EVENT_MASKfields combination.- Returns:
- an AWTEvent object
- Throws:
TimeoutExpiredException- See Also:
waitEvent()
-
waitEvent
public java.awt.AWTEvent waitEvent()
Waits for the first event. Waits duringEventTool.WaitEventTimeoutmilliseconds.- Returns:
- an AWTEvent object
- Throws:
TimeoutExpiredException- See Also:
waitEvent(long),getTheWholeEventMask()
-
checkNoEvent
public boolean checkNoEvent(long eventMask, long waitTime)Check that no event under mask will be dispatched during time specified.- Parameters:
eventMask- Mask to wait events under.AWTEvent.*_EVENT_MASKfields combination.waitTime- Quiet time (millisecons).- Returns:
- true if no event ahs found.
- See Also:
checkNoEvent(long)
-
checkNoEvent
public boolean checkNoEvent(long waitTime)
Check that no event will be dispatched during time specified.- Parameters:
waitTime- Quiet time (millisecons).- Returns:
- true if no event ahs found.
- See Also:
checkNoEvent(long, long),getTheWholeEventMask()
-
waitNoEvent
public void waitNoEvent(long eventMask, long waitTime)DuringEventTool.WaitNoEventTimeouttime waits for true result of checkNoEvent(long, long) method.- Parameters:
eventMask- Mask to wait events under.AWTEvent.*_EVENT_MASKfields combination.waitTime- Quiet time (millisecons).- Throws:
TimeoutExpiredException- See Also:
checkNoEvent(long, long),waitNoEvent(long)
-
waitNoEvent
public void waitNoEvent(long waitTime)
DuringEventTool.WaitNoEventTimeouttime waits for true result ofcheckNoEvent(long)method.- Parameters:
waitTime- Quiet time (millisecons).- Throws:
TimeoutExpiredException- See Also:
checkNoEvent(long),waitNoEvent(long, long)
-
-