junit.extensions.jfcunit.eventdata
Class KeyEventData

java.lang.Object
  extended byjunit.extensions.jfcunit.eventdata.AbstractEventData
      extended byjunit.extensions.jfcunit.eventdata.AbstractKeyEventData
          extended byjunit.extensions.jfcunit.eventdata.KeyEventData
All Implemented Interfaces:
EventDataConstants

public class KeyEventData
extends AbstractKeyEventData

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

Author:
Vijay Aravamudhan : ThoughtWorks Inc.

Field Summary
private  java.awt.Component m_comp
          The component to be fired upon.
private  int m_keyCode
          The key code to be fired.
 
Fields inherited from class junit.extensions.jfcunit.eventdata.AbstractKeyEventData
 
Fields inherited from class junit.extensions.jfcunit.eventdata.AbstractEventData
 
Fields inherited from interface junit.extensions.jfcunit.eventdata.EventDataConstants
CENTER, CUSTOM, DEFAULT_HOLDTIME, DEFAULT_ISPOPUPTRIGGER, 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
KeyEventData()
          Default Constructor.
KeyEventData(JFCTestCase testCase, java.awt.Component comp, int keyCode)
          Constructor.
KeyEventData(JFCTestCase testCase, java.awt.Component comp, int keyCode, int modifiers, long sleepTime)
          Constructor.
KeyEventData(JFCTestCase testCase, java.awt.Component comp, int keyCode, long sleepTime)
          Constructor.
 
Method Summary
 boolean canConsume(java.awt.AWTEvent ae)
          Check if this event can consume the AWTEvent.
 boolean consume(java.awt.AWTEvent ae)
          Consume the event.
 java.awt.Component getComponent()
          The component on which the event has to be fired.
 int getKeyCode()
          Get the key code to be sent.
 java.awt.Component getSource()
          Get the attribute value.
 void populate(org.w3c.dom.Element e)
          Populate the element with the key code.
 void setKeyCode(int keyCode)
          Set the key code to be sent.
 void setSource(java.awt.Component comp)
          Set the attribute value.
protected  void setupKeyStrokes()
          Setup the keystrokes for the event.
 java.lang.String toString()
          Generate a description of the event.
 
Methods inherited from class junit.extensions.jfcunit.eventdata.AbstractKeyEventData
addKeyStrokes, applyModifier, clearKeyStrokes, equals, getDefaultModifiers, getKeyMapping, getKeyStrokes, getModifierText, hashCode, prepareComponent, setKeyMapping, setModifiers
 
Methods inherited from class junit.extensions.jfcunit.eventdata.AbstractEventData
calculatePoint, getDefaultPosition, getDefaultSleepTime, getLocationOnScreen, getModifiers, getPosition, getReferencePoint, getRoot, getRoot, getSleepTime, getTestCase, isMetaChar, isValid, isValidForProcessing, setLocationOnScreen, setPosition, setReferencePoint, setSleepTime, setTestCase, setValid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_comp

private java.awt.Component m_comp
The component to be fired upon.


m_keyCode

private int m_keyCode
The key code to be fired.

Constructor Detail

KeyEventData

public KeyEventData()
Default Constructor.


KeyEventData

public KeyEventData(JFCTestCase testCase,
                    java.awt.Component comp,
                    int keyCode)
Constructor.

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

KeyEventData

public KeyEventData(JFCTestCase testCase,
                    java.awt.Component comp,
                    int keyCode,
                    long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
keyCode - The key to be sent to the component
sleepTime - The wait time in ms between each event.

KeyEventData

public KeyEventData(JFCTestCase testCase,
                    java.awt.Component comp,
                    int keyCode,
                    int modifiers,
                    long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comp - The component on which to trigger the event.
keyCode - The key to be sent to the component
modifiers - The modifier key values that need to be passed onto the event.
sleepTime - The wait time in ms between each event.
Method Detail

setKeyCode

public final void setKeyCode(int keyCode)
Set the key code to be sent.

Parameters:
keyCode - Key code.

getKeyCode

public final int getKeyCode()
Get the key code to be sent.

Returns:
int key code to be sent.

setSource

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

Parameters:
comp - The new value of the attribute

getSource

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

Returns:
Component The value of the attribute.

getComponent

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

Specified by:
getComponent in class AbstractEventData
Returns:
The component.

canConsume

public boolean canConsume(java.awt.AWTEvent ae)
Check if this event can consume the AWTEvent.

Overrides:
canConsume in class AbstractKeyEventData
Parameters:
ae - Event to be consumed.
Returns:
boolean true if the event can be consumed.

consume

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

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

populate

public void populate(org.w3c.dom.Element e)
Populate the element with the key code.

Overrides:
populate in class AbstractEventData
Parameters:
e - Element to be populated with the data for this event.

toString

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

Overrides:
toString in class AbstractEventData
Returns:
String description of the event.

setupKeyStrokes

protected void setupKeyStrokes()
Setup the keystrokes for the event.

Specified by:
setupKeyStrokes in class AbstractKeyEventData


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