01: package abbot.editor.editors;
02:
03: import javax.swing.*;
04:
05: import junit.extensions.abbot.*;
06: import abbot.script.*;
07: import abbot.tester.JTextComponentTester;
08: import abbot.finder.matchers.*;
09:
10: /** Verify CallEditor operation. */
11:
12: public class CallEditorTest extends ResolverFixture implements
13: XMLConstants {
14:
15: private Call call;
16: private CallEditor editor;
17: private JTextComponentTester tester;
18:
19: protected void setUp() {
20: call = new Call(getResolver(), null, "java.lang.Object",
21: "hashCode", null);
22: editor = new CallEditor(call);
23: tester = new JTextComponentTester();
24: }
25:
26: public void testMethodList() throws Throwable {
27: showFrame(editor);
28: JComboBox cb = getMethodComboBox(editor);
29: assertEquals("Wrong method selected", cb.getSelectedItem(),
30: "hashCode");
31: String[] expected = { "equals", "getClass", "hashCode",
32: "notify", "notifyAll", "toString", "wait", };
33: assertEquals("Wrong number of methods", expected.length, cb
34: .getItemCount());
35: for (int i = 0; i < cb.getItemCount(); i++) {
36: assertEquals("Wrong method in combo list", expected[i], cb
37: .getItemAt(i));
38: }
39: }
40:
41: public void testMethodListUpdateOnClassChange() throws Exception {
42: showFrame(editor);
43: JTextField tf = getTargetClassBox(editor);
44: JComboBox cb = getMethodComboBox(editor);
45: int count = cb.getItemCount();
46: String TEXT = "abbot.tester.ComponentTester";
47: tester.actionEnterText(tf, TEXT);
48: assertEquals("Text entered improperly", TEXT, tf.getText());
49: assertTrue("Method list was not updated", count != cb
50: .getItemCount());
51: }
52:
53: protected JTextField getTargetClassBox(CallEditor editor)
54: throws Exception {
55: return (JTextField) getFinder().find(editor,
56: new NameMatcher(TAG_CLASS));
57: }
58:
59: protected JComboBox getMethodComboBox(CallEditor editor)
60: throws Exception {
61: return (JComboBox) getFinder().find(editor,
62: new NameMatcher(TAG_METHOD));
63: }
64:
65: /** Construct a test case with the given name. */
66: public CallEditorTest(String name) {
67: super (name);
68: }
69:
70: /** Run the default test suite. */
71: public static void main(String[] args) {
72: RepeatHelper.runTests(args, CallEditorTest.class);
73: }
74: }
|