junit.extensions.jfcunit
Class TestHelper

java.lang.Object
  extended byjunit.extensions.jfcunit.TestHelper
Direct Known Subclasses:
JFCTestHelper, RobotTestHelper

public abstract class TestHelper
extends java.lang.Object

A helper class that provides facilities for locating and posting events to components within a GUI. To use, create a new instance of TestHelper in your setUp. Caveat: Windows can only be located once they have been shown once to the user.

Author:
Matt Caswell, Vijay Aravamudhan : ThoughtWorks Inc.

Field Summary
static long DEFAULTSLEEP
          The length of time that the test class will sleep for between each event being posted.
private static java.lang.Object LOCK
          Lock for setting the key mapping.
private  int m_step
          Step size for mouse movement events.
private static KeyMapping s_keyMapping
          KeyMapping to be used with the helper.
private static java.util.HashMap s_systemWindows
          System Windows List.
private static JFCTestCase s_test
          Current test.
 
Constructor Summary
protected TestHelper()
          Constructor.
 
Method Summary
static void addSystemWindow(java.lang.String matchTitleRE)
          Add a regular expression to match the window titles which should not be closed during cleanup.
protected  void adjustModifiers(java.awt.Component ultimate, int modifiers, int newModifiers)
          Send the modifier key release event for the modifiers.
static java.awt.Point calcNextPoint(java.awt.Point src, java.awt.Point dest, int step)
          Calculate the next point along the path to the destingation point.
static void cleanUp(JFCTestCase testCase)
          This method is used to clean up any existing open windows, etc if ase lettersa test fails midway.
static void cleanUp(JFCTestCase testCase, long awtSleepTime)
          This method is used to clean up any existing open windows, etc if a test fails midway.
static void disposeWindow(java.awt.Window window, JFCTestCase testCase)
          This method does the actual work of destroying the window.
static void disposeWindow(java.awt.Window window, JFCTestCase testCase, long awtSleepTime)
          This method does the actual work of destroying the window and any dialogs that it owns.
 void enterClickAndLeave(AbstractMouseEventData evtData)
          Helper method to fire appropriate events to click(s) a component with a custom wait method.
 void enterDragAndLeave(AbstractMouseEventData srcEvtData, AbstractMouseEventData dstEvtData, int incr)
          Helper method to fire appropriate events to drag and drop a component with a custom wait method.
 void enterDragAndLeave(DragEventData ded)
          Helper method to fire appropriate events to drag and drop a component with a custom wait method.
 void enterMouseWheel(MouseWheelEventData evtData)
          Enter a mouseWheel event.
static java.awt.Component findComponent(java.lang.Class compCls, java.awt.Container cont, int index)
          Deprecated. 2.02 Use new ComponentFinder(compCls).find(cont, index);
static java.awt.Component findComponent(java.lang.Class compCls, int index)
          Deprecated. 2.02 Use new ComponentFinder(aClass).find(index);
static java.awt.Component findComponent(Finder finder, java.awt.Container cont, int index)
          Deprecated. 2.02 use finder.find(cont, index);
static java.awt.Component findComponent(Finder finder, int index)
          Deprecated. 2.02 Use finder.find(index);
static java.awt.Component findNamedComponent(java.lang.Class aClass, java.awt.Container cont, int index)
          Deprecated. 2.02 Use new NamedComponentFinder(aClass, null).find(cont, index);
static java.awt.Component findNamedComponent(java.lang.Class compCls, int index)
          Deprecated. 2.02 Use new ComponentFinder(compCls).find(cont, index);
static java.awt.Component findNamedComponent(java.lang.Class aClass, java.lang.String name, java.awt.Container cont, int index)
          Deprecated. 2.02 Use new NamedComponentFinder(aClass, name).find(cont, index);
static java.awt.Component findNamedComponent(java.lang.Class compCls, java.lang.String name, int index)
          Deprecated. 2.02 Use new NamedComponentFinder(compCls, name).find(index);
static java.awt.Component findNamedComponent(java.lang.String name, java.awt.Container cont, int index)
          Deprecated. 2.02 Use new NamedComponentFinder(null, name).find(cont, index);
static java.awt.Component findNamedComponent(java.lang.String name, int index)
          Deprecated. 2.02 Use new NamedComponentFinder(null,name).find(index);
