Package org.fest.swing.core

Examples of org.fest.swing.core.Robot


   * Runs the screenshot process.
   */
  public void run() {
    long start = System.currentTimeMillis();

    Robot robot = BasicRobot.robotWithNewAwtHierarchy();

    // set skin
    GuiActionRunner.execute(new GuiTask() {
      @Override
      protected void executeInEDT() throws Throwable {
        SubstanceLookAndFeel.setSkin(skin);
        JFrame.setDefaultLookAndFeelDecorated(true);
      }
    });
    robot.waitForIdle();

    // create the frame and set the icon image
    GuiActionRunner.execute(new GuiTask() {
      @Override
      protected void executeInEDT() throws Throwable {
        sf = new SampleFrame();
        sf.setIconImage(SubstanceImageCreator.getColorSchemeImage(null,
            new ImageIcon(SkinRobot.class.getClassLoader()
                .getResource(
                    "test/resource/image-x-generic.png")),
            SubstanceLookAndFeel.getCurrentSkin(sf.getRootPane())
                .getActiveColorScheme(
                    DecorationAreaType.PRIMARY_TITLE_PANE),
            0.0f));
        sf.setSize(338, 245);
        sf.setLocationRelativeTo(null);
        sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        sf.setVisible(true);
      }
    });
    robot.waitForIdle();

    // get the default button
    JButton defaultButton = GuiActionRunner
        .execute(new GuiQuery<JButton>() {
          @Override
          protected JButton executeInEDT() throws Throwable {
            return sf.getRootPane().getDefaultButton();
          }
        });
    // and move the mouse to it
    robot.moveMouse(defaultButton);
    robot.waitForIdle();

    // wait for a second
    Pause.pause(1000);

    // make the first screenshot
    GuiActionRunner.execute(new GuiTask() {
      @Override
      protected void executeInEDT() throws Throwable {
        makeScreenshot(1);
      }
    });
    robot.waitForIdle();

    // switch to the last tab
    GuiActionRunner.execute(new GuiTask() {
      @Override
      protected void executeInEDT() throws Throwable {
        sf.switchToLastTab();
      }
    });
    robot.waitForIdle();

    // move the mouse away from the frame
    robot.moveMouse(new Point(0, 0));
    robot.waitForIdle();

    // wait for two seconds
    Pause.pause(1000);

    // make the second screenshot
    GuiActionRunner.execute(new GuiTask() {
      @Override
      protected void executeInEDT() throws Throwable {
        makeScreenshot(2);
      }
    });
    robot.waitForIdle();

    // dispose the frame
    GuiActionRunner.execute(new GuiTask() {
      @Override
      protected void executeInEDT() throws Throwable {
        sf.dispose();
      }
    });
    robot.waitForIdle();

    long end = System.currentTimeMillis();
    System.out.println(this.getClass().getSimpleName() + " : "
        + (end - start) + "ms");
  }
View Full Code Here


  @Test
  public void testFocusHandling() throws FactoryException {

    MainUI ui = new MainUI();
    ui.withModelInteractor(pi);
    Robot robot = BasicRobot.robotWithCurrentAwtHierarchy();

    ui.main();
   
    //hit start
      robot.click(robot.finder().findByName(ButtonPanel.START_BUTTON_NAME));

   
    // perform tab key press and wait until it took place
    robot.pressAndReleaseKey(KeyEvent.VK_TAB);
    robot.waitForIdle();

    // perform left key press and wait until it took place
    robot.pressAndReleaseKey(KeyEvent.VK_LEFT);
    robot.waitForIdle();

    // verify that the game registered the left key press and that it didn't
    // lose focus
    verify(pi).left();
    assertTrue(ui.isFocusOwner());
View Full Code Here

TOP

Related Classes of org.fest.swing.core.Robot

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.