Package junit.extensions.abbot

Examples of junit.extensions.abbot.Timer


            public void run() {
                JOptionPane.showMessageDialog(null, "cref", null,
                                              JOptionPane.PLAIN_MESSAGE);
            }
        });
        Timer timer = new Timer();
        while (true) {
            try {
                JButton button = (JButton)getFinder().
                    find(new ClassMatcher(JButton.class));
                // Create a reference, then dispose of its match
                ComponentReference existing = getResolver().addComponent(button);
                getHierarchy().dispose(SwingUtilities.getWindowAncestor(button));
                break;
            }
            catch(ComponentNotFoundException e) {
                getRobot().waitForIdle();
            }
            if (timer.elapsed() > 10000)
                fail("Timed out waiting for transient dialog to show");
        }

        Frame fa = new MyFrame("A");
        Frame fb = new MyFrame("B");
        Frame fc = new MyFrame("C");
        showWindow(fa);
        showWindow(fb);
        showWindow(fc);

        // find a button, any button will do
        JButton button2 = (JButton)getFinder().
            find(fa, new ClassMatcher(JButton.class));
       
        timer.reset();
        ComponentReference cref = resolver.addComponent(button2);

        assertTrue("Maximum reference creation time exceeded, elapsed time="
                   + timer.elapsed() + "ms",
                   timer.elapsed() < MAX_CREATION_TIME);
    }
View Full Code Here


        JButton button3 = (JButton)getFinder().
            find(fb, new ClassMatcher(JButton.class));
       
        ComponentReference cref = resolver.addComponent(button2);
        fa.setVisible(false);
        Timer timer = new Timer();
        ComponentReference cref2 = resolver.addComponent(button3);

        assertTrue("Maximum reference creation time exceeded, elapsed time="
                   + timer.elapsed() + "ms",
                   timer.elapsed() < MAX_CREATION_TIME);
    }
View Full Code Here

                parent = panel;
            }
            parent.add(button = new JButton("tab " + t));
        }
        showFrame(tabs);
        Timer timer = new Timer();
        ComponentReference ref = resolver.addComponent(button);
        if (timer.elapsed() > 500)
            fail("Creation of non-visible tabbed pane component took "
                 + timer.elapsed() + "ms");
    }
View Full Code Here

                chooser.showOpenDialog(null);
            }
        });
        // Wait for the dialog to post
        Window w;
        Timer timer = new Timer();
        while ((w = SwingUtilities.getWindowAncestor(chooser)) == null) {
            if (timer.elapsed() > 5000)
                fail("File chooser has no window");
            getRobot().sleep();
        }
        assertTrue("Wrong window selected: " + d, d != w);

        timer.reset();
        while (!w.isShowing()) {
            if (timer.elapsed() > 5000)
                fail("File chooser window is not showing");
            getRobot().sleep();
        }

        // NOTE: making the JFileChooser reference triggered a bug where this
View Full Code Here

        JPanel pane = new JPanel();
        int count = fill(pane, 8, 2) + 2;
        Frame f = showFrame(pane);
        StringWriter writer = new StringWriter();
        HierarchyWriter hw = new HierarchyWriter(getHierarchy());
        Timer timer = new Timer();
        hw.writeHierarchy(writer);
        int MAX_TIME = 2000;
        assertTrue("Too long to save hierarchy: " + timer.elapsed() + "ms for "
                   + count + " references (max total time " + MAX_TIME + "ms)",
                   timer.elapsed() < MAX_TIME);
    }
View Full Code Here

        ComponentTester tester = new ComponentTester();
        Component button =
            getFinder().find(w, new ClassMatcher(JButton.class));
        tester.actionClick(button);
        // Give the annotation thread time to clean up
        Timer timer = new Timer();
        while (ann.isShowing()) {
            getRobot().sleep();
            if (timer.elapsed() > 1000)
                fail("Annotation should be hidden after dismiss button activated");
        }
        timer.reset();
        while (ann.isRunning) {
            getRobot().sleep();
            if (timer.elapsed() > 1000)
                fail("Annotation step should have finished");
        }
        assertEquals("No exception should be thrown",
                     (Throwable)null, stepFailure);
    }
View Full Code Here

        int x = w.getX() + w.getWidth()/2;
        int y = w.getY() + w.getHeight()/2;
        robot.mouseMove(x, y);
        robot.mouseMove(x, y+1);
        Timer timer = new Timer();
        while (!flag1.flag || !flag2.flag) {
            if (timer.elapsed() > 5000) {
                fail("No motion event received: AWTEventListener=" + flag1.flag
                     + ", MouseListener=" + flag2.flag);
            }
        }
    }
View Full Code Here

        showFrame(label);
        java.awt.Point pt = label.getLocationOnScreen();
        robot.mouseMove(pt.x + label.getWidth()/2, pt.y + label.getHeight()/2);
        robot.mousePress(MouseEvent.BUTTON2_MASK);
        robot.mouseRelease(MouseEvent.BUTTON2_MASK);
        Timer timer = new Timer();
        while (!watcher.gotClick) {
            if (timer.elapsed() > EVENT_GENERATION_DELAY)
                fail("Never received button 2 click event");
            robot.delay(200);
        }
        assertEquals("This platform has bad robot button 2 mask mapping",
                     MouseEvent.BUTTON2_MASK, watcher.modifiers);

        watcher.gotClick = false;
        robot.mousePress(MouseEvent.BUTTON3_MASK);
        robot.mouseRelease(MouseEvent.BUTTON3_MASK);
        timer.reset();
        while (!watcher.gotClick) {
            if (timer.elapsed() > EVENT_GENERATION_DELAY)
                fail("Never received button 3 click event");
            robot.delay(200);
        }
        assertEquals("This platform has bad robot button 3 mask mapping",
                     MouseEvent.BUTTON3_MASK, watcher.modifiers);
View Full Code Here

        pt = list2.getLocationOnScreen();
        robot.mouseMove(pt.x + list2.getWidth()/2, pt.y + list2.getHeight()/2);
        robot.mousePress(MouseEvent.BUTTON1_MASK);
        robot.mouseRelease(MouseEvent.BUTTON1_MASK);
        robot.waitForIdle();
        Timer timer = new Timer();
        while (!mw1.gotClick) {
            if (timer.elapsed() > EVENT_GENERATION_DELAY)
                fail("Never received click event on first frame");
            robot.delay(200);
        }
        timer.reset();
        while (!mw2.gotClick) {
            if (timer.elapsed() > EVENT_GENERATION_DELAY)
                fail("Never received click event on second frame");
            robot.delay(200);
        }
        assertEquals("Multi-click counting should not span frames",
                     1, mw1.clickCount);
View Full Code Here

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    flag.flag = true;
                }
            });
            Timer timer = new Timer();
            while (!flag.flag) {
                if (timer.elapsed() > 5000)
                    fail("An active AWT Popup blocks the event queue");
                Thread.sleep(10);
            }
        }
        finally {
View Full Code Here

TOP

Related Classes of junit.extensions.abbot.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.