static java.awt.Window[] getAllWindows()
          Deprecated. 2.02 use WindowMonitor.getWindows();
static JFCTestCase getCurrentTestCase()
          Get the current test case.
private static int getDir(int src, int dest)
          Calculate the direction of travel given the src and dest point.
static KeyMapping getKeyMapping()
          Get the key mapping to be used.
 java.lang.String getMessageFromJDialog(javax.swing.JDialog dialog)
          A helper method to find the message being displayed in a dialog box.
static java.util.List getShowingDialogs()
          Deprecated. 2.05 Use DialogFinder(null).findAll()
static java.util.List getShowingDialogs(java.util.List ret, java.awt.Window[] owners, Finder finder)
          Deprecated. 2.05 use new DialogFinder(null).findAll(owners);
static java.util.List getShowingDialogs(java.util.List ret, java.awt.Window[] owners, java.lang.String titlematch)
          Deprecated. 2.05 Use new DialogFinder(titlematch).findAll(owners);
static java.util.List getShowingDialogs(java.lang.String titlematch)
          Deprecated. 2.05 use new DialogFinder(titlematch).findAll();
static java.util.List getShowingDialogs(java.awt.Window win)
          Deprecated. 2.05 Use new DialogFinder(null).findAll(win);
static java.util.List getShowingDialogs(java.awt.Window[] owners, java.lang.String titlematch)
          Deprecated. 2.05 use new DialogFinder(titlematch).findAll(owners);
static java.util.List getShowingDialogs(java.awt.Window win, java.lang.String titlematch)
          Deprecated. 2.05 use new DialogFinder(titleMatch).findAll(win);
 javax.swing.JFileChooser getShowingJFileChooser(java.awt.Window win)
          Deprecated. 2.05 use JFileChooserFinder(null).find(win, 0);
 java.util.List getShowingJFileChoosers(java.awt.Window win)
          Deprecated. 2.05 use JFileChooserFinder(null).findAl(win);
 int getStep()
          Returns the step size for the move events.
static java.util.Set getSystemWindows()
          Returns a unmodifiable list of the system window regular expressions.
static java.awt.Window getWindow(AbstractWindowFinder finder)
          Returns a single window that is showing that passes the filtration by the Finder passed in.
static java.awt.Window getWindow(java.lang.String title)
          Deprecated. 2.02 use new FrameFinder(title).getWindow
static java.util.List getWindows()
          Returns a set of all the Windows that are currently visible.
static java.util.List getWindows(AbstractWindowFinder finder)
          Deprecated. 2.05 use finder.findAll();
static java.util.List getWindows(java.util.List ret, java.awt.Window[] windows, Finder finder)
          Deprecated. 2.05 use finder.findAll(windows);
static java.util.List getWindows(java.util.List ret, java.awt.Window[] windows, java.lang.String titlematch)
          Deprecated. 2.05 use new FrameFinder(titlematch).findAll();
static java.util.List getWindows(java.lang.String titlematch)
          Returns a set of all the Windows that are currently visible and the title contains the given titlematch string.
static int indexOf(Finder finder, java.awt.Container cont, java.awt.Component comp)
          Find the index of the component given.
protected static boolean isBounded(int val, int vMin, int vMax)
          Check to see if the value is bounded by the min and max.
protected abstract  void keyPressed(java.awt.Component ultimate, JFCKeyStroke stroke)
          Process a key press event on a component.
protected abstract  void keyReleased(java.awt.Component ultimate, JFCKeyStroke stroke)
          Process a key release event on a component.
protected abstract  void mouseMoved(java.awt.Component ultimate, int x, int y)
          Process a mouse move event on a component.
protected abstract  void mousePressed(java.awt.Component ultimate, int modifiers, int click, boolean isPopupTrigger)
          Process a mouse press event on a component.
protected abstract  void mouseReleased(java.awt.Component ultimate, int modifiers, int click, boolean isPopupTrigger)
          Process a mouse release event on a component.
protected static int mouseToKeyModifiers(int modifiers)
          Convert the modifiers from mouse modifiers to keyboard modifiers.
protected abstract  void mouseWheel(java.awt.Component ultimate, int amount, int rotation)
          Simulate rotating the mouseWheel.
