01: package abbot.editor.editors;
02:
03: import java.awt.event.*;
04:
05: import javax.swing.JLabel;
06:
07: import junit.extensions.abbot.*;
08: import abbot.script.*;
09:
10: /** Verify EventEditor operation. */
11:
12: public class EventEditorTest extends ResolverFixture {
13:
14: private Event event;
15: private EventEditor editor;
16:
17: public void testMouseEvent() {
18: JLabel label = new JLabel(getName());
19: showFrame(label);
20: MouseEvent me = new MouseEvent(label, MouseEvent.MOUSE_MOVED,
21: System.currentTimeMillis(), MouseEvent.BUTTON1_MASK, 2,
22: 3, 1, false);
23: event = new Event(getResolver(), "mouse press", me);
24: String refid = event.getComponentID();
25: editor = new EventEditor(event);
26: // expect description, type, kind, component, x, y
27: assertEquals("Wrong number of fields", 6, editor
28: .getComponents().length / 4);
29: assertTrue("Type field should not be enabled", !editor.type
30: .isEnabled());
31: assertTrue("Kind field should not be enabled", !editor.kind
32: .isEnabled());
33:
34: assertEquals("Wrong Component", refid, editor.cref
35: .getSelectedItem());
36:
37: }
38:
39: public void testKeyEvent() {
40: JLabel label = new JLabel(getName());
41: showFrame(label);
42: KeyEvent ke = new KeyEvent(label, KeyEvent.KEY_PRESSED, System
43: .currentTimeMillis(), 0, KeyEvent.VK_A,
44: KeyEvent.CHAR_UNDEFINED);
45: event = new Event(getResolver(), "key press", ke);
46: String refid = event.getComponentID();
47: editor = new EventEditor(event);
48: // expect description, type, kind, component, keycode
49: assertEquals("Wrong number of fields", 5, editor
50: .getComponents().length / 4);
51: assertTrue("Type field should not be enabled", !editor.type
52: .isEnabled());
53: assertTrue("Kind field should not be editable", !editor.kind
54: .isEditable());
55:
56: assertEquals("Wrong Component", refid, editor.cref
57: .getSelectedItem());
58: }
59:
60: /** Construct a test case with the given name. */
61: public EventEditorTest(String name) {
62: super (name);
63: }
64:
65: /** Run the default test suite. */
66: public static void main(String[] args) {
67: TestHelper.runTests(args, EventEditorTest.class);
68: }
69: }
|