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