protected  void pressModifiers(java.awt.Component ultimate, int modifiers)
          Send the modifier key press event for the modifiers.
protected  void releaseModifiers(java.awt.Component ultimate, int modifiers)
          Send the modifier key release event for the modifiers.
static void removeAllSystemWindows()
          Remove all System Window regular expressions.
static void removeSystemWindow(java.lang.String matchTitleRE)
          Remove a regular expression to match the window titles which should not be closed during cleanup.
 void sendKeyAction(KeyEventData evtData)
          This method is used to send KeyPressed, KeyTyped and KeyReleased events (in that order) to the specified component.
 void sendString(AbstractKeyEventData evtData)
          This method is used to send KeyPressed, KeyTyped and KeyReleased events (in that order) to the specified component.
static void setCurrentTestCase(JFCTestCase tc)
          Set the current test case.
static void setKeyMapping(KeyMapping km)
          Set the key mapping to be used.
 void setStep(int step)
          Set the step size of mouse move events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULTSLEEP

public static final long DEFAULTSLEEP
The length of time that the test class will sleep for between each event being posted.

See Also:
Constant Field Values

s_test

private static JFCTestCase s_test
Current test.


s_keyMapping

private static KeyMapping s_keyMapping
KeyMapping to be used with the helper.


s_systemWindows

private static java.util.HashMap s_systemWindows
System Windows List. These windows should not be closed when the cleanUp is called. The vector should contain the Regular expression strings for matching the name to the title.


LOCK

private static final java.lang.Object LOCK
Lock for setting the key mapping.


m_step

private int m_step
Step size for mouse movement events.

Constructor Detail

TestHelper

protected TestHelper()
Constructor.

Method Detail

getAllWindows

public static java.awt.Window[] getAllWindows()
Deprecated. 2.02 use WindowMonitor.getWindows();

Get all of the windows we know about including heavy weight popups.

Returns:
Window[] All of the windows we know about.

setCurrentTestCase

public static void setCurrentTestCase(JFCTestCase tc)
Set the current test case.

Parameters:
tc - TestCase to set as the current test.

getCurrentTestCase

public static JFCTestCase getCurrentTestCase()
Get the current test case.

Returns:
JFCTestCase which is the current test.

getSystemWindows

public static final java.util.Set getSystemWindows()
Returns a unmodifiable list of the system window regular expressions.

Returns:
unmodifiable Set containing the regular expressions for matching windows.

addSystemWindow

public static final void addSystemWindow(java.lang.String matchTitleRE)
                                  throws org.apache.regexp.RESyntaxException
Add a regular expression to match the window titles which should not be closed during cleanup.

Parameters:
matchTitleRE - Regular expression defining the windows which should not be closed.
Throws:
org.apache.regexp.RESyntaxException - if the syntax is not a valid Regular expression.

setKeyMapping

public static void setKeyMapping(KeyMapping km)
Set the key mapping to be used.

Parameters:
km - KeyMapping to be used.

getKeyMapping

public static KeyMapping getKeyMapping()
Get the key mapping to be used.

Returns:
the key mapping.

getShowingDialogs

public static java.util.List getShowingDialogs()
Deprecated. 2.05 Use DialogFinder(null).findAll()

Returns a set of all the Dialogs that are currently visible for all opened, visible windows - including the special case of the shared, hidden frame which is the owner of JDialogs whose owner is not specified.

Returns:
The full list of dialogs.

getShowingDialogs

public static java.util.List getShowingDialogs(java.awt.Window win)
Deprecated. 2.05 Use new DialogFinder(null).findAll(win);

Helper method to obtain a list of the dialogs owned by a given window.

Parameters:
win - The window to find dialogs for.
Returns:
The list of dialogs owned by the given window (including the window if it is a Dialog itself).

getShowingDialogs

public static java.util.List getShowingDialogs(java.lang.String titlematch)
Deprecated. 2.05 use new DialogFinder(titlematch).findAll();

Returns a set of all the Dialogs that are currently visible and the title contains the given titlematch string - including the special case of the shared, hidden frame which is the owner of JDialogs whose owner is not specified.

Parameters:
titlematch - The string pattern to search for in the dialog's title.
Returns:
The list of dialogs owned by the given window (including the window if it is a Dialog itself).

getShowingDialogs

