|
1
|
|
package abbot.editor.editors;
|
|
2
|
|
|
|
3
|
|
import java.awt.Color;
|
|
4
|
|
import java.awt.Component;
|
|
5
|
|
import java.awt.event.KeyEvent;
|
|
6
|
|
import javax.swing.*;
|
|
7
|
|
|
|
8
|
|
import junit.extensions.abbot.*;
|
|
9
|
|
import abbot.DynamicLoadingConstants;
|
|
10
|
|
import abbot.script.*;
|
|
11
|
|
import abbot.tester.*;
|
|
12
|
|
import abbot.finder.matchers.*;
|
|
13
|
|
import abbot.editor.widgets.*;
|
|
14
|
|
|
|
15
|
|
|
|
16
|
|
|
|
17
|
|
public class LaunchEditorTest
|
|
18
|
|
extends ComponentTestFixture implements XMLConstants, DynamicLoadingConstants {
|
|
19
|
|
|
|
20
|
|
private Launch launch;
|
|
21
|
|
private LaunchEditor editor;
|
|
22
|
|
private ComponentTester tester;
|
|
23
|
|
|
|
24
|
4
|
protected void setUp() {
|
|
25
|
4
|
launch = new Launch(getResolver(), LaunchEditor.HELP_DESC,
|
|
26
|
|
"java.lang.Object", "hashCode", null);
|
|
27
|
4
|
editor = new LaunchEditor(launch);
|
|
28
|
4
|
tester = new ComponentTester();
|
|
29
|
|
}
|
|
30
|
|
|
|
31
|
1
|
public void testRemoveHelpDescription() throws Exception {
|
|
32
|
1
|
showFrame(editor);
|
|
33
|
1
|
JCheckBox cb = (JCheckBox)getFinder().
|
|
34
|
|
find(new ClassMatcher(JCheckBox.class));
|
|
35
|
1
|
assertEquals("Should start with help description",
|
|
36
|
|
LaunchEditor.HELP_DESC, launch.getDescription());
|
|
37
|
1
|
tester.actionClick(cb);
|
|
38
|
1
|
assertFalse("Help description should be changed on edit of other prop",
|
|
39
|
|
LaunchEditor.HELP_DESC.equals(launch.getDescription()));
|
|
40
|
|
}
|
|
41
|
|
|
|
42
|
1
|
public void testClasspathAffectsClassAndMethod() throws Exception {
|
|
43
|
1
|
String PATH = DYNAMIC_CLASSPATH;
|
|
44
|
1
|
String CLASSNAME = DYNAMIC_CLASSNAME;
|
|
45
|
1
|
String METHOD = "main";
|
|
46
|
1
|
launch.setTargetClassName(CLASSNAME);
|
|
47
|
1
|
launch.setMethodName(METHOD);
|
|
48
|
1
|
launch.setArguments("[]");
|
|
49
|
1
|
launch.setClasspath(PATH);
|
|
50
|
1
|
editor = new LaunchEditor(launch);
|
|
51
|
1
|
showFrame(editor);
|
|
52
|
|
|
|
53
|
1
|
ArrayEditor array = (ArrayEditor)getFinder().
|
|
54
|
|
find(editor, new NameMatcher(TAG_CLASSPATH));
|
|
55
|
1
|
JTextField tf = (JTextField)getFinder().
|
|
56
|
|
find(array, new NameMatcher("editor"));
|
|
57
|
1
|
JTextField className = (JTextField)getFinder().
|
|
58
|
|
find(editor, new NameMatcher(TAG_CLASS));
|
|
59
|
1
|
JComboBox methodCombo = (JComboBox)getFinder().
|
|
60
|
|
find(editor, new NameMatcher(TAG_METHOD));
|
|
61
|
1
|
JTextField method = (JTextField)getFinder().
|
|
62
|
|
find(methodCombo, new ClassMatcher(JTextField.class));
|
|
63
|
1
|
Color normal = className.getForeground();
|
|
64
|
|
|
|
65
|
1
|
assertEquals("Wrong class name", CLASSNAME, className.getText());
|
|
66
|
1
|
assertEquals("Wrong method name", METHOD, method.getText());
|
|
67
|
1
|
assertEquals("Wrong number of path elements",
|
|
68
|
|
1, array.getValues().length);
|
|
69
|
1
|
assertEquals("Wrong path", PATH, array.getValues()[0]);
|
|
70
|
|
|
|
71
|
1
|
JTextComponentTester textTester = new JTextComponentTester();
|
|
72
|
1
|
textTester.actionEnterText(tf, "no.such.path");
|
|
73
|
|
|
|
74
|
1
|
assertTrue("Class name field should show invalid: "
|
|
75
|
|
+ className.getForeground(),
|
|
76
|
|
!normal.equals(className.getForeground()));
|
|
77
|
1
|
assertTrue("Method name field should show invalid"
|
|
78
|
|
+ method.getForeground(),
|
|
79
|
|
!normal.equals(method.getForeground()));
|
|
80
|
|
|
|
81
|
1
|
textTester.actionEnterText(tf, PATH);
|
|
82
|
1
|
assertEquals("Class name should have reverted to normal foreground",
|
|
83
|
|
normal, className.getForeground());
|
|
84
|
0
|
assertEquals("Method name should have reverted to normal foreground",
|
|
85
|
|
normal, method.getForeground());
|
|
86
|
|
}
|
|
87
|
|
|
|
88
|
1
|
public void testChangeClasspath() throws Exception {
|
|
89
|
1
|
String PATH = "/some/path";
|
|
90
|
1
|
launch.setClasspath(PATH);
|
|
91
|
1
|
editor = new LaunchEditor(launch);
|
|
92
|
1
|
showFrame(editor);
|
|
93
|
1
|
ArrayEditor array = (ArrayEditor)getFinder().
|
|
94
|
|
find(editor, new NameMatcher(TAG_CLASSPATH));
|
|
95
|
|
|
|
96
|
1
|
Object[] path = array.getValues();
|
|
97
|
1
|
assertEquals("Path element not added", 1, path.length);
|
|
98
|
|
|
|
99
|
1
|
JTextField tf = (JTextField)getFinder().
|
|
100
|
|
find(array, new NameMatcher("editor"));
|
|
101
|
1
|
assertEquals("Incorrect editor text", PATH, tf.getText());
|
|
102
|
|
|
|
103
|
1
|
path = array.getValues();
|
|
104
|
1
|
assertEquals("Path not changed", PATH, path[0]);
|
|
105
|
|
}
|
|
106
|
|
|
|
107
|
1
|
public void testAddClasspath() throws Exception {
|
|
108
|
1
|
showFrame(editor);
|
|
109
|
1
|
ArrayEditor array = (ArrayEditor)getFinder().
|
|
110
|
|
find(editor, new NameMatcher(TAG_CLASSPATH));
|
|
111
|
1
|
JButton button = (JButton)getFinder().
|
|
112
|
|
find(array, new NameMatcher("add"));
|
|
113
|
1
|
tester.actionClick(button);
|
|
114
|
1
|
Object[] path = array.getValues();
|
|
115
|
1
|
assertEquals("Should have added a path", 1, path.length);
|
|
116
|
1
|
tester.actionClick(button);
|
|
117
|
1
|
path = array.getValues();
|
|
118
|
1
|
assertEquals("Should have added a path", 2, path.length);
|
|
119
|
|
}
|
|
120
|
|
|
|
121
|
|
|
|
122
|
4
|
public LaunchEditorTest(String name) {
|
|
123
|
4
|
super(name);
|
|
124
|
|
}
|
|
125
|
|
|
|
126
|
|
|
|
127
|
0
|
public static void main(String[] args) {
|
|
128
|
0
|
TestHelper.runTests(args, LaunchEditorTest.class);
|
|
129
|
|
}
|
|
130
|
|
}
|
|
131
|
|
|