01: package abbot.finder;
02:
03: import javax.swing.*;
04: import junit.extensions.abbot.*;
05:
06: /** Check version settings, and platform or JVM-specific bugs. */
07: public class BasicFinderTest extends ComponentTestFixture {
08:
09: public void testFindIconifiedJInternalFrame() throws Exception {
10: JDesktopPane p = new JDesktopPane();
11: JInternalFrame f = new JInternalFrame(getName());
12: p.add(f);
13: f.setIcon(true);
14: showFrame(p);
15: getFinder().find(new ComponentMatcher(f));
16: }
17:
18: public void testPopupReachableInHierarchy() throws Exception {
19: final JPopupMenu light = new JPopupMenu();
20: JMenuItem mi1, mi2;
21: light.add(mi1 = new JMenuItem("item"));
22: final JPopupMenu heavy = new JPopupMenu();
23: heavy.add(mi2 = new JMenuItem("item 1"));
24: heavy.add(new JMenuItem("item 2"));
25: heavy.add(new JMenuItem("item 3"));
26: heavy.add(new JMenuItem("item 4"));
27: heavy.add(new JMenuItem("item 5"));
28: heavy.add(new JMenuItem("item 6"));
29: final JLabel label1 = new JLabel("light");
30: final JLabel label2 = new JLabel("heavy");
31: installPopup(label1, light);
32: installPopup(label2, heavy);
33:
34: JPanel pane = new JPanel();
35: pane.add(label1);
36: pane.add(label2);
37: showFrame(pane);
38: getRobot().showPopupMenu(label1);
39: Matcher lightweightMatcher = new ComponentMatcher(light);
40: getFinder().find(lightweightMatcher);
41:
42: getRobot().click(mi1);
43: getRobot().waitForIdle();
44: try {
45: getFinder().find(lightweightMatcher);
46: fail("Should not find lightweight popup in hierarchy after it is hidden");
47: } catch (ComponentNotFoundException e) {
48: }
49:
50: getRobot().showPopupMenu(label2);
51: Matcher heavyMatcher = new ComponentMatcher(heavy);
52: getFinder().find(heavyMatcher);
53: getRobot().click(mi2);
54: getRobot().waitForIdle();
55: try {
56: getFinder().find(heavyMatcher);
57: fail("Should not find heavyweight popup in hierarchy after it is hidden");
58: } catch (ComponentNotFoundException e) {
59: }
60: }
61:
62: public BasicFinderTest(String name) {
63: super (name);
64: }
65:
66: public static void main(String[] args) {
67: TestHelper.runTests(args, BasicFinderTest.class);
68: }
69: }
|