public static java.util.List getShowingDialogs(java.awt.Window win,
                                               java.lang.String titlematch)
Deprecated. 2.05 use new DialogFinder(titleMatch).findAll(win);

Returns a set of all the Dialogs that are currently visible and the title contains the given titlematch string.

Parameters:
win - The window to find dialogs for.
titlematch - The string pattern to search for in the dialog's title.
Returns:
The list of dialogs owned by the given window (including the window if it is a Dialog itself).

getShowingDialogs

public static java.util.List getShowingDialogs(java.awt.Window[] owners,
                                               java.lang.String titlematch)
Deprecated. 2.05 use new DialogFinder(titlematch).findAll(owners);

Returns a set of all the Dialogs that are currently visible and the title contains the given titlematch string - including the special case of the shared, hidden frame which is the owner of JDialogs whose owner is not specified.

Parameters:
owners - The array of windows to find dialogs for.
titlematch - The string pattern to search for in the dialog's title.
Returns:
The list of dialogs owned by the given window (including the window if it is a Dialog itself).

getShowingDialogs

public static java.util.List getShowingDialogs(java.util.List ret,
                                               java.awt.Window[] owners,
                                               java.lang.String titlematch)
Deprecated. 2.05 Use new DialogFinder(titlematch).findAll(owners);

Returns a set of all the Dialogs that are currently visible and the title contains the given titlematch string - including the special case of the shared, hidden frame which is the owner of JDialogs whose owner is not specified.

Parameters:
ret - The list of already filtered and accepted dialogs.
owners - The array of windows to find dialogs for.
titlematch - The string pattern to search for in the dialog's title.
Returns:
The list of dialogs owned by the given window (including the window if it is a Dialog itself).

getShowingDialogs

public static java.util.List getShowingDialogs(java.util.List ret,
                                               java.awt.Window[] owners,
                                               Finder finder)
Deprecated. 2.05 use new DialogFinder(null).findAll(owners);

Returns a set of all the Dialogs that are currently visible and the title contains the given titlematch string - including the special case of the shared, hidden frame which is the owner of JDialogs whose owner is not specified.

Parameters:
ret - The list of already filtered and accepted dialogs.
owners - The array of windows to find dialogs for.
finder - The DialogFinder which is used to filter using a title match
Returns:
The list of dialogs owned by the given window (including the window if it is a Dialog itself).

getWindows

public static java.util.List getWindows(AbstractWindowFinder finder)
Deprecated. 2.05 use finder.findAll();

Returns a set of all the Windows that are currently visible based on the Finder being passed in.

Parameters:
finder - The AbstractWindowFinder which is used to filter
Returns:
Set of Window objects.

getWindows

public static java.util.List getWindows(java.util.List ret,
                                        java.awt.Window[] windows,
                                        java.lang.String titlematch)
Deprecated. 2.05 use new FrameFinder(titlematch).findAll();

Returns a set of all the Windows that are currently visible and the title contains the given titlematch string.

Parameters:
ret - The list of already filtered and accepted windows.
windows - The array of windows to filter and add.
titlematch - The string pattern to search for in the window's title.
Returns:
Set of Window objects.

getWindows

public static java.util.List getWindows(java.util.List ret,
                                        java.awt.Window[] windows,
                                        Finder finder)
Deprecated. 2.05 use finder.findAll(windows);

Returns a set of all the Windows that are currently visible and the title contains the given titlematch string.

Parameters:
ret - The list of already filtered and accepted windows.
windows - The array of windows to filter and add.
finder - The FrameFinder which is used to filter using a title match
Returns:
Set of Window objects.

calcNextPoint

public static java.awt.Point calcNextPoint(java.awt.Point src,
                                           java.awt.Point dest,
                                           int step)
Calculate the next point along the path to the destingation point.

Parameters:
src - Source point.
dest - Dest point.
step - Number of pixels to step.
Returns:
src point.

cleanUp

public static void cleanUp(JFCTestCase testCase)
This method is used to clean up any existing open windows, etc if ase lettersa test fails midway. To be called in the tearDown() method.

Parameters:
testCase - The test case that is firing the event.
See Also:
addSystemWindow(java.lang.String), removeSystemWindow(java.lang.String), removeAllSystemWindows()

cleanUp

public static void cleanUp(JFCTestCase testCase,
                           long awtSleepTime)
