|
1
|
|
package abbot.editor.recorder;
|
|
2
|
|
|
|
3
|
|
import java.util.Vector;
|
|
4
|
|
|
|
5
|
|
import javax.swing.JList;
|
|
6
|
|
|
|
7
|
|
import junit.extensions.abbot.RepeatHelper;
|
|
8
|
|
import junit.framework.*;
|
|
9
|
|
import abbot.script.Resolver;
|
|
10
|
|
import abbot.tester.*;
|
|
11
|
|
|
|
12
|
|
|
|
13
|
|
|
|
14
|
|
|
|
15
|
|
public class JListRecorderTest
|
|
16
|
|
extends AbstractSemanticRecorderFixture {
|
|
17
|
|
|
|
18
|
|
private JListTester tester;
|
|
19
|
|
private JList list;
|
|
20
|
|
private static final int MAX_ENTRIES = 5;
|
|
21
|
|
|
|
22
|
1
|
public JListRecorderTest(String name) {
|
|
23
|
1
|
super(name);
|
|
24
|
|
}
|
|
25
|
|
|
|
26
|
10
|
protected SemanticRecorder createSemanticRecorder(Resolver r) {
|
|
27
|
10
|
return new JListRecorder(r);
|
|
28
|
|
}
|
|
29
|
|
|
|
30
|
1
|
private void showList() {
|
|
31
|
1
|
Vector els = new Vector();
|
|
32
|
1
|
for (int i=0;i < MAX_ENTRIES;i++) {
|
|
33
|
5
|
els.add("list item " + i);
|
|
34
|
|
}
|
|
35
|
1
|
list = new JList(els);
|
|
36
|
1
|
tester = (JListTester)ComponentTester.getTester(list);
|
|
37
|
1
|
showFrame(list);
|
|
38
|
|
}
|
|
39
|
|
|
|
40
|
1
|
public void testCaptureSelection() {
|
|
41
|
1
|
showList();
|
|
42
|
1
|
startRecording();
|
|
43
|
1
|
for (int i=MAX_ENTRIES-1;i >= 0; i--) {
|
|
44
|
5
|
tester.actionSelectIndex(list, i);
|
|
45
|
5
|
assertStep("SelectRow\\(.*,\"list item " + i + "\"\\)");
|
|
46
|
|
}
|
|
47
|
|
}
|
|
48
|
|
|
|
49
|
|
|
|
50
|
1
|
public static Test suite() {
|
|
51
|
1
|
return new TestSuite(JListRecorderTest.class);
|
|
52
|
|
}
|
|
53
|
|
|
|
54
|
0
|
public static void main(String[] args) {
|
|
55
|
0
|
RepeatHelper.runTests(args, JListRecorderTest.class);
|
|
56
|
|
}
|
|
57
|
|
}
|
|
58
|
|
|