01: package abbot.script;
02:
03: import java.awt.Component;
04: import javax.swing.JTextField;
05: import java.util.HashMap;
06: import junit.extensions.abbot.*;
07:
08: public class PropertyCallTest extends ResolverFixture {
09:
10: public void testChangeType() throws Throwable {
11: ComponentReference ref = new ComponentReference(getResolver(),
12: Component.class, new HashMap());
13: getResolver().addComponentReference(ref);
14: PropertyCall step = new PCall(getResolver(), getName(),
15: abbot.tester.ComponentTester.class.getName(),
16: "assertFrameShowing", new String[] { "title" });
17: assertEquals("Default class should be ComponentTester",
18: abbot.tester.ComponentTester.class.getName(), step
19: .getTargetClassName());
20: step.setComponentID(ref.getID());
21: assertEquals("Target class should have changed",
22: Component.class.getName(), step.getTargetClassName());
23: }
24:
25: public void testMethodLookup() throws Throwable {
26: String text = "Custom Field";
27: // TODO need to check a class that *wasn't* loaded by the same class
28: // loader as this test.
29: JTextField tf = new TextFieldTestClass(text);
30: showFrame(tf);
31: ComponentReference ref = getResolver().addComponent(tf);
32: PropertyCall step = new PCall(getResolver(), getName(),
33: "getText", ref.getID());
34: step.run();
35: }
36:
37: public void testStaticMethodCall() throws Throwable {
38: PropertyCall step = new PCall(getResolver(), getName(),
39: getClass().getName(), "staticCall", new String[0]);
40: assertEquals("Wrong default class", getClass(), step
41: .getTargetClass());
42: }
43:
44: public PropertyCallTest(String name) {
45: super (name);
46: }
47:
48: public static void main(String[] args) {
49: TestHelper.runTests(args, PropertyCallTest.class);
50: }
51:
52: private class PCall extends PropertyCall {
53: public PCall(Resolver r, String d, String m, String id) {
54: super (r, d, m, id);
55: }
56:
57: public PCall(Resolver r, String d, String c, String m,
58: String[] a) {
59: super (r, d, c, m, a);
60: }
61: }
62:
63: public static void staticCall() {
64: }
65: }
66:
67: class TextFieldTestClass extends JTextField {
68: public TextFieldTestClass(String contents) {
69: super (contents);
70: }
71:
72: public String getText() {
73: return super.getText();
74: }
75: }
|