|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AbstractButtonFinderTagHandlerT.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
package junit.extensions.jfcunit.finder;
|
|
| 2 |
|
|
| 3 |
import javax.swing.AbstractButton;
|
|
| 4 |
import javax.swing.BoxLayout;
|
|
| 5 |
import javax.swing.JButton;
|
|
| 6 |
import javax.swing.JFrame;
|
|
| 7 |
import javax.swing.JRadioButton;
|
|
| 8 |
import javax.swing.JToggleButton;
|
|
| 9 |
|
|
| 10 |
import org.w3c.dom.Element;
|
|
| 11 |
import junit.extensions.jfcunit.AbstractTestCase;
|
|
| 12 |
import junit.extensions.jfcunit.xml.JFCXMLTestCase;
|
|
| 13 |
import junit.extensions.xml.XMLException;
|
|
| 14 |
import junit.extensions.xml.elements.ElementFixture;
|
|
| 15 |
|
|
| 16 |
/**
|
|
| 17 |
* Test the AbstractButtonFinderTagHandler.
|
|
| 18 |
*/
|
|
| 19 |
public class AbstractButtonFinderTagHandlerT extends AbstractTestCase { |
|
| 20 |
/**
|
|
| 21 |
* Test fixture.
|
|
| 22 |
*/
|
|
| 23 |
private ElementFixture m_fixture;
|
|
| 24 |
|
|
| 25 |
/**
|
|
| 26 |
* Constructor.
|
|
| 27 |
* @param name String name of the test method to run.
|
|
| 28 |
*/
|
|
| 29 | 1 |
public AbstractButtonFinderTagHandlerT(final String name) {
|
| 30 | 1 |
super(name);
|
| 31 |
} |
|
| 32 |
|
|
| 33 |
/**
|
|
| 34 |
* Setup the test.
|
|
| 35 |
* @throws Exception may be thrown.
|
|
| 36 |
*/
|
|
| 37 | 1 |
protected void setUp() throws Exception { |
| 38 | 1 |
super.setUp();
|
| 39 | 1 |
m_fixture = new ElementFixture(this); |
| 40 | 1 |
m_fixture.setUp(); |
| 41 |
} |
|
| 42 |
|
|
| 43 |
/**
|
|
| 44 |
* Tear down the test.
|
|
| 45 |
* @throws Exception may be thrown.
|
|
| 46 |
*/
|
|
| 47 | 1 |
protected void tearDown() throws Exception { |
| 48 | 1 |
m_fixture.tearDown(); |
| 49 | 1 |
m_fixture = null;
|
| 50 | 1 |
super.tearDown();
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
/**
|
|
| 54 |
* Test finding a button.
|
|
| 55 |
* @throws XMLException may be thrown.
|
|
| 56 |
*/
|
|
| 57 | 1 |
public void testProcessElement() throws XMLException { |
| 58 | 1 |
JFrame frame = this.createJFrame(getName());
|
| 59 | 1 |
BoxLayout boxLayout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS);
|
| 60 | 1 |
frame.getContentPane().setLayout(boxLayout); |
| 61 | 1 |
AbstractButton b1 = new JButton("L1"); |
| 62 | 1 |
AbstractButton b2 = new JToggleButton("L2"); |
| 63 | 1 |
AbstractButton b3 = new JRadioButton("L3"); |
| 64 |
|
|
| 65 | 1 |
frame.getContentPane().add(b1); |
| 66 | 1 |
frame.getContentPane().add(b2); |
| 67 | 1 |
frame.getContentPane().add(b3); |
| 68 | 1 |
this.packAndShow(frame);
|
| 69 |
|
|
| 70 | 1 |
JFCXMLTestCase tc = m_fixture.getJFCTestCase(); |
| 71 | 1 |
tc.addProperty("frame", frame);
|
| 72 | 1 |
Element e = m_fixture.newElement("find", new String[] { |
| 73 |
"finder", "AbstractButtonFinder", |
|
| 74 |
"label", "L1", |
|
| 75 |
"container", "frame", |
|
| 76 |
"id", "button", |
|
| 77 |
"index", "0", |
|
| 78 |
"wait", "35" |
|
| 79 |
}); |
|
| 80 |
|
|
| 81 | 1 |
AbstractButtonFinderTagHandler th = new AbstractButtonFinderTagHandler(e, tc);
|
| 82 | 1 |
th.processElement(); |
| 83 |
|
|
| 84 | 1 |
Object o = tc.getProperty("button");
|
| 85 | 1 |
assertSame("Button not found", b1, o);
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
} |
|
| 89 |
|
|
||||||||||