junit.extensions.jfcunit.eventdata
Class MouseWheelEventData

java.lang.Object
  extended byjunit.extensions.jfcunit.eventdata.AbstractEventData
      extended byjunit.extensions.jfcunit.eventdata.AbstractMouseEventData
          extended byjunit.extensions.jfcunit.eventdata.MouseEventData
              extended byjunit.extensions.jfcunit.eventdata.MouseWheelEventData
All Implemented Interfaces:
EventDataConstants

public class MouseWheelEventData
extends MouseEventData

Data container class that holds all the data necessary for jfcUnit to fire mouse events.

Author:
Vijay Aravamudhan : ThoughtWorks Inc.

Field Summary
static int DEFAULT_MOUSE_CLICKS
          The amount to scroll by default.
private  java.awt.Component m_comp
          The Component on which to trigger the event.
private  int m_scrollAmount
          Amount to scroll for each wheel rotation.
private  int m_wheelRotation
          Number of wheel clicks to rotate.
private static java.lang.reflect.Method s_getScrollAmountMethod
          Method for getting the scroll amount from the event.
private static java.lang.reflect.Method s_getWheelRotationMethod
          Method for getting the rotation of the mouse from the event.
private static int s_mouseWheelEvent
          MouseWheelEvent event id.
private static java.lang.Class s_mweClass
          Class of the MouseWheelEvent.
 
Fields inherited from class junit.extensions.jfcunit.eventdata.MouseEventData
DEFAULT_ISPOPUPTRIGGER
 
Fields inherited from class junit.extensions.jfcunit.eventdata.AbstractMouseEventData
 
Fields inherited from class junit.extensions.jfcunit.eventdata.AbstractEventData
 
Fields inherited from interface junit.extensions.jfcunit.eventdata.EventDataConstants
CENTER, CUSTOM, DEFAULT_HOLDTIME, DEFAULT_KEY_MODIFIERS, DEFAULT_MOUSE_MODIFIERS, DEFAULT_NUMBEROFCLICKS, DEFAULT_POPUP_MODIFIERS, DEFAULT_POSITION, DEFAULT_SCROLL_AMOUNT, DEFAULT_SLEEPTIME, DEFAULT_WHEEL_ROTATION, DOWN_ARROW_SUBCOMPONENT, EAST, EDITOR_SUBCOMPONENT, INVALID_SUBCOMPONENT, INVALID_TEXT_OFFSET, NORTH, NORTH_EAST, NORTH_WEST, OFFSET, PERCENT, POSITIONSTRINGS, SOUTH, SOUTH_EAST, SOUTH_WEST, UP_ARROW_SUBCOMPONENT, WEST
 
Constructor Summary
MouseWheelEventData()
          Default Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int wheelRotation)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation, int numberOfClicks)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation, int numberOfClicks, boolean isPopupTrigger)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation, int numberOfClicks, boolean isPopupTrigger, long sleepTime)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation, int numberOfClicks, int modifiers)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation, int numberOfClicks, int modifiers, boolean isPopupTrigger)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, int position)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, int position, java.awt.Point referencePoint)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, java.awt.Point referencePoint)
          Constructor.
MouseWheelEventData(JFCTestCase testCase, java.awt.Component comp, int amount, int wheelRotation, int numberOfClicks, long sleepTime)
          Constructor.
 
Method Summary
 boolean canConsume(java.awt.AWTEvent ae)
          Returns true if the event can be consumed by this instnace of event data.
 boolean consume(java.awt.AWTEvent ae)
          Consume the event.
 boolean equals(java.lang.Object o)
          Compare to event data and deterime if they are equal.
 java.awt.Component getComponent()
          The component on which the event has to be fired.
 int getScrollAmount()
          Get the scroll amount.
 java.awt.Component getSource()
          Get the attribute value.
 int getWheelRotation()
          Get the wheel rotation.
 int hashCode()
          Get the hashCode for this object.
 boolean prepareComponent()
          Prepare the component for firing the mouse event.
 void setScrollAmount(int scrollAmount)
          Set the scroll amount.
 void setSource(java.awt.Component comp)
          Set the attribute value.
 void setWheelRotation(int wheelRotation)
          Set the wheel rotation.
 java.lang.String toString()
          Generate a string representation of the event.
 
Methods inherited from class junit.extensions.jfcunit.eventdata.MouseEventData
insureVisibleLocation, populate
 
Methods inherited from class junit.extensions.jfcunit.eventdata.AbstractMouseEventData
getDefaultModifiers, getDefaultModifiers, getDefaultNumberOfClicks, getDefaultPopupTrigger, getModifierText, getNumberOfClicks, getPopupTrigger, sameSource, setNumberOfClicks, setPopupTrigger
 
