junit.extensions.jfcunit
Class JFCTestHelper

java.lang.Object
  extended byjunit.extensions.jfcunit.TestHelper
      extended byjunit.extensions.jfcunit.JFCTestHelper

public final class JFCTestHelper
extends TestHelper

Class that provides facilities for locating components within a GUI. To use create a new instance of JFCTestHelper in your setUp. Windows can only be located once they have been shown once to the user. Provide methods for entering clicks and drag operations. Note: java.awt.dnd functions are tightly integrated with the OS and are not dependent on the AWTEventQueue processing. Thus these interactions can only be done with the RobotTestHelper which sends events in at the OS level.

Author:
Matt Caswell, Vijay Aravamudhan : ThoughtWorks Inc., Kevin Wilson

Field Summary
private  int m_lastClicks
          Last number of clicks.
private  int m_lastMouseModifiers
          The mouse buttons that were pressed in the previous call.
private  boolean m_lastPopup
          The popup that appeared in the previous call.
private  long m_lastPressed
          The mouse buttons that were pressed in the previous call.
private  java.awt.EventQueue m_queue
          The EventQueue on which all events are processed.
private static java.awt.Point s_last
          The coordinate where the last event was fired.
 
Fields inherited from class junit.extensions.jfcunit.TestHelper
DEFAULTSLEEP
 
Constructor Summary
JFCTestHelper()
          Constructor.
 
Method Summary
protected  void keyPressed(java.awt.Component ultimate, JFCKeyStroke stroke)
          Process a key press event on a component.
protected  void keyReleased(java.awt.Component ultimate, JFCKeyStroke stroke)
          Process a key release event on a component.
protected  void mouseMoved(java.awt.Component ultimate, int x, int y)
          Process a mouse move event on a component.
protected  void mousePressed(java.awt.Component ultimate, int modifiers, int click, boolean isPopupTrigger)
          Process a mouse press event on a component.
protected  void mouseReleased(java.awt.Component ultimate, int modifiers, int click, boolean isPopupTrigger)
          Process a mouse release event on a component.
protected  void mouseWheel(java.awt.Component ultimate, int amount, int wheelRotation)
          Simulate rotating the mouseWheel Only supported in Java 1.4.
private  void postEvent(java.awt.AWTEvent evt)
          This method is just present so as to put debug statements in one central place, without repeating everywhere.
 
Methods inherited from class junit.extensions.jfcunit.TestHelper
addSystemWindow, adjustModifiers, calcNextPoint, cleanUp, cleanUp, disposeWindow, disposeWindow, enterClickAndLeave, enterDragAndLeave, enterDragAndLeave, enterMouseWheel, findComponent, findComponent, findComponent, findComponent, findNamedComponent, findNamedComponent, findNamedComponent, findNamedComponent, findNamedComponent, findNamedComponent, getAllWindows, getCurrentTestCase, getKeyMapping, getMessageFromJDialog, getShowingDialogs, getShowingDialogs, getShowingDialogs, getShowingDialogs, getShowingDialogs, getShowingDialogs, getShowingDialogs, getShowingJFileChooser, getShowingJFileChoosers, getStep, getSystemWindows, getWindow, getWindow, getWindows, getWindows, getWindows, getWindows, getWindows, indexOf, isBounded, mouseToKeyModifiers, pressModifiers, releaseModifiers, removeAllSystemWindows, removeSystemWindow, sendKeyAction, sendString, setCurrentTestCase, setKeyMapping, setStep
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_last

private static java.awt.Point s_last
The coordinate where the last event was fired.


m_queue

private java.awt.EventQueue m_queue
The EventQueue on which all events are processed.


m_lastPopup

private boolean m_lastPopup
The popup that appeared in the previous call.


m_lastClicks

private int m_lastClicks
Last number of clicks.


m_lastMouseModifiers

private int m_lastMouseModifiers
The mouse buttons that were pressed in the previous call.


m_lastPressed

private long m_lastPressed
The mouse buttons that were pressed in the previous call.

Constructor Detail

JFCTestHelper

public JFCTestHelper()
Constructor.

Method Detail

keyPressed

protected void keyPressed(java.awt.Component ultimate,
                          JFCKeyStroke stroke)
Process a key press event on a component.

Specified by:
keyPressed in class TestHelper
Parameters:
ultimate - The ultimate parent Component
stroke - The JFCKeyStroke to be performed.

keyReleased

protected void keyReleased(java.awt.Component ultimate,
                           JFCKeyStroke stroke)
Process a key release event on a component.

Specified by:
keyReleased in class TestHelper
Parameters:
ultimate - The ultimate parent Component
stroke - The JFCKeyStroke to be performed.

mouseMoved

protected void mouseMoved(java.awt.Component ultimate,
                          int x,
                          int y)
Process a mouse move event on a component.

Specified by:
mouseMoved in class TestHelper
Parameters:
ultimate - The ultimate parent Component
x - The x coordinate of the point where the mouse is being moved to.
y - The y coordinate of the point where the mouse is being moved to.

mousePressed

protected void mousePressed(java.awt.Component ultimate,
                            int modifiers,
                            int click,
                            boolean isPopupTrigger)
Process a mouse press event on a component.

Specified by:
mousePressed in class TestHelper
Parameters:
ultimate - The ultimate parent Component
modifiers - The modifiers associated with this mouse event.
click - The number of clicks associated with this mouse event.
isPopupTrigger - Whether this mouse event will generate a popup.

mouseReleased

protected void mouseReleased(java.awt.Component ultimate,
                             int modifiers,
                             int click,
                             boolean isPopupTrigger)
Process a mouse release event on a component.

Specified by:
mouseReleased in class TestHelper
Parameters:
ultimate - The ultimate parent Component
modifiers - The modifiers associated with this mouse event.
click - The number of clicks associated with this mouse event.
isPopupTrigger - Whether this mouse event will generate a popup.

mouseWheel

protected void mouseWheel(java.awt.Component ultimate,
                          int amount,
                          int wheelRotation)
Simulate rotating the mouseWheel Only supported in Java 1.4.

Specified by:
mouseWheel in class TestHelper
Parameters:
ultimate - Component to fire the events on.
amount - Amount to rotate the wheel.
wheelRotation - amount to rotate the wheel. positive for rotation towards the user. Negative for rotation away from the user.

postEvent

private void postEvent(java.awt.AWTEvent evt)
This method is just present so as to put debug statements in one central place, without repeating everywhere.

Parameters:
evt - The event to be posted.


Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999