|
1
|
|
package junit.extensions.jfcunit.finder;
|
|
2
|
|
|
|
3
|
|
import javax.swing.JFrame;
|
|
4
|
|
|
|
5
|
|
import org.w3c.dom.Element;
|
|
6
|
|
import junit.extensions.jfcunit.AbstractTestCase;
|
|
7
|
|
import junit.extensions.jfcunit.xml.JFCXMLTestCase;
|
|
8
|
|
import junit.extensions.xml.XMLException;
|
|
9
|
|
import junit.extensions.xml.XMLTagResourceBundle;
|
|
10
|
|
import junit.extensions.xml.elements.AbstractTagHandler;
|
|
11
|
|
import junit.extensions.xml.elements.ElementFixture;
|
|
12
|
|
|
|
13
|
|
|
|
14
|
|
|
|
15
|
|
|
|
16
|
|
|
|
17
|
|
|
|
18
|
|
|
|
19
|
|
public class FrameFinderTagHandlerT
|
|
20
|
|
extends AbstractTestCase {
|
|
21
|
|
|
|
22
|
|
|
|
23
|
|
|
|
24
|
|
|
|
25
|
|
private ElementFixture m_fixture;
|
|
26
|
|
|
|
27
|
|
|
|
28
|
|
|
|
29
|
|
|
|
30
|
|
|
|
31
|
4
|
public FrameFinderTagHandlerT(final String name) {
|
|
32
|
4
|
super(name);
|
|
33
|
|
}
|
|
34
|
|
|
|
35
|
|
|
|
36
|
|
|
|
37
|
|
|
|
38
|
|
|
|
39
|
4
|
protected void setUp() throws Exception {
|
|
40
|
4
|
super.setUp();
|
|
41
|
4
|
m_fixture = new ElementFixture(this);
|
|
42
|
4
|
m_fixture.setUp();
|
|
43
|
|
}
|
|
44
|
|
|
|
45
|
|
|
|
46
|
|
|
|
47
|
|
|
|
48
|
|
|
|
49
|
4
|
protected void tearDown() throws Exception {
|
|
50
|
4
|
m_fixture.tearDown();
|
|
51
|
|
|
|
52
|
4
|
m_fixture = null;
|
|
53
|
4
|
super.tearDown();
|
|
54
|
|
}
|
|
55
|
|
|
|
56
|
|
|
|
57
|
|
|
|
58
|
|
|
|
59
|
|
|
|
60
|
1
|
public void testProcessElement() throws XMLException {
|
|
61
|
|
|
|
62
|
1
|
JFrame frame = this.createJFrame("Test Frame");
|
|
63
|
1
|
this.packAndShow(frame);
|
|
64
|
1
|
setWindow(frame);
|
|
65
|
|
|
|
66
|
1
|
JFCXMLTestCase tc = m_fixture.getJFCTestCase();
|
|
67
|
1
|
Element e = m_fixture.newElement("find", new String[] {
|
|
68
|
|
"finder", "FrameFinder",
|
|
69
|
|
"title", "Test Frame",
|
|
70
|
|
"id", "frame",
|
|
71
|
|
"index", "0",
|
|
72
|
|
"wait", "35"
|
|
73
|
|
});
|
|
74
|
1
|
AbstractTagHandler h = XMLTagResourceBundle.getTagHandler(e, tc, "find");
|
|
75
|
1
|
h.processElement();
|
|
76
|
|
|
|
77
|
1
|
Object o = tc.getProperty("frame");
|
|
78
|
1
|
assertNotNull(o);
|
|
79
|
|
}
|
|
80
|
|
|
|
81
|
|
|
|
82
|
|
|
|
83
|
|
|
|
84
|
|
|
|
85
|
1
|
public void testProcessZeroWait() throws XMLException {
|
|
86
|
|
|
|
87
|
1
|
JFrame frame = this.createJFrame("Test Frame");
|
|
88
|
1
|
this.packAndShow(frame);
|
|
89
|
1
|
setWindow(frame);
|
|
90
|
|
|
|
91
|
1
|
JFCXMLTestCase tc = m_fixture.getJFCTestCase();
|
|
92
|
1
|
Element e = m_fixture.newElement("find", new String[] {
|
|
93
|
|
"finder", "FrameFinder",
|
|
94
|
|
"title", "Test Frame",
|
|
95
|
|
"id", "frame",
|
|
96
|
|
"index", "0",
|
|
97
|
|
"wait", "0"
|
|
98
|
|
});
|
|
99
|
1
|
AbstractTagHandler h = XMLTagResourceBundle.getTagHandler(e, tc, "find");
|
|
100
|
1
|
h.processElement();
|
|
101
|
|
|
|
102
|
1
|
Object o = tc.getProperty("frame");
|
|
103
|
1
|
assertNotNull(o);
|
|
104
|
|
}
|
|
105
|
|
|
|
106
|
|
|
|
107
|
|
|
|
108
|
|
|
|
109
|
|
|
|
110
|
1
|
public void testProcessSlowToShow() throws XMLException {
|
|
111
|
|
|
|
112
|
1
|
JFrame frame = this.createJFrame("Test Frame");
|
|
113
|
1
|
setWindow(frame);
|
|
114
|
|
|
|
115
|
1
|
JFCXMLTestCase tc = m_fixture.getJFCTestCase();
|
|
116
|
1
|
Element e = m_fixture.newElement("find", new String[] {
|
|
117
|
|
"finder", "FrameFinder",
|
|
118
|
|
"title", "Test Frame",
|
|
119
|
|
"id", "frame",
|
|
120
|
|
"index", "0",
|
|
121
|
|
"wait", "30"
|
|
122
|
|
});
|
|
123
|
1
|
final AbstractTagHandler h = XMLTagResourceBundle.getTagHandler(e, tc,
|
|
124
|
|
"find");
|
|
125
|
|
|
|
126
|
1
|
Thread th = new Thread(new Runnable() {
|
|
127
|
1
|
public void run() {
|
|
128
|
1
|
h.processElement();
|
|
129
|
|
}
|
|
130
|
|
});
|
|
131
|
1
|
th.start();
|
|
132
|
|
|
|
133
|
1
|
try {
|
|
134
|
1
|
Thread.currentThread().sleep(5000);
|
|
135
|
1
|
packAndShow(frame);
|
|
136
|
1
|
th.join();
|
|
137
|
|
} catch (InterruptedException ex) {
|
|
138
|
|
}
|
|
139
|
1
|
Object o = tc.getProperty("frame");
|
|
140
|
1
|
assertNotNull(o);
|
|
141
|
|
}
|
|
142
|
|
|
|
143
|
|
|
|
144
|
|
|
|
145
|
|
|
|
146
|
|
|
|
147
|
1
|
public void testProcessTooSlowToShow() throws XMLException {
|
|
148
|
|
|
|
149
|
1
|
JFrame frame = this.createJFrame("Test Frame");
|
|
150
|
1
|
setWindow(frame);
|
|
151
|
|
|
|
152
|
1
|
JFCXMLTestCase tc = m_fixture.getJFCTestCase();
|
|
153
|
1
|
Element e = m_fixture.newElement("find", new String[] {
|
|
154
|
|
"finder", "FrameFinder",
|
|
155
|
|
"title", "Test Frame",
|
|
156
|
|
"id", "frame",
|
|
157
|
|
"index", "0",
|
|
158
|
|
"wait", "3"
|
|
159
|
|
});
|
|
160
|
1
|
final AbstractTagHandler h = XMLTagResourceBundle.getTagHandler(e, tc,
|
|
161
|
|
"find");
|
|
162
|
|
|
|
163
|
1
|
Thread th = new Thread(new Runnable() {
|
|
164
|
1
|
public void run() {
|
|
165
|
1
|
h.processElement();
|
|
166
|
|
}
|
|
167
|
|
});
|
|
168
|
1
|
th.start();
|
|
169
|
|
|
|
170
|
1
|
try {
|
|
171
|
1
|
Thread.currentThread().sleep(5000);
|
|
172
|
1
|
packAndShow(frame);
|
|
173
|
1
|
th.join();
|
|
174
|
|
} catch (InterruptedException ex) {
|
|
175
|
|
}
|
|
176
|
1
|
Object o = tc.getProperty("frame");
|
|
177
|
1
|
assertNull(o);
|
|
178
|
|
}
|
|
179
|
|
}
|
|
180
|
|
|