|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| FindTagHandler.java | - | 87.5% | 80% | 84.6% |
|
||||||||||||||
| 1 |
package junit.extensions.jfcunit.finder;
|
|
| 2 |
|
|
| 3 |
import junit.extensions.jfcunit.xml.JFCXMLConstants;
|
|
| 4 |
|
|
| 5 |
import junit.extensions.xml.IXMLTestCase;
|
|
| 6 |
import junit.extensions.xml.XMLException;
|
|
| 7 |
import junit.extensions.xml.XMLTagResourceBundle;
|
|
| 8 |
import junit.extensions.xml.elements.AbstractTagHandler;
|
|
| 9 |
|
|
| 10 |
import org.w3c.dom.Element;
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
/**
|
|
| 14 |
* This element helps locate objects within the gui. It
|
|
| 15 |
* uses the underlying JFCUnit finders to locate objects.
|
|
| 16 |
* The finders implementation may be extended via the
|
|
| 17 |
* TagMapping.properties file specified in the classpath.
|
|
| 18 |
*
|
|
| 19 |
* <h3>Description</h3>
|
|
| 20 |
* <p>
|
|
| 21 |
* This creates a DialogFinder and executes the find.
|
|
| 22 |
* </p>
|
|
| 23 |
*
|
|
| 24 |
* <h3>Parameters</h3>
|
|
| 25 |
* <table border="1" cellpadding="2" cellspacing="0">
|
|
| 26 |
* <tr>
|
|
| 27 |
* <td valign="top"><b>Attribute</b></td>
|
|
| 28 |
* <td valign="top"><b>Description</b></td>
|
|
| 29 |
* <td align="center" valign="top"><b>Required</b></td>
|
|
| 30 |
* <td valign="top"><b>Default</b></td>
|
|
| 31 |
* <td valign="top"><b>Values</b></td>
|
|
| 32 |
* </tr>
|
|
| 33 |
* <tr>
|
|
| 34 |
* <td valign="top">finder</td>
|
|
| 35 |
* <td valign="top">This element specifies the finder implementation to use.</td>
|
|
| 36 |
* <td valign="top" align="center">Yes</td>
|
|
| 37 |
* <td valign="top">N/A</td>
|
|
| 38 |
* <td valign="top">AbstractButtonFinder ComponentFinder DialogFinder FrameFinder
|
|
| 39 |
* JLabelFinder JMenuItemFinder JWindowFinder NamedComponentFinder or other custom
|
|
| 40 |
* finder tags specified in TagMapping.properties.</td>
|
|
| 41 |
* </tr>
|
|
| 42 |
* <tr>
|
|
| 43 |
* <td valign="top">id</td>
|
|
| 44 |
* <td valign="top">Id for the object found.</td>
|
|
| 45 |
* <td valign="top" align="center">Yes</td>
|
|
| 46 |
* <td valign="top">N/A</td>
|
|
| 47 |
* <td valign="top">String</td>
|
|
| 48 |
* </tr>
|
|
| 49 |
* <tr>
|
|
| 50 |
* <td valign="top">others</td>
|
|
| 51 |
* <td valign="top">See corresponding tag handler implementation
|
|
| 52 |
* for a definition of other attributes that may be required.</td>
|
|
| 53 |
* <td valign="top" align="center">Yes</td>
|
|
| 54 |
* <td valign="top">N/A</td>
|
|
| 55 |
* <td valign="top">N/A</td>
|
|
| 56 |
* </tr>
|
|
| 57 |
* </table>
|
|
| 58 |
* <h3>Example</h3>
|
|
| 59 |
* <blockquote><pre>
|
|
| 60 |
* <find
|
|
| 61 |
* finder="DialogFinder"
|
|
| 62 |
* id="MyDialog"
|
|
| 63 |
* title="^My dialog box$"
|
|
| 64 |
* />
|
|
| 65 |
* </pre></blockquote>
|
|
| 66 |
* <p>
|
|
| 67 |
* The above uses the TagHandler associated with the DialogFinder tag in the
|
|
| 68 |
* TagMapping.properties file. In the default jfcUnit case this would be the
|
|
| 69 |
* junit.extensions.jfcunit.finder.DialogFinderTagMapping.
|
|
| 70 |
* </p>
|
|
| 71 |
*
|
|
| 72 |
* @see junit.extensions.jfcunit.finder.AbstractButtonFinderTagHandler
|
|
| 73 |
* @see junit.extensions.jfcunit.finder.ComponentFinderTagHandler
|
|
| 74 |
* @see junit.extensions.jfcunit.finder.DialogFinderTagHandler
|
|
| 75 |
* @see junit.extensions.jfcunit.finder.FrameFinderTagHandler
|
|
| 76 |
* @see junit.extensions.jfcunit.finder.JLabelFinderTagHandler
|
|
| 77 |
* @see junit.extensions.jfcunit.finder.JMenuItemFinderTagHandler
|
|
| 78 |
* @see junit.extensions.jfcunit.finder.JWindowFinderTagHandler
|
|
| 79 |
* @see junit.extensions.jfcunit.finder.NamedComponentFinderTagHandler
|
|
| 80 |
* @see junit.extensions.jfcunit.finder.JPopupMenuFinderTagHandler
|
|
| 81 |
* @see junit.extensions.jfcunit.finder.LabeledComponentFinderTagHander
|
|
| 82 |
* @author Kevin Wilson
|
|
| 83 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
| 84 |
*/
|
|
| 85 |
public class FindTagHandler extends AbstractTagHandler |
|
| 86 |
implements JFCXMLConstants {
|
|
| 87 |
/**
|
|
| 88 |
* Constructor for FindTagHandler.
|
|
| 89 |
*
|
|
| 90 |
* @param element The element to be processed
|
|
| 91 |
* @param testCase The IXMLTestCase that uses this element
|
|
| 92 |
*/
|
|
| 93 | 160 |
public FindTagHandler(final Element element, final IXMLTestCase testCase) {
|
| 94 | 160 |
super(element, testCase);
|
| 95 |
} |
|
| 96 |
|
|
| 97 |
/**
|
|
| 98 |
* Returns the value of the FINDER attribute for this element.
|
|
| 99 |
* @return String The value of the FINDER attribute.
|
|
| 100 |
*/
|
|
| 101 | 160 |
public String getFinder() {
|
| 102 | 160 |
return getString(FINDER);
|
| 103 |
} |
|
| 104 |
|
|
| 105 |
/**
|
|
| 106 |
* Returns the value of the NAME attribute for this element.
|
|
| 107 |
* @return String The value of the NAME attribute.
|
|
| 108 |
*/
|
|
| 109 | 0 |
public String getName() {
|
| 110 | 0 |
return getString(NAME);
|
| 111 |
} |
|
| 112 |
|
|
| 113 |
/**
|
|
| 114 |
* @see junit.extensions.xml.elements.AbstractTagHandler#processElement()
|
|
| 115 |
*/
|
|
| 116 | 160 |
public void processElement() throws XMLException { |
| 117 | 160 |
validateElement(); |
| 118 |
|
|
| 119 | 160 |
XMLTagResourceBundle.getTagHandler( |
| 120 |
getElement(), |
|
| 121 |
getXMLTestCase(), |
|
| 122 |
getFinder()).processElement(); |
|
| 123 |
} |
|
| 124 |
|
|
| 125 |
/**
|
|
| 126 |
* @see junit.extensions.xml.elements.AbstractTagHandler#validateElement()
|
|
| 127 |
*/
|
|
| 128 | 160 |
public void validateElement() throws XMLException { |
| 129 |
// do the default validations from the super class
|
|
| 130 | 160 |
super.validateElement();
|
| 131 |
|
|
| 132 |
// check the element tag name
|
|
| 133 | 160 |
checkElementTagName(FIND); |
| 134 |
|
|
| 135 |
// required attribute: class
|
|
| 136 | 160 |
checkRequiredAttribute(FINDER); |
| 137 |
} |
|
| 138 |
} |
|
| 139 |
|
|
||||||||||