|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AbstractButtonFinderTagHandler.java | - | 100% | 100% | 100% |
|
1 |
package junit.extensions.jfcunit.finder;
|
|
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.Icon;
|
|
9 |
|
|
10 |
|
|
11 |
/**
|
|
12 |
* This is a extension of the findTagHandler element. Where the
|
|
13 |
* finder specified is AbstractButtonFinder.
|
|
14 |
*
|
|
15 |
* <h3>Description</h3>
|
|
16 |
* <p>
|
|
17 |
* This creates a AbstractButtonFinder and executes the find.
|
|
18 |
* </p>
|
|
19 |
* <h3>Finder tag name</h3>
|
|
20 |
* <p>
|
|
21 |
* AbstractButtonFinder
|
|
22 |
* </p>
|
|
23 |
* <h3>Parameters</h3>
|
|
24 |
* <table border="1" cellpadding="2" cellspacing="0">
|
|
25 |
* <tr>
|
|
26 |
* <td valign="top"><b>Attribute</b></td>
|
|
27 |
* <td valign="top"><b>Description</b></td>
|
|
28 |
* <td align="center" valign="top"><b>Required</b></td>
|
|
29 |
* <td valign="top"><b>Default</b></td>
|
|
30 |
* <td valign="top"><b>Values</b></td>
|
|
31 |
* </tr>
|
|
32 |
* <tr>
|
|
33 |
* <td valign="top">finder</td>
|
|
34 |
* <td valign="top">For this element the type must be set to AbstractButtonFinder</td>
|
|
35 |
* <td valign="top" align="center">Yes</td>
|
|
36 |
* <td valign="top">N/A</td>
|
|
37 |
* <td valign="top">N/A</td>
|
|
38 |
* </tr>
|
|
39 |
* <tr>
|
|
40 |
* <td valign="top">id</td>
|
|
41 |
* <td valign="top">Id for the object found.</td>
|
|
42 |
* <td valign="top" align="center">Yes</td>
|
|
43 |
* <td valign="top">N/A</td>
|
|
44 |
* <td valign="top">String</td>
|
|
45 |
* </tr>
|
|
46 |
* <tr>
|
|
47 |
* <td valign="top">refid</td>
|
|
48 |
* <td valign="top">Id for the object found.</td>
|
|
49 |
* <td valign="top" align="center">No</td>
|
|
50 |
* <td valign="top">Search in all windows</td>
|
|
51 |
* <td valign="top">Panel to be searched</td>
|
|
52 |
* </tr>
|
|
53 |
* <tr>
|
|
54 |
* <td valign="top">index</td>
|
|
55 |
* <td valign="top">The index of the element to select from the combo box.</td>
|
|
56 |
* <td valign="top" align="center">Yes</td>
|
|
57 |
* <td valign="top">N/A</td>
|
|
58 |
* <td valign="top">Zero based index of list items.</td>
|
|
59 |
* </tr>
|
|
60 |
* <tr>
|
|
61 |
* <td valign="top">label</td>
|
|
62 |
* <td valign="top">The label of the button to be found.</td>
|
|
63 |
* <td valign="top" align="center">label or iconfile is required.</td>
|
|
64 |
* <td valign="top">None</td>
|
|
65 |
* <td valign="top">String</td>
|
|
66 |
* </tr>
|
|
67 |
* <tr>
|
|
68 |
* <td valign="top">iconfile</td>
|
|
69 |
* <td valign="top">The iconfile which is used as a icon on the button.</td>
|
|
70 |
* <td valign="top" align="center">label or iconfile is required.</td>
|
|
71 |
* <td valign="top">None</td>
|
|
72 |
* <td valign="top">Icon file name to be loaded and compared.</td>
|
|
73 |
* </tr>
|
|
74 |
* </table>
|
|
75 |
* <h3>Example</h3>
|
|
76 |
* <blockquote><pre>
|
|
77 |
* <find
|
|
78 |
* finder="AbstractButtonFinder"
|
|
79 |
* id="MyButton"
|
|
80 |
* index="0"
|
|
81 |
* label="My Button"
|
|
82 |
* />
|
|
83 |
* </pre></blockquote>
|
|
84 |
* <p>
|
|
85 |
* The above finds the first occurance of a button with the label
|
|
86 |
* "My Button"
|
|
87 |
* </p>
|
|
88 |
* @see junit.extensions.jfcunit.finder.AbstractButtonFinder
|
|
89 |
* @author Kevin Wilson
|
|
90 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
91 |
*/
|
|
92 |
public class AbstractButtonFinderTagHandler extends BaseFindTagHandler { |
|
93 |
/**
|
|
94 |
* Constructor for FindTagHandler.
|
|
95 |
*
|
|
96 |
* @param element The element to be processed
|
|
97 |
* @param testCase The IXMLTestCase that uses this element
|
|
98 |
*/
|
|
99 | 6 |
public AbstractButtonFinderTagHandler(final Element element,
|
100 |
final IXMLTestCase testCase) { |
|
101 | 6 |
super(element, testCase);
|
102 |
} |
|
103 |
|
|
104 |
/**
|
|
105 |
* @see junit.extensions.xml.elements.AbstractTagHandler#processElement()
|
|
106 |
* @throws XMLException is thrown if the element cannot be understood.
|
|
107 |
*/
|
|
108 | 6 |
public void processElement() throws XMLException { |
109 | 6 |
validateElement(); |
110 |
|
|
111 | 6 |
String label = getLabel(); |
112 | 6 |
Icon icon = getIcon(); |
113 | 6 |
boolean caseIndependent = getCaseIndependent();
|
114 |
|
|
115 | 6 |
find(new AbstractButtonFinder(label, icon, caseIndependent));
|
116 |
} |
|
117 |
|
|
118 |
/**
|
|
119 |
* @see junit.extensions.xml.elements.AbstractTagHandler#validateElement()
|
|
120 |
* @throws XMLException thrown if the element cannot be validated.
|
|
121 |
*/
|
|
122 | 6 |
public void validateElement() throws XMLException { |
123 |
// do the default validations from the super class
|
|
124 | 6 |
super.validateElement();
|
125 |
|
|
126 |
// reqd attribute: at least one of label or icon file
|
|
127 | 6 |
checkAtLeastOneRequiredAttribute( |
128 |
getElement(), |
|
129 |
new String[] {LABEL, ICONFILE});
|
|
130 |
} |
|
131 |
} |
|
132 |
|
|