This method is used to clean up any existing open windows, etc if a test fails midway. To be called in the tearDown() method.

Parameters:
testCase - The test case that is firing the event.
awtSleepTime - The wait time in ms between each event.

disposeWindow

public static void disposeWindow(java.awt.Window window,
                                 JFCTestCase testCase)
This method does the actual work of destroying the window.

Parameters:
window - The window that needs to be destroyed.
testCase - The test case that is firing the event.

disposeWindow

public static void disposeWindow(java.awt.Window window,
                                 JFCTestCase testCase,
                                 long awtSleepTime)
This method does the actual work of destroying the window and any dialogs that it owns.

Parameters:
window - The window that needs to be destroyed.
testCase - The test case that is firing the event.
awtSleepTime - The wait time in ms between each event.

removeAllSystemWindows

public static final void removeAllSystemWindows()
Remove all System Window regular expressions.


removeSystemWindow

public static final void removeSystemWindow(java.lang.String matchTitleRE)
Remove a regular expression to match the window titles which should not be closed during cleanup.

Parameters:
matchTitleRE - Regular expression defining the windows which should not be closed.

getMessageFromJDialog

public java.lang.String getMessageFromJDialog(javax.swing.JDialog dialog)
A helper method to find the message being displayed in a dialog box.

Parameters:
dialog - The dialog box displaying the message
Returns:
The messagebeing displayed

getWindow

public static java.awt.Window getWindow(java.lang.String title)
Deprecated. 2.02 use new FrameFinder(title).getWindow

Returns a single window that is showing with given string in the title. If there is more than one window that match, then it is undefined which one will be returned.

Parameters:
title - The string that should be present in the title.
Returns:
A showing window with the given title pattern.

getWindow

public static java.awt.Window getWindow(AbstractWindowFinder finder)
Returns a single window that is showing that passes the filtration by the Finder passed in. If there is more than one window that match, then it is undefined which one will be returned.

Parameters:
finder - The AbstractWindowFinder which is used to filter
Returns:
A showing window with the given title.

getWindows

public static java.util.List getWindows()
Returns a set of all the Windows that are currently visible.

Returns:
Set of Window objects.

getWindows

public static java.util.List getWindows(java.lang.String titlematch)
Returns a set of all the Windows that are currently visible and the title contains the given titlematch string.

Parameters:
titlematch - The string pattern to search for in the window's title.
Returns:
Set of Window objects.

getShowingJFileChooser

public javax.swing.JFileChooser getShowingJFileChooser(java.awt.Window win)
Deprecated. 2.05 use JFileChooserFinder(null).find(win, 0);

Finds a JFileChooser being shown by a window.

Parameters:
win - The window to owning the chooser.
Returns:
The chooser that has been found, or null if there are none.

getShowingJFileChoosers

public java.util.List getShowingJFileChoosers(java.awt.Window win)
Deprecated. 2.05 use JFileChooserFinder(null).findAl(win);

Finds a list of all the JFileChoosers being shown by a window.

Parameters:
win - The window to owning the chooser.
Returns:
The list of JFileChoosers.

findComponent

public static java.awt.Component findComponent(java.lang.Class compCls,
                                               int index)
Deprecated. 2.02 Use new ComponentFinder(aClass).find(index);

Finds a component which is an instance of the given class by searching from all top level windows.

Parameters:
compCls - Component class
index - The index of the component. The first component matching the criteria will have index 0, the second 1, etc.
Returns:
Component Component found. Null if index components do not exist.

findComponent

public static java.awt.Component findComponent(java.lang.Class compCls,
                                               java.awt.Container cont,
                                               int index)
Deprecated. 2.02 Use new ComponentFinder(compCls).find(cont, index);

Finds a component which is an instance of the given class within a given container.

Parameters:
compCls - The class of the component.
cont - The container that the component will be in.
index - The index of the component. The first component matching the criteria will have index 0, the second 1, etc.
Returns:
The component that has been found (or null if none found).

findComponent

public static java.awt.Component findComponent(Finder finder,
                                               int index)
Deprecated. 2.02 Use finder.find(index);

Finds a component which is an instance of the given class by searching from all top level windows.

Parameters:
finder - Finder class to be used for locating components.
index - The index of the component. The first component matching the criteria will have index 0, the second 1, etc.
Returns:
Component Component found. Null if index components do not exist.

