Package org.fest.swing.util

Examples of org.fest.swing.util.TimeoutWatch


  protected final boolean waitForShowing(@Nonnull Component c, long timeout) {
    // TODO test
    if (robot.isReadyForInput(c)) {
      return true;
    }
    TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
    while (!robot.isReadyForInput(c)) {
      if (c instanceof JPopupMenu) {
        // move the mouse over the parent menu item to ensure the sub-menu shows
        Component invoker = ((JPopupMenu) c).getInvoker();
        if (invoker instanceof JMenu) {
          robot.jitter(invoker);
        }
      }
      if (watch.isTimeOut()) {
        return false;
      }
      pause();
    }
    return true;
View Full Code Here


  private void startWaiting(long timeout) {
    if (alreadyVisible()) {
      return;
    }
    TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
    while (!shown) {
      pause(DEFAULT_SLEEP_TIME);
      if (watch.isTimeOut()) {
        done();
        throw new WaitTimedOutError("Timed out waiting for component to be visible");
      }
    }
  }
View Full Code Here

   * @throws NullPointerException if the given condition is {@code null}.
   * @throws WaitTimedOutError if the wait times out.
   */
  public static void pause(@Nonnull Condition condition, long timeout) {
    checkNotNull(condition);
    TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
    while (!condition.test()) {
      if (watch.isTimeOut() && !condition.test()) {
        condition.done();
        throw new WaitTimedOutError(String.format("Timed out waiting for %s", condition.toString()));
      }
      pause(SLEEP_INTERVAL);
    }
View Full Code Here

   * @throws NullPointerException if the array of conditions has one or more {@code null} values.
   * @throws WaitTimedOutError if the wait times out.
   */
  public static void pause(@Nonnull Condition[] conditions, long timeout) {
    checkNotNullOrEmpty(conditions);
    TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
    while (!areSatisfied(conditions)) {
      if (watch.isTimeOut()) {
        for (Condition condition : conditions) {
          condition.done();
        }
        throw new WaitTimedOutError(String.format("Timed out waiting for %s", format(conditions)));
      }
View Full Code Here

   */
  @RunsInEDT
  @Nullable JList findDropDownList() {
    JPopupMenu popup = robot.findActivePopupMenu();
    if (popup == null) {
      TimeoutWatch watch = startWatchWithTimeoutOf(robot.settings().timeoutToFindPopup());
      popup = robot.findActivePopupMenu();
      while (popup == null) {
        if (watch.isTimeOut()) {
          return null;
        }
        pause();
        popup = robot.findActivePopupMenu();
      }
View Full Code Here

   * @throws ActionFailedException if there is no drag action in effect.
   */
  @RunsInEDT
  public void drop(@Nonnull Component target, @Nonnull Point where) {
    dragOver(target, where);
    TimeoutWatch watch = startWatchWithTimeoutOf(settings().eventPostingDelay() * 4);
    while (!robot.isDragging()) {
      if (watch.isTimeOut()) {
        throw actionFailure("There is no drag in effect");
      }
      pause();
    }
    int dropDelay = settings().dropDelay();
View Full Code Here

    // Make sure the correct window is in front
    activateWindowOfFocusTarget(target, currentOwner);
    giveFocusTo(target);
    try {
      if (wait) {
        TimeoutWatch watch = startWatchWithTimeoutOf(settings().timeoutToBeVisible());
        while (!focusMonitor.hasFocus()) {
          if (watch.isTimeOut()) {
            throw actionFailure(concat("Focus change to ", format(target), " failed"));
          }
          pause();
        }
      }
View Full Code Here

  @RunsInEDT
  private boolean waitForComponentToBeReady(@Nonnull Component c, long timeout) {
    if (isReadyForInput(c)) {
      return true;
    }
    TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
    while (!isReadyForInput(c)) {
      if (c instanceof JPopupMenu) {
        // wiggle the mouse over the parent menu item to ensure the sub-menu shows
        Pair<Component, Point> invokerAndCenterOfInvoker = invokerAndCenterOfInvoker((JPopupMenu) c);
        Component invoker = invokerAndCenterOfInvoker.first;
        if (invoker instanceof JMenu) {
          jitter(invoker, invokerAndCenterOfInvoker.second);
        }
      }
      if (watch.isTimeOut()) {
        return false;
      }
      pause();
    }
    return true;
View Full Code Here

  public @Nullable JPopupMenu findActivePopupMenu() {
    JPopupMenu popup = activePopupMenu();
    if (popup != null || isEventDispatchThread()) {
      return popup;
    }
    TimeoutWatch watch = startWatchWithTimeoutOf(POPUP_TIMEOUT);
    while ((popup = activePopupMenu()) == null) {
      if (watch.isTimeOut()) {
        break;
      }
      pause(100);
    }
    return popup;
View Full Code Here

   */
  @RunsInCurrentThread
  protected final boolean waitForShowing(Component c, long timeout) {
    // TODO test
    if (robot.isReadyForInput(c)) return true;
    TimeoutWatch watch = startWatchWithTimeoutOf(timeout);
    while (!robot.isReadyForInput(c)) {
      if (c instanceof JPopupMenu) {
        // move the mouse over the parent menu item to ensure the sub-menu shows
        Component invoker = ((JPopupMenu)c).getInvoker();
        if (invoker instanceof JMenu) robot.jitter(invoker);
      }
      if (watch.isTimeOut()) return false;
      pause();
    }
    return true;
  }
View Full Code Here

TOP

Related Classes of org.fest.swing.util.TimeoutWatch

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.