Package org.fest.swing.test.util

Examples of org.fest.swing.test.util.StopWatch


* @author Alex Ruiz
*/
public class Pause_pauseWithTimeoutInTimeUnit_Test {
  @Test
  public void should_pause_for_the_given_amount_of_time() {
    StopWatch watch = startNewStopWatch();
    long delay = 2000;
    Pause.pause(2, TimeUnit.SECONDS);
    watch.stop();
    assertThat(watch.ellapsedTime() >= delay).isTrue();
  }
View Full Code Here


public class Pause_pauseWithCondition_Test {
  @Test
  public void should_wait_till_Condition_is_satisfied() {
    int timeToWaitTillSatisfied = 1000;
    SatisfiedCondition condition = new SatisfiedCondition(timeToWaitTillSatisfied);
    StopWatch watch = startNewStopWatch();
    Pause.pause(condition);
    watch.stop();
    assertThat(watch.ellapsedTime() >= timeToWaitTillSatisfied).isTrue();
    assertThat(condition.satisfied).isTrue();
  }
View Full Code Here

  @Test
  public void should_wait_till_Conditions_are_satisfied() {
    int timeToWaitTillSatisfied = 1000;
    SatisfiedCondition one = new SatisfiedCondition(timeToWaitTillSatisfied);
    SatisfiedCondition two = new SatisfiedCondition(timeToWaitTillSatisfied);
    StopWatch watch = startNewStopWatch();
    Pause.pause(new Condition[] { one, two });
    watch.stop();
    assertThat(watch.ellapsedTime() >= timeToWaitTillSatisfied).isTrue();
    assertThat(one.satisfied).isTrue();
    assertThat(two.satisfied).isTrue();
  }
View Full Code Here

* @author Alex Ruiz
*/
public class Pause_pauseWithTimeoutInMilliseconds_Test {
  @Test
  public void should_pause_for_the_given_amount_of_time() {
    StopWatch watch = startNewStopWatch();
    long delay = 2000;
    Pause.pause(delay);
    watch.stop();
    assertThat(watch.ellapsedTime() >= delay).isTrue();
  }
View Full Code Here

  public void should_give_focus_to_Component_and_wait_till_it_is_focused() {
    showWindow();
    assertThatButtonDoesNotHaveFocus();
    window.button.waitToRequestFocus();
    final CountDownLatch done = new CountDownLatch(1);
    StopWatch stopWatch = startNewStopWatch();
    new Thread() {
      @Override
      public void run() {
        driver.focusAndWaitForFocusGain(window.button);
        done.countDown();
      }
    }.start();
    try {
      done.await();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
    stopWatch.stop();
    assertThatButtonHasFocus();
    assertThatWaited(stopWatch, TIME_TO_WAIT_FOR_FOCUS_GAIN);
  }
View Full Code Here

    verify(inputState).update(event);
    verify(eventQueue).postEvent(event);
  }

  private void postEventAndAssertItWaited(Component c) {
    StopWatch stopWatch = startNewStopWatch();
    poster.postEvent(c, event);
    stopWatch.stop();
    assertThat(stopWatch.ellapsedTime()).isGreaterThanOrEqualTo(WAIT_DELAY);
  }
View Full Code Here

    window = TestWindow.createNewWindow(getClass());
  }

  @Test
  public void should_timeout_if_Component_never_shown() {
    StopWatch stopWatch = startNewStopWatch();
    int timeout = 500;
    try {
      ComponentShownWaiter.waitTillShown(window, timeout);
      failWhenExpectingException();
    } catch (WaitTimedOutError e) {
      stopWatch.stop();
    }
    assertThat(stopWatch.ellapsedTime()).isGreaterThanOrEqualTo(timeout);
  }
View Full Code Here

    assertThat(stopWatch.ellapsedTime()).isGreaterThanOrEqualTo(timeout);
  }

  @Test
  public void should_wait_till_Component_is_shown() {
    StopWatch stopWatch = startNewStopWatch();
    int timeout = 10000;
    new Thread() {
      @Override
      public void run() {
        pause(1000);
        robot.showWindow(window);
      }
    }.start();
    ComponentShownWaiter.waitTillShown(window, timeout);
    stopWatch.stop();
    assertThat(stopWatch.ellapsedTime()).isLessThan(timeout);
  }
View Full Code Here

  }

  @Test
  public void should_not_wait_if_Component_is_already_shown() {
    robot.showWindow(window);
    StopWatch stopWatch = startNewStopWatch();
    ComponentShownWaiter.waitTillShown(window, 10000);
    stopWatch.stop();
    assertThat(stopWatch.ellapsedTime()).isLessThan(10);
  }
View Full Code Here

    window = TestWindow.createNewWindow(getClass());
  }

  @Test
  public void should_use_default_timeout() {
    StopWatch stopWatch = startNewStopWatch();
    try {
      ComponentShownWaiter.waitTillShown(window);
      failWhenExpectingException();
    } catch (WaitTimedOutError e) {
      stopWatch.stop();
    }
    assertThat(stopWatch.ellapsedTime()).isGreaterThanOrEqualTo(5000);
  }
View Full Code Here

TOP

Related Classes of org.fest.swing.test.util.StopWatch

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.