|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
MouseWheelEventDataTagHandler.java | - | 100% | 100% | 100% |
|
1 |
package junit.extensions.jfcunit.eventdata;
|
|
2 |
|
|
3 |
import junit.extensions.xml.IXMLTestCase;
|
|
4 |
import junit.extensions.xml.XMLException;
|
|
5 |
|
|
6 |
import org.w3c.dom.Element;
|
|
7 |
|
|
8 |
|
|
9 |
/**
|
|
10 |
* This element implements the mouse wheel movement.
|
|
11 |
*
|
|
12 |
* <h3>Description</h3>
|
|
13 |
* <p>
|
|
14 |
* Invokes the junit.extensions.jfcunit.TestHelper.mouseWheel() method
|
|
15 |
* with the parameters given by this element.
|
|
16 |
* </p>
|
|
17 |
* <p>
|
|
18 |
* To use the wheel task, set the <i>refid</i> attribute to the name of the
|
|
19 |
* component which has been found.
|
|
20 |
* </p>
|
|
21 |
*
|
|
22 |
* <h3>Parameters</h3>
|
|
23 |
* <table border="1" cellpadding="2" cellspacing="0">
|
|
24 |
* <tr>
|
|
25 |
* <td valign="top"><b>Attribute</b></td>
|
|
26 |
* <td valign="top"><b>Description</b></td>
|
|
27 |
* <td align="center" valign="top"><b>Required</b></td>
|
|
28 |
* <td valign="top"><b>Default</b></td>
|
|
29 |
* </tr>
|
|
30 |
* <tr>
|
|
31 |
* <td valign="top">refid</td>
|
|
32 |
* <td valign="top">Id of a object reference which has been previously found.</td>
|
|
33 |
* <td valign="top" align="center">Yes</td>
|
|
34 |
* <td valign="top">N/A</td>
|
|
35 |
* </tr>
|
|
36 |
* <tr>
|
|
37 |
* <td valign="top">amount</td>
|
|
38 |
* <td valign="top">The number of units that should be scrolled in response to this event.</td>
|
|
39 |
* <td valign="top" align="center">No</td>
|
|
40 |
* <td valign="top">3</td>
|
|
41 |
* </tr>
|
|
42 |
* <tr>
|
|
43 |
* <td valign="top">rotation</td>
|
|
44 |
* <td valign="top">The number of "clicks" the mouse wheel was rotated.</td>
|
|
45 |
* <td valign="top" align="center">No</td>
|
|
46 |
* <td valign="top">1</td>
|
|
47 |
* </tr>
|
|
48 |
*
|
|
49 |
* </table>
|
|
50 |
* <h3>Example</h3>
|
|
51 |
* <blockquote><pre>
|
|
52 |
* <wheel
|
|
53 |
* refid="ScrollPane"
|
|
54 |
* amount="3"
|
|
55 |
* rotation="50"
|
|
56 |
* />
|
|
57 |
* </pre></blockquote>
|
|
58 |
* @see junit.extensions.jfcunit.eventdata.MouseWheelEventData
|
|
59 |
* @author Kevin Wilson
|
|
60 |
*/
|
|
61 |
public class MouseWheelEventDataTagHandler extends BaseEventDataTagHandler { |
|
62 |
/**
|
|
63 |
* Constructor for MouseWheelEventDataTagHandler.
|
|
64 |
*
|
|
65 |
* @param element The element to be processed
|
|
66 |
* @param testCase The IXMLTestCase that uses this element
|
|
67 |
*/
|
|
68 | 6 |
public MouseWheelEventDataTagHandler(final Element element,
|
69 |
final IXMLTestCase testCase) { |
|
70 | 6 |
super(element, testCase);
|
71 |
} |
|
72 |
|
|
73 |
/**
|
|
74 |
* @see junit.extensions.xml.elements.AbstractTagHandler#processElement()
|
|
75 |
*/
|
|
76 | 6 |
public void processElement() throws XMLException { |
77 | 6 |
validateElement(); |
78 |
|
|
79 | 6 |
MouseWheelEventData event = new MouseWheelEventData(
|
80 |
getJFCTestCase(), |
|
81 |
getComponent(), |
|
82 |
getAmount(), |
|
83 |
getRotation(), |
|
84 |
getClicks(), |
|
85 |
getModifiers(), |
|
86 |
getPopupTrigger(), |
|
87 |
getSleepTime(), |
|
88 |
getPosition(), |
|
89 |
getReference()); |
|
90 | 6 |
getJFCTestCase().getHelper().enterMouseWheel(event); |
91 |
} |
|
92 |
|
|
93 |
/**
|
|
94 |
* @see junit.extensions.xml.elements.AbstractTagHandler#validateElement()
|
|
95 |
*/
|
|
96 | 6 |
public void validateElement() throws XMLException { |
97 |
// do the default validations from the super class
|
|
98 | 6 |
super.validateElement();
|
99 |
} |
|
100 |
|
|
101 |
/**
|
|
102 |
* Get the number of clicks. Default for number of clicks
|
|
103 |
* is zero for mouse wheel events.
|
|
104 |
*
|
|
105 |
* @return int number of clicks.
|
|
106 |
*/
|
|
107 | 6 |
protected int getClicks() { |
108 | 6 |
return getInt(CLICKS, 0);
|
109 |
} |
|
110 |
|
|
111 |
/**
|
|
112 |
* Get the modifiers for the mouse wheel event.
|
|
113 |
* Default modifiers is Zero.
|
|
114 |
* @return int modifiers.
|
|
115 |
* @see java.awt.event.MouseEvent for modifiers.
|
|
116 |
*/
|
|
117 | 6 |
protected int getModifiers() { |
118 |
// Default clicks for this method should be zero.
|
|
119 | 6 |
return getModifiers(0);
|
120 |
} |
|
121 |
|
|
122 |
/**
|
|
123 |
* Get the amount from the XML.
|
|
124 |
* @return int amount to be scrolled.
|
|
125 |
*/
|
|
126 | 6 |
private int getAmount() { |
127 | 6 |
return getInt(AMOUNT, DEFAULT_SCROLL_AMOUNT);
|
128 |
} |
|
129 |
|
|
130 |
/**
|
|
131 |
* Get the rotation of the wheel from the XML.
|
|
132 |
* @return int rotation of the mouse wheel.
|
|
133 |
*/
|
|
134 | 6 |
private int getRotation() { |
135 | 6 |
return getInt(ROTATION, DEFAULT_WHEEL_ROTATION);
|
136 |
} |
|
137 |
} |
|
138 |
|
|