junit.extensions.jfcunit.eventdata
Class KeyTagHandler

java.lang.Object
  extended byjunit.extensions.xml.elements.AbstractTagHandler
      extended byjunit.extensions.jfcunit.eventdata.KeyTagHandler
All Implemented Interfaces:
EventDataConstants, JFCXMLConstants, XMLConstants

public class KeyTagHandler
extends AbstractTagHandler
implements JFCXMLConstants

This class will handle the processing of <key> nodes.

Description

This element will be used to submit key codes and strings to a component.

Parameters

Attribute Description Required Default Values
refid Id of a object reference which has been previously found. Yes N/A N/A
string The string to be entered. One string or code attribute is required empty string Any characters
code The key code to be entered. One string or code attribute is required None The key codes to use should follow the VK_(codes) of KeyEventData. Ex: VK_F4
modifiers The modifiers to be used for this event. No None Alt Altgr Ctrl Meta Shift
sleeptime Maximum sleep time No 500 Positive Integer representing the milli-seconds

Example

 <key
    refid="FileMenuItem"
    code="VK_F2"
    modifiers="Shift"
 />
 
 <key
    refid="FileMenuItem"
    code="VK_F2"
    modifiers="Ctrl+Shift"
 />
 

The above simulates pressing shift F2.

Author:
Kevin Wilson, Vijay Aravamudhan : ThoughtWorks Inc.
See Also:
KeyEventData

Field Summary
 
Fields inherited from class junit.extensions.xml.elements.AbstractTagHandler
 
Fields inherited from interface junit.extensions.jfcunit.xml.JFCXMLConstants
ALT, ALTGR, AMOUNT, ASSERTEXIT, AWTTHREAD, BUTTON1, BUTTON2, BUTTON3, CASEINDEPENDENT, CLASS, CLICK, CLICKS, CODE, CONTAINER, CONTAINS, CTRL, DESTINATION, DOWN, DRAG, DURATION, EDITOR, ENDSWITH, EQUALS, FIND, FINDER, FLUSH, ICONDESCRIPTION, ICONFILE, INDEXDELIMITER, INDEXES, KEY, LABEL, MATCH, META, MODIFIERS, NODEVALUE, OPERATION, PATH, PATHDELIMITER, PAUSE, POINT, POPUPTRIGGER, POSITION, RECORDING, REFERENCE, RESUME, ROBOT, ROTATION, SHIFT, SHOW, SLEEP, SLEEPTIME, SOURCE, STARTSWITH, STRING, SUBCOMPONENT, TERMINATOR, TITLE, UP, WAIT
 
Fields inherited from interface junit.extensions.xml.XMLConstants
ACTION, ACTUALOBJ, ACTUALREFID, ADD, ASSERTENABLED, ASSERTEQUALS, ASSERTNOTEQUALS, ASSERTNOTNULL, ASSERTNOTSAME, ASSERTNULL, ASSERTSAME, CALL, CASE, CHOOSE, CLASSNAME, COLUMN, CONFIRM, DEBUG, DEFAULT, DELIMITER, DIALOG, DUMP, ECHO, ENABLED, ENCODING, EVALUATE, EXPECTEDOBJ, EXPECTEDREFID, FAIL, FILE, FOCUS, FOREACH, ID, INDEX, JFCFILELOC, LESSTHAN, LISTITEM, LOG, MARK, MESSAGE, METHOD, MODE, NAME, OTHERWISE, PATHREFID, PROCEDURE, PROPERTY, RECURSIVE, REFID, RELATIVE, REMOVE, ROW, SAVE, STDERR, STDOUT, STOPWATCH, SUITE, SWITCH, TABLECELL, TAGHANDLERS, TAGNAME, TEST, TYPE, USERE, VALUE, WHEN, WHILE
 
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
KeyTagHandler(org.w3c.dom.Element element, IXMLTestCase testCase)
          Constructor for FindTagHandler.
 
Method Summary
private  int getCharacter()
          Returns the value of the CODE attribute for this element.
private  int getModifiers()
          Returns the value of the MODIFIERS attribute for this element.
protected  int getModifiers(int defaultValue)
          Returns the value of the MODIFIERS attribute for this element.
private  java.lang.String getRefId()
          Returns the value of the REFID attribute for this element.
protected  long getSleepTime()
          Returns the value of the SLEEPTIME attribute for this element.
 void processElement()
          Submit the keystrokes specified by the event.
 void validateElement()
          Validate that the refid attribute is specified and either code or string attributes are specified.
 
Methods inherited from class junit.extensions.xml.elements.AbstractTagHandler
checkAtLeastOneRequiredAttribute, checkAtLeastOneRequiredAttribute, checkElementTagName, checkOneRequiredAttribute, checkOneRequiredAttribute, checkRequiredAttribute, checkRequiredAttribute, getBoolean, getBoolean, getBoolean, getBoolean, getElement, getInt, getInt, getLong, getLong, getPoint, getPoint, getString, getString, getString, getString, getTagName, getTest, getTestCase, getXMLTestCase, getXMLTestSuite, resolveVariables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyTagHandler

public KeyTagHandler(org.w3c.dom.Element element,
                     IXMLTestCase testCase)
Constructor for FindTagHandler.

Parameters:
element - The element to be processed
testCase - The IXMLTestCase that uses this element
Method Detail

processElement

public void processElement()
                    throws XMLException
Submit the keystrokes specified by the event.

Specified by:
processElement in class AbstractTagHandler
Throws:
XMLException - may be thrown.

validateElement

public void validateElement()
                     throws XMLException
Validate that the refid attribute is specified and either code or string attributes are specified.

Overrides:
validateElement in class AbstractTagHandler
Throws:
XMLException - if the refid is missing or (code and string) attributes are not present.

getModifiers

protected int getModifiers(int defaultValue)
Returns the value of the MODIFIERS attribute for this element. Defaults to defaultValue.

Parameters:
defaultValue - value to be returned if the element does not exist.
Returns:
int The value of the MODIFIERS attribute, defaultValue if not specified.

getSleepTime

protected long getSleepTime()
Returns the value of the SLEEPTIME attribute for this element. Defaults to DEFAULT_SLEEPTIME.

Returns:
String The value of the SLEEPTIME attribute, DEFAULT_SLEEPTIME if not specified.

getCharacter

private int getCharacter()
Returns the value of the CODE attribute for this element.

Returns:
String The value of the CODE attribute.

getModifiers

private int getModifiers()
Returns the value of the MODIFIERS attribute for this element. Defaults to zero.

Returns:
int The value of the MODIFIERS attribute, zero if not specified.

getRefId

private java.lang.String getRefId()
Returns the value of the REFID attribute for this element.

Returns:
String The value of the REFID attribute.


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