Class EventTool

java.lang.Object
org.netbeans.jemmy.EventTool
All Implemented Interfaces:
Outputable, Timeoutable

public class EventTool extends 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 Details

    • EventTool

      public EventTool()
      Constructor.
  • Method Details

    • 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:
    • getLastEvent

      public static 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:
    • getLastEventTime

      public static long getLastEventTime()
      Returns time of the last dispatched event.
      Returns:
      time in milliseconds
      See Also:
    • getLastEvent

      public static AWTEvent getLastEvent()
      Returns last dispatched event.
      Returns:
      AWTEvent
      See Also:
    • addListeners

      public static void addListeners(long eventMask)
      Adds listeners to listen events under mask. Invokes removeListeners() first, so any event history is lost.
      Parameters:
      eventMask - Mask to listen events under. AWTEvent.*_EVENT_MASK fields combination.
      See Also:
    • addListeners

      public static void addListeners()
      Adds listeners to listen all types of events. Invokes removeListeners() first, so any event history is lost. This method is invoked during static section of this class.
      See Also:
    • removeListeners

      public static void removeListeners()
      Removes all listeners.
      See Also:
    • getCurrentEventMask

      public static long getCurrentEventMask()
      Returns event mask last time used by addListeners(long) method. In case if addListeners() method was used last, getTheWholeEventMask() result is returned.
      Returns:
      a long representing the current event mask value
      See Also:
    • getTheWholeEventMask

      public static long getTheWholeEventMask()
      Returns a combination of all AWTEvent.*_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 interface Timeoutable
      Parameters:
      ts - ?t? A collection of timeout assignments.
      See Also:
    • getTimeouts

      public Timeouts getTimeouts()
      Return current timeouts.
      Specified by:
      getTimeouts in interface Timeoutable
      Returns:
      the collection of current timeout assignments.
      See Also:
    • setOutput

      public void setOutput(TestOut out)
      Defines print output streams or writers.
      Specified by:
      setOutput in interface Outputable
      Parameters:
      out - Identify the streams or writers used for print output.
      See Also:
    • getOutput

      public TestOut getOutput()
      Returns print output streams or writers.
      Specified by:
      getOutput in interface Outputable
      Returns:
      an object that contains references to objects for printing to output and err streams.
      See Also:
    • waitEvent

      public AWTEvent waitEvent(long eventMask)
      Waits for the first event under mask. Waits during EventTool.WaitEventTimeout milliseconds.
      Parameters:
      eventMask - Mask to wait events under. AWTEvent.*_EVENT_MASK fields combination.
      Returns:
      an AWTEvent object
      Throws:
      TimeoutExpiredException
      See Also:
    • waitEvent

      public AWTEvent waitEvent()
      Waits for the first event. Waits during EventTool.WaitEventTimeout milliseconds.
      Returns:
      an AWTEvent object
      Throws:
      TimeoutExpiredException
      See Also:
    • 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

      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:
    • waitNoEvent

      public void waitNoEvent(long eventMask, long waitTime)
      During EventTool.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:
    • waitNoEvent

      public void waitNoEvent(long waitTime)
      During EventTool.WaitNoEventTimeout time waits for true result of checkNoEvent(long) method.
      Parameters:
      waitTime - Quiet time (millisecons).
      Throws:
      TimeoutExpiredException
      See Also: