|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| DialogFinderTagHandler.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 DialogFinder.
|
|
| 12 |
*
|
|
| 13 |
* <h3>Description</h3>
|
|
| 14 |
* <p>
|
|
| 15 |
* This creates a DialogFinder and executes the find.
|
|
| 16 |
* </p>
|
|
| 17 |
* <h3>Finder tag name</h3>
|
|
| 18 |
* <p>
|
|
| 19 |
* DialogFinder
|
|
| 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 DialogFinder</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">title</td>
|
|
| 46 |
* <td valign="top">The title of the dialog to be found.</td>
|
|
| 47 |
* <td valign="top" align="center">Yes</td>
|
|
| 48 |
* <td valign="top">None</td>
|
|
| 49 |
* <td valign="top">Regular expression defining the title.</td>
|
|
| 50 |
* </tr>
|
|
| 51 |
* <tr>
|
|
| 52 |
* <td valign="top">caseindependent</td>
|
|
| 53 |
* <td valign="top">Ignore the case if true</td>
|
|
| 54 |
* <td valign="top" align="center">No</td>
|
|
| 55 |
* <td valign="top">false</td>
|
|
| 56 |
* <td valign="top">true/false</td>
|
|
| 57 |
* </tr>
|
|
| 58 |
* </table>
|
|
| 59 |
* <h3>Example</h3>
|
|
| 60 |
* <blockquote><pre>
|
|
| 61 |
* <find
|
|
| 62 |
* finder="DialogFinder"
|
|
| 63 |
* id="MyDialog"
|
|
| 64 |
* title="^My dialog box$"
|
|
| 65 |
* />
|
|
| 66 |
* </pre></blockquote>
|
|
| 67 |
* <p>
|
|
| 68 |
* The above finds the first dialog with
|
|
| 69 |
* a complete title "My dialog box"
|
|
| 70 |
* </p>
|
|
| 71 |
* @see junit.extensions.jfcunit.finder.DialogFinder
|
|
| 72 |
* @author Kevin Wilson
|
|
| 73 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
| 74 |
*/
|
|
| 75 |
public class DialogFinderTagHandler extends BaseFindTagHandler { |
|
| 76 |
/**
|
|
| 77 |
* Constructor for ComponentFinderTagHandler.
|
|
| 78 |
*
|
|
| 79 |
* @param element The element to be processed
|
|
| 80 |
* @param testCase The IXMLTestCase that uses this element
|
|
| 81 |
*/
|
|
| 82 | 4 |
public DialogFinderTagHandler(final Element element,
|
| 83 |
final IXMLTestCase testCase) {
|
|
| 84 | 4 |
super(element, testCase);
|
| 85 |
} |
|
| 86 |
|
|
| 87 |
/**
|
|
| 88 |
* @see junit.extensions.xml.elements.AbstractTagHandler#processElement()
|
|
| 89 |
*/
|
|
| 90 | 4 |
public void processElement() throws XMLException { |
| 91 | 4 |
validateElement(); |
| 92 | 4 |
findWindow(new DialogFinder(
|
| 93 |
getTitle(), |
|
| 94 |
getCaseIndependent())); |
|
| 95 |
} |
|
| 96 |
|
|
| 97 |
/**
|
|
| 98 |
* @see junit.extensions.xml.elements.AbstractTagHandler#validateElement()
|
|
| 99 |
*/
|
|
| 100 | 4 |
public void validateElement() throws XMLException { |
| 101 |
// do the default validations from the super class
|
|
| 102 | 4 |
super.validateElement();
|
| 103 |
|
|
| 104 |
// reqd attribute: class
|
|
| 105 | 4 |
checkRequiredAttribute(TITLE); |
| 106 |
} |
|
| 107 |
|
|
| 108 |
/**
|
|
| 109 |
* Get the Wait time for the finder.
|
|
| 110 |
* @return Duration for the Finder to try again until the
|
|
| 111 |
* object is found.
|
|
| 112 |
*/
|
|
| 113 | 4 |
protected int getWait() { |
| 114 | 4 |
return super.getInt(WAIT, 15); |
| 115 |
} |
|
| 116 |
} |
|
| 117 |
|
|
||||||||||