|
1
|
|
package junit.extensions.jfcunit.finder;
|
|
2
|
|
|
|
3
|
|
import junit.extensions.jfcunit.AbstractTestCase;
|
|
4
|
|
|
|
5
|
|
import javax.swing.JButton;
|
|
6
|
|
import javax.swing.JFrame;
|
|
7
|
|
import javax.swing.JComponent;
|
|
8
|
|
|
|
9
|
|
|
|
10
|
|
|
|
11
|
|
|
|
12
|
|
|
|
13
|
|
|
|
14
|
|
public class ComponentFinderT extends AbstractTestCase {
|
|
15
|
|
|
|
16
|
|
|
|
17
|
|
|
|
18
|
|
|
|
19
|
|
|
|
20
|
4
|
public ComponentFinderT(final String name) {
|
|
21
|
4
|
super(name);
|
|
22
|
|
}
|
|
23
|
|
|
|
24
|
|
|
|
25
|
|
|
|
26
|
|
|
|
27
|
1
|
public void testNullClass() {
|
|
28
|
1
|
ComponentFinder finder = new ComponentFinder(null);
|
|
29
|
1
|
JButton button = new JButton();
|
|
30
|
1
|
JFrame frame = createJFrame(getName());
|
|
31
|
1
|
frame.getContentPane().add(button);
|
|
32
|
1
|
packAndShow(frame);
|
|
33
|
1
|
setWindow(frame);
|
|
34
|
1
|
assertFalse("Finder is not working", finder.testComponent(button));
|
|
35
|
|
}
|
|
36
|
|
|
|
37
|
|
|
|
38
|
|
|
|
39
|
|
|
|
40
|
1
|
public void testInvalidClass() {
|
|
41
|
1
|
ComponentFinder finder = new ComponentFinder(JFrame.class);
|
|
42
|
1
|
JButton button = new JButton();
|
|
43
|
1
|
JFrame frame = createJFrame(getName());
|
|
44
|
1
|
frame.getContentPane().add(button);
|
|
45
|
1
|
setWindow(frame);
|
|
46
|
1
|
packAndShow(frame);
|
|
47
|
1
|
assertFalse("Finder is not working", finder.testComponent(button));
|
|
48
|
|
}
|
|
49
|
|
|
|
50
|
|
|
|
51
|
|
|
|
52
|
|
|
|
53
|
1
|
public void testValidClass() {
|
|
54
|
1
|
ComponentFinder finder = new ComponentFinder(JButton.class);
|
|
55
|
1
|
JButton button = new JButton();
|
|
56
|
1
|
JFrame frame = createJFrame(getName());
|
|
57
|
1
|
frame.getContentPane().add(button);
|
|
58
|
1
|
packAndShow(frame);
|
|
59
|
1
|
setWindow(frame);
|
|
60
|
1
|
assertTrue("Finder is not working", finder.testComponent(button));
|
|
61
|
|
}
|
|
62
|
|
|
|
63
|
|
|
|
64
|
|
|
|
65
|
|
|
|
66
|
1
|
public void testComponentClass() {
|
|
67
|
1
|
ComponentFinder finder = new ComponentFinder(JComponent.class);
|
|
68
|
1
|
assertSame(JComponent.class, finder.getComponentClass());
|
|
69
|
|
|
|
70
|
1
|
finder.setComponentClass(JButton.class);
|
|
71
|
1
|
assertSame(JButton.class, finder.getComponentClass());
|
|
72
|
|
}
|
|
73
|
|
}
|
|
74
|
|
|