01: package abbot.editor.editors;
02:
03: import java.util.ArrayList;
04:
05: import javax.swing.JComboBox;
06:
07: import junit.extensions.abbot.*;
08: import abbot.Log;
09: import abbot.script.*;
10: import abbot.finder.matchers.ClassMatcher;
11:
12: /** Verify ActionEditor operation. */
13:
14: public class ActionEditorTest extends ResolverFixture {
15:
16: private Action action;
17: private ActionEditor editor;
18:
19: protected void setUp() {
20: action = new Action(getResolver(), null, "actionClick",
21: new String[] { "MethodSelector" }, JComboBox.class);
22: editor = new ActionEditor(action);
23: }
24:
25: public void testComponentTesterMethodList() throws Throwable {
26: showFrame(editor);
27:
28: JComboBox cb = (JComboBox) getFinder().find(
29: new ClassMatcher(JComboBox.class));
30: action.getResolver().addComponent(cb);
31:
32: assertEquals("Wrong method selected", "actionClick", cb
33: .getSelectedItem());
34: ArrayList list = new ArrayList();
35: for (int i = 0; i < cb.getItemCount(); i++) {
36: Log.debug("Got " + cb.getItemAt(i));
37: list.add(cb.getItemAt(i));
38: }
39: assertTrue("No items in the list", cb.getItemCount() > 0);
40: String[] expected = { "actionClick", "actionFocus",
41: "actionKeyStroke",
42: // Combo box methods
43: "actionSelectIndex", "actionSelectItem", };
44: for (int i = 0; i < expected.length; i++) {
45: assertTrue(expected[i] + " missing", list
46: .contains(expected[i]));
47: }
48: }
49:
50: /** Construct a test case with the given name. */
51: public ActionEditorTest(String name) {
52: super (name);
53: }
54:
55: /** Run the default test suite. */
56: public static void main(String[] args) {
57: TestHelper.runTests(args, ActionEditorTest.class);
58: }
59: }
|