findComponent

public static java.awt.Component findComponent(Finder finder,
                                               java.awt.Container cont,
                                               int index)
Deprecated. 2.02 use finder.find(cont, index);

Finds a component matching the given criteria within a given container.

Parameters:
finder - The Finder that is used to test components for a match.
cont - The container that the component will be in.
index - The index of the component. The first component matching the criteria will have index 0, the second 1, etc.
Returns:
The component that has been found (or null if none found).

findNamedComponent

public static java.awt.Component findNamedComponent(java.lang.Class compCls,
                                                    int index)
Deprecated. 2.02 Use new ComponentFinder(compCls).find(cont, index);

Finds a component which is an instance of the given class by searching from all top level windows.

Parameters:
compCls - Component class
index - The index of the component. The first component matching the criteria will have index 0, the second 1, etc.
Returns:
Component Component found. Null if index components do not exist.

findNamedComponent

public static java.awt.Component findNamedComponent(java.lang.String name,
                                                    int index)
Deprecated. 2.02 Use new NamedComponentFinder(null,name).find(index);

Finds a indexed component which has the given name by searching from all top level windows.

Parameters:
name - The pattern for the name of the component to find.
index - The index of the component. The first component matching the criteria will have index 0, the second 1, etc.
Returns:
Component Component found. Null if index components do not exist.

findNamedComponent

public static java.awt.Component findNamedComponent(java.lang.Class compCls,
                                                    java.lang.String name,
                                                    int index)
Deprecated. 2.02 Use new NamedComponentFinder(compCls, name).find(index);

Finds a component which is an instance of the given class and has the given name by searching from all top level windows.

Parameters:
compCls - Component class
name - The pattern for the name of the component to find.
index - The index of the component. The first component matching the criteria will have index 0, the second 1, etc.
Returns:
Component Component found. Null if index components do not exist.

findNamedComponent

public static java.awt.Component findNamedComponent(java.lang.String name,
                                                    java.awt.Container cont,
                                                    int index)
Deprecated. 2.02 Use new NamedComponentFinder(null, name).find(cont, index);

Finds a component matching the given criteria within a given container.

Parameters:
name - The pattern for the name of the component to find.
cont - The container that the component will be in.
index - The index of the component. The first component matching the criteria will have index 0, the second 1, etc.
Returns:
The component that has been found (or null if none found).

findNamedComponent

public static java.awt.Component findNamedComponent(java.lang.Class aClass,
                                                    java.awt.Container cont,
                                                    int index)
Deprecated. 2.02 Use new NamedComponentFinder(aClass, null).find(cont, index);

Finds a component matching the given criteria within a given container.

Parameters:
aClass - The component's class.
cont - The container that the component will be in.
index - The index of the component. The first component matching the criteria will have index 0, the second 1, etc.
Returns:
The component that has been found (or null if none found).

findNamedComponent

public static java.awt.Component findNamedComponent(java.lang.Class aClass,
                                                    java.lang.String name,
                                                    java.awt.Container cont,
                                                    int index)
Deprecated. 2.02 Use new NamedComponentFinder(aClass, name).find(cont, index);

Finds a component matching the given criteria within a given container.

Parameters:
aClass - The component's class.
name - The pattern for the name of the component to find.
cont - The container that the component will be in.
index - The index of the component. The first component matching the criteria will have index 0, the second 1, etc.
Returns:
The component that has been found (or null if none found).

indexOf

public static int indexOf(Finder finder,
                          java.awt.Container cont,
                          java.awt.Component comp)
Find the index of the component given.

Parameters:
finder - Finder used for indexing.
cont - Container to look for the component in.
comp - Component to find the index of.
Returns:
Index of the component

setStep

public void setStep(int step)
Set the step size of mouse move events.

Parameters:
step - size in pixels.

getStep

public int getStep()
Returns the step size for the move events.

Returns:
int size in pixels.

enterClickAndLeave

public void enterClickAndLeave(AbstractMouseEventData evtData)
Helper method to fire appropriate events to click(s) a component with a custom wait method.

Parameters:
evtData - The event data container

enterDragAndLeave

public void enterDragAndLeave(AbstractMouseEventData srcEvtData,
                              AbstractMouseEventData dstEvtData,
                              int incr)
