junit.extensions.jfcunit
Class RobotTestHelper

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

public class RobotTestHelper
extends TestHelper

Class that provides facilities for locating components within a GUI. To use create a new instance of RobotTestHelper in your setUp. Windows can only be located once they have been shown once to the user. After calling the helper.enterClickAndLeave() the JFCTestCase.sleep(long delay) method should be called to prevent subsequent clicks from being treated as a double click. A sleep dalay of 300ms can be used as a guideline.

Author:
Vijay Aravamudhan : ThoughtWorks Inc., Kevin Wilson

Field Summary
private static int LEGAL_BUTTONS
          Legal buttons.
private  int m_delay
          Mandatory delay to get thing working.
private  java.awt.Robot m_robot
          Robot instance.
private static java.awt.Point s_last
          Last location.
 
Fields inherited from class junit.extensions.jfcunit.TestHelper
DEFAULTSLEEP
 
Constructor Summary
RobotTestHelper()
          Construct a new RobotTestHelper.
 
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.
 
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
Last location.


LEGAL_BUTTONS

private static final int LEGAL_BUTTONS
Legal buttons.

See Also:
Constant Field Values

m_robot

private java.awt.Robot m_robot
Robot instance.


m_delay

private int m_delay
Mandatory delay to get thing working.

Constructor Detail

RobotTestHelper

public RobotTestHelper()
                throws java.awt.AWTException
Construct a new RobotTestHelper.

Throws:
java.awt.AWTException - An instance of java.awt.AWTException can be thrown when initializing the Robot.
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 - Not used in the robot.
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 - Not used in the robot.
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 - Not used in the robot.
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 - Not used in the robot.
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 - Not used in the robot.
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. Ignored on the robot. The amount will be extracted from the OS Mouse configuration.
wheelRotation - Rotation of the mouse wheel.


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