Methods inherited from class junit.extensions.jfcunit.eventdata.AbstractEventData
calculatePoint, getDefaultPosition, getDefaultSleepTime, getLocationOnScreen, getModifiers, getPosition, getReferencePoint, getRoot, getRoot, getSleepTime, getTestCase, isMetaChar, isValid, isValidForProcessing, setLocationOnScreen, setModifiers, setPosition, setReferencePoint, setSleepTime, setTestCase, setValid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MOUSE_CLICKS

public static final int DEFAULT_MOUSE_CLICKS
The amount to scroll by default.

See Also:
Constant Field Values

s_mouseWheelEvent

private static int s_mouseWheelEvent
MouseWheelEvent event id.


s_mweClass

private static java.lang.Class s_mweClass
Class of the MouseWheelEvent. Used so that the code is backward compatible.


s_getWheelRotationMethod

private static java.lang.reflect.Method s_getWheelRotationMethod
Method for getting the rotation of the mouse from the event. Used so that the code is backward compatible.


s_getScrollAmountMethod

private static java.lang.reflect.Method s_getScrollAmountMethod
Method for getting the scroll amount from the event. Used so that the code is backward compatible.


m_comp

private java.awt.Component m_comp
The Component on which to trigger the event.


m_scrollAmount

private int m_scrollAmount
Amount to scroll for each wheel rotation.


m_wheelRotation

private int m_wheelRotation
Number of wheel clicks to rotate.

Constructor Detail

MouseWheelEventData

public MouseWheelEventData()
Default Constructor.


MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int wheelRotation)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation,
                           int numberOfClicks)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation,
                           int numberOfClicks,
                           int modifiers)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation,
                           int numberOfClicks,
                           boolean isPopupTrigger)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
isPopupTrigger - boolean specifying whether this event will show a popup.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation,
                           int numberOfClicks,
                           long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
sleepTime - The wait time in ms between each event.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation,
                           int numberOfClicks,
                           boolean isPopupTrigger,
                           long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime,
                           int position)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.
position - The relative mouse position within the cell.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime,
                           java.awt.Point referencePoint)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.
referencePoint - The CUSTOM mouse position within the cell.

MouseWheelEventData

public MouseWheelEventData(JFCTestCase testCase,
                           java.awt.Component comp,
                           int amount,
                           int wheelRotation,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime,
                           int position,
                           java.awt.Point referencePoint)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
amount - The amount to scroll for each rotation.
wheelRotation - The amount to rotate the wheel positive for values towards the user. Negative for away from the user.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.
position - The relative mouse position within the cell.
referencePoint - If position is CUSTOM then the point is a offset from the location of the component. If the position is PERCENT then the location is a percentage offset of the hight and width. Otherwise, the referencePoint is unused.
Method Detail

setSource

public final void setSource(java.awt.Component comp)
Set the attribute value.

Overrides:
setSource in class MouseEventData
Parameters:
comp - The new value of the attribute.

getSource

public final java.awt.Component getSource()
Get the attribute value.

Overrides:
getSource in class MouseEventData
Returns:
Component The value of the attribute.

getComponent

public java.awt.Component getComponent()
The component on which the event has to be fired.

Overrides:
getComponent in class MouseEventData
Returns:
The component.

setScrollAmount

public final void setScrollAmount(int scrollAmount)
Set the scroll amount.

Parameters:
scrollAmount - Amount to scroll for each wheel click.

getScrollAmount

public final int getScrollAmount()
Get the scroll amount.

Returns:
int scroll amount.

setWheelRotation

public final void setWheelRotation(int wheelRotation)
Set the wheel rotation.

Parameters:
wheelRotation - amount to rotate the wheel.

getWheelRotation

public final int getWheelRotation()
Get the wheel rotation.

Returns:
int number of wheel rotations.

canConsume

public boolean canConsume(java.awt.AWTEvent ae)
Returns true if the event can be consumed by this instnace of event data.

Overrides:
canConsume in class MouseEventData
Parameters:
ae - Event to be consumed.
Returns:
true if the event was consumed.

consume

public boolean consume(java.awt.AWTEvent ae)
Consume the event.

Overrides:
consume in class MouseEventData
Parameters:
ae - AWTEvent to be consumed.
Returns:
boolean true if the event was consumed.

equals

public boolean equals(java.lang.Object o)
Compare to event data and deterime if they are equal.

Overrides:
equals in class MouseEventData
Parameters:
o - Object to be compared.
Returns:
true if the events are the same.

hashCode

public int hashCode()
Get the hashCode for this object.

Overrides:
hashCode in class MouseEventData
Returns:
int hashCode.

prepareComponent

public boolean prepareComponent()
Prepare the component for firing the mouse event.

Overrides:
prepareComponent in class MouseEventData
Returns:
boolean true if the component is ready.

toString

public java.lang.String toString()
Generate a string representation of the event.

Overrides:
toString in class AbstractMouseEventData
Returns:
String form of the event data.


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