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 void
addListeners()
Adds listeners to listen all types of events.static void
addListeners(long eventMask)
Adds listeners to listen events under mask.boolean
checkNoEvent(long waitTime)
Check that no event will be dispatched during time specified.boolean
checkNoEvent(long eventMask, long waitTime)
Check that no event under mask will be dispatched during time specified.static long
getCurrentEventMask()
Returns event mask last time used byaddListeners(long)
method.static java.awt.AWTEvent
getLastEvent()
Returns last dispatched event.static java.awt.AWTEvent
getLastEvent(long eventMask)
Returns last dispatched event under mask.static long
getLastEventTime()
Returns time of the last dispatched event.static long
getLastEventTime(long eventMask)
Returns time of the last dispatched event under mask.TestOut
getOutput()
Returns print output streams or writers.static long
getTheWholeEventMask()
Returns a combination of allAWTEvent.*_EVENT_MASK
fields..Timeouts
getTimeouts()
Return current timeouts.static void
removeListeners()
Removes all listeners.void
setOutput(TestOut out)
Defines print output streams or writers.void
setTimeouts(Timeouts ts)
Defines current timeouts.java.awt.AWTEvent
waitEvent()
Waits for the first event.java.awt.AWTEvent
waitEvent(long eventMask)
Waits for the first event under mask.void
waitNoEvent(long waitTime)
DuringEventTool.WaitNoEventTimeout
time waits for true result ofcheckNoEvent(long)
method.void
waitNoEvent(long eventMask, long waitTime)
DuringEventTool.WaitNoEventTimeout
time 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_MASK
fields 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_MASK
fields 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_MASK
fields 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_MASK
fields..- Returns:
- a combination of all
AWTEvent.*_EVENT_MASK
fields.
-
setTimeouts
public void setTimeouts(Timeouts ts)
Defines current timeouts.- Specified by:
setTimeouts
in interfaceTimeoutable
- Parameters:
ts
- ?t? A collection of timeout assignments.- See Also:
Timeouts
,Timeoutable
,getTimeouts()
-
getTimeouts
public Timeouts getTimeouts()
Return current timeouts.- Specified by:
getTimeouts
in 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:
setOutput
in 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:
getOutput
in 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.WaitEventTimeout
milliseconds.- Parameters:
eventMask
- Mask to wait events under.AWTEvent.*_EVENT_MASK
fields combination.- Returns:
- an AWTEvent object
- Throws:
TimeoutExpiredException
- See Also:
waitEvent()
-
waitEvent
public java.awt.AWTEvent waitEvent()
Waits for the first event. Waits duringEventTool.WaitEventTimeout
milliseconds.- 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_MASK
fields 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.WaitNoEventTimeout
time waits for true result of checkNoEvent(long, long) method.- Parameters:
eventMask
- Mask to wait events under.AWTEvent.*_EVENT_MASK
fields combination.waitTime
- Quiet time (millisecons).- Throws:
TimeoutExpiredException
- See Also:
checkNoEvent(long, long)
,waitNoEvent(long)
-
waitNoEvent
public void waitNoEvent(long waitTime)
DuringEventTool.WaitNoEventTimeout
time waits for true result ofcheckNoEvent(long)
method.- Parameters:
waitTime
- Quiet time (millisecons).- Throws:
TimeoutExpiredException
- See Also:
checkNoEvent(long)
,waitNoEvent(long, long)
-
-