|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
JComboBoxMouseEventDataTagHandler.java | - | 87.5% | 100% | 91.7% |
|
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 |
import javax.swing.JComboBox;
|
|
9 |
|
|
10 |
|
|
11 |
/**
|
|
12 |
* This is a extension of the click and drag elements. Where the
|
|
13 |
* type specified is JComboMouseEventData.
|
|
14 |
*
|
|
15 |
* <h3>Description</h3>
|
|
16 |
* <p>
|
|
17 |
* Nothing is invoked directly by this tag handler. The click and drag elements
|
|
18 |
* use this tag handler to customize the data specificly for the type specified.
|
|
19 |
* </p>
|
|
20 |
* <p>
|
|
21 |
* For now this class requires the index. It does not yet provide methods for
|
|
22 |
* searching for tabs based upon the text or icon contained. These are left
|
|
23 |
* for future enhancements.
|
|
24 |
* </p>
|
|
25 |
*
|
|
26 |
* <h3>Parameters</h3>
|
|
27 |
* <table border="1" cellpadding="2" cellspacing="0">
|
|
28 |
* <tr>
|
|
29 |
* <td valign="top"><b>Attribute</b></td>
|
|
30 |
* <td valign="top"><b>Description</b></td>
|
|
31 |
* <td align="center" valign="top"><b>Required</b></td>
|
|
32 |
* <td valign="top"><b>Default</b></td>
|
|
33 |
* <td valign="top"><b>Values</b></td>
|
|
34 |
* </tr>
|
|
35 |
* <tr>
|
|
36 |
* <td valign="top">type</td>
|
|
37 |
* <td valign="top">For this element the type must be set to MouseEventData</td>
|
|
38 |
* <td valign="top" align="center">Yes</td>
|
|
39 |
* <td valign="top">N/A</td>
|
|
40 |
* <td valign="top">N/A</td>
|
|
41 |
* </tr>
|
|
42 |
* <tr>
|
|
43 |
* <td valign="top">refid</td>
|
|
44 |
* <td valign="top">Id of a object reference which has been previously found.</td>
|
|
45 |
* <td valign="top" align="center">Yes</td>
|
|
46 |
* <td valign="top">N/A</td>
|
|
47 |
* <td valign="top">N/A</td>
|
|
48 |
* </tr>
|
|
49 |
* <tr>
|
|
50 |
* <td valign="top">index</td>
|
|
51 |
* <td valign="top">The index of the element to select from the combo box.</td>
|
|
52 |
* <td valign="top" align="center">Yes</td>
|
|
53 |
* <td valign="top">N/A</td>
|
|
54 |
* <td valign="top">Zero based index of list items.</td>
|
|
55 |
* </tr>
|
|
56 |
* <tr>
|
|
57 |
* <td valign="top">clicks</td>
|
|
58 |
* <td valign="top">The number of clicks to be executed.</td>
|
|
59 |
* <td valign="top" align="center">No</td>
|
|
60 |
* <td valign="top">1</td>
|
|
61 |
* <td valign="top">Positive Integer</td>
|
|
62 |
* </tr>
|
|
63 |
* <tr>
|
|
64 |
* <td valign="top">modifiers</td>
|
|
65 |
* <td valign="top">The modifiers to be used for this event.</td>
|
|
66 |
* <td valign="top" align="center">No</td>
|
|
67 |
* <td valign="top">Button1 if popup is false otherwise Button3</td>
|
|
68 |
* <td valign="top">alt altgr control meta shift button1 button2 button3</td>
|
|
69 |
* </tr>
|
|
70 |
* <tr>
|
|
71 |
* <td valign="top">popup</td>
|
|
72 |
* <td valign="top">True if this is event is using the popup button.</td>
|
|
73 |
* <td valign="top" align="center">No</td>
|
|
74 |
* <td valign="top">false</td>
|
|
75 |
* <td valign="top">true false</td>
|
|
76 |
* </tr>
|
|
77 |
* <tr>
|
|
78 |
* <td valign="top">sleeptime</td>
|
|
79 |
* <td valign="top">Maximum sleep time</td>
|
|
80 |
* <td valign="top" align="center">No</td>
|
|
81 |
* <td valign="top">500</td>
|
|
82 |
* <td valign="top">Positive Integer representing the milli-seconds</td>
|
|
83 |
* </tr>
|
|
84 |
* <tr>
|
|
85 |
* <td valign="top">position</td>
|
|
86 |
* <td valign="top">Positioning of the mouse within the bounds of the component.</td>
|
|
87 |
* <td valign="top" align="center">No</td>
|
|
88 |
* <td valign="top">center</td>
|
|
89 |
* <td valign="top">center north northeast east southeast south southwest west northwest custom percentage</td>
|
|
90 |
* </tr>
|
|
91 |
* <tr>
|
|
92 |
* <td valign="top">reference</td>
|
|
93 |
* <td valign="top">Reference point or number for position calculation.</td>
|
|
94 |
* <td valign="top" align="center">No</td>
|
|
95 |
* <td valign="top">null</td>
|
|
96 |
* <td valign="top">integers "x,y"</td>
|
|
97 |
* </tr>
|
|
98 |
*
|
|
99 |
* </table>
|
|
100 |
* <h3>Example</h3>
|
|
101 |
* <blockquote><pre>
|
|
102 |
* <click
|
|
103 |
* type="JComboBoxMouseEventData"
|
|
104 |
* refid="Combo"
|
|
105 |
* index="1"
|
|
106 |
* />
|
|
107 |
* </pre></blockquote>
|
|
108 |
* <p>
|
|
109 |
* The above clicks once on the center of the component identified by
|
|
110 |
* Combo.
|
|
111 |
* </p>
|
|
112 |
* @see junit.extensions.jfcunit.eventdata.JComboBoxMouseEventData
|
|
113 |
* @author Kevin Wilson
|
|
114 |
*/
|
|
115 |
public class JComboBoxMouseEventDataTagHandler extends BaseEventDataTagHandler { |
|
116 |
/**
|
|
117 |
* Constructor for JComboBoxMouseEventDataTagHandler.
|
|
118 |
*
|
|
119 |
* @param element The element to be processed
|
|
120 |
* @param testCase The IXMLTestCase that uses this element
|
|
121 |
*/
|
|
122 | 80 |
public JComboBoxMouseEventDataTagHandler(final Element element,
|
123 |
final IXMLTestCase testCase) { |
|
124 | 80 |
super(element, testCase);
|
125 |
} |
|
126 |
|
|
127 |
/**
|
|
128 |
* @see junit.extensions.xml.elements.AbstractTagHandler#processElement()
|
|
129 |
* @throws XMLException when the syntax is incorrect.
|
|
130 |
*/
|
|
131 | 80 |
public void processElement() throws XMLException { |
132 | 80 |
validateElement(); |
133 |
|
|
134 | 80 |
setEventData( |
135 |
new JComboBoxMouseEventData(
|
|
136 |
getJFCTestCase(), |
|
137 |
(JComboBox) getComponent(), |
|
138 |
getIndex(), |
|
139 |
getClicks(), |
|
140 |
getModifiers(), |
|
141 |
getPopupTrigger(), |
|
142 |
getSleepTime(), |
|
143 |
getPosition(), |
|
144 |
getReference())); |
|
145 |
} |
|
146 |
|
|
147 |
/**
|
|
148 |
* @throws XMLException when the syntax is incorrect.
|
|
149 |
* @see junit.extensions.xml.elements.AbstractTagHandler#validateElement()
|
|
150 |
*/
|
|
151 | 80 |
public void validateElement() throws XMLException { |
152 |
// do the default validations from the super class
|
|
153 | 80 |
super.validateElement();
|
154 |
|
|
155 |
/**
|
|
156 |
* @todo Should be able to find the object to select.
|
|
157 |
* For now we will require the index.
|
|
158 |
* index into combo box.
|
|
159 |
*/
|
|
160 | 80 |
checkRequiredAttribute(INDEX); |
161 |
} |
|
162 |
|
|
163 |
/**
|
|
164 |
* Returns the value of the INDEX attribute for this element. Defaults to 0 (zero) if not found.
|
|
165 |
* @return int The value of the parsed INDEX attribute, zero if not found.
|
|
166 |
*/
|
|
167 | 80 |
private int getIndex() { |
168 | 80 |
try {
|
169 | 80 |
return getInt(INDEX, 0);
|
170 |
} catch (NumberFormatException e) {
|
|
171 | 0 |
throw new NumberFormatException("Index not formatted properly"); |
172 |
} |
|
173 |
} |
|
174 |
} |
|
175 |
|
|