Helper method to fire appropriate events to drag and drop a component with a custom wait method. Note this will not work with java.awt.dnd API implementations. The java.awt.dnd implementation is driven from a level below the AWT EventQueue. Use the RobotTestHelper to work with java.awt.dnd.

Parameters:
srcEvtData - The source event data container
dstEvtData - The destination event data container
incr - Amount to increment the coords while "moving" from source to destination.

enterDragAndLeave

public void enterDragAndLeave(DragEventData ded)
Helper method to fire appropriate events to drag and drop a component with a custom wait method. Note this will not work with java.awt.dnd API implementations. The java.awt.dnd implementation is driven from a level below the AWT EventQueue. Use the RobotTestHelper to work with java.awt.dnd.

Parameters:
ded - The destination event data container

enterMouseWheel

public void enterMouseWheel(MouseWheelEventData evtData)
Enter a mouseWheel event.

Parameters:
evtData - MouseWheelEventData to be processed.

sendKeyAction

public void sendKeyAction(KeyEventData evtData)
This method is used to send KeyPressed, KeyTyped and KeyReleased events (in that order) to the specified component. This method should be used only to send Action key events. NOTE: This method will not call 'requestFocus()' on the component - the developer should include it in the test code if needed.

Parameters:
evtData - The event data container.

sendString

public void sendString(AbstractKeyEventData evtData)
This method is used to send KeyPressed, KeyTyped and KeyReleased events (in that order) to the specified component. This method can also differentiate between upper and lower case characters in the specified string. NOTE: This method will not call 'requestFocus()' on the component - the developer should include it in the test code if needed.

Parameters:
evtData - The event data container.

mouseToKeyModifiers

protected static int mouseToKeyModifiers(int modifiers)
Convert the modifiers from mouse modifiers to keyboard modifiers. ALT modifier overlaps with BUTTON2 and META overlaps with BUTTON3.

Parameters:
modifiers - The mouse modifiers that need to be converted.
Returns:
int The corresponding keyboard modifiers.

adjustModifiers

protected final void adjustModifiers(java.awt.Component ultimate,
                                     int modifiers,
                                     int newModifiers)
Send the modifier key release event for the modifiers.

Parameters:
ultimate - Component to receive the events.
modifiers - The modifiers to be released.
newModifiers - The new modifiers which should be pressed.

pressModifiers

protected final void pressModifiers(java.awt.Component ultimate,
                                    int modifiers)
Send the modifier key press event for the modifiers.

Parameters:
ultimate - Component to receive the events.
modifiers - The modifiers to be pressed.

releaseModifiers

protected final void releaseModifiers(java.awt.Component ultimate,
                                      int modifiers)
Send the modifier key release event for the modifiers.

Parameters:
ultimate - Component to receive the events.
modifiers - The modifiers to be released.

isBounded

protected static boolean isBounded(int val,
                                   int vMin,
                                   int vMax)
Check to see if the value is bounded by the min and max.

Parameters:
val - Value to be checked.
vMin - minimum value of range.
vMax - maximum value of range.
Returns:
true if the value is between vMin and vMax.

keyPressed

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

Parameters:
ultimate - The ultimate parent Component
stroke - The JFCKeyStroke to be performed.

keyReleased

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

Parameters:
ultimate - The ultimate parent Component
stroke - The JFCKeyStroke to be performed.

mouseMoved

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

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 abstract void mousePressed(java.awt.Component ultimate,
                                     int modifiers,
                                     int click,
                                     boolean isPopupTrigger)
Process a mouse press event on a component.

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 abstract void mouseReleased(java.awt.Component ultimate,
                                      int modifiers,
                                      int click,
                                      boolean isPopupTrigger)
Process a mouse release event on a component.

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 abstract void mouseWheel(java.awt.Component ultimate,
                                   int amount,
                                   int rotation)
Simulate rotating the mouseWheel.

Parameters:
ultimate - Component to fire the events on.
amount - Amount to scroll for each rotation.
rotation - clicks to rotate the mouse wheel.

getDir

private static int getDir(int src,
                          int dest)
Calculate the direction of travel given the src and dest point.

Parameters:
src - Source
dest - Destination
Returns:
-1 if dest < src, 0 if dest = src, and 1 if dest > src


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