Exemplo n.º 1
0
  /* (non-Javadoc)
   * @see com.windowtester.runtime.IUIContext#dragTo(com.windowtester.runtime.locator.ILocator, int)
   */
  public IWidgetLocator dragTo(ILocator locator, int mods) throws WidgetSearchException {

    /*
     * This is a bit tricky since we don't want to handle conditions WHILE a key is
     * down and the actual drag is being done in a subclass who is free to handle conditions...
     *
     * The current work-around is to "go native"
     *
     */
    // LogHandler.log("modifiers in dragTo ignored -- not implemented");
    // go native so that conditions are not handled while the key is down
    boolean isStatePreDragNative = applicationContext.isNative(); // cache for restore
    applicationContext.setNative();
    try {
      getDriver().mouseDown(mods);
      return dragTo(locator);
    } finally {
      getDriver().mouseUp(mods);
      // restore state
      if (!isStatePreDragNative) applicationContext.setDefault();
    }
  }
Exemplo n.º 2
0
  /**
   * Check for any active conditions and handle them. If a condition is handled, original hover
   * context will be restored post condition handling.
   *
   * @return one of the following flags indicating what was processed: {@link
   *     IConditionMonitor#PROCESS_NONE} if conditions were processed but no conditions were
   *     satisfied, {@link IConditionMonitor#PROCESS_ONE_OR_MORE} if conditions were processed and
   *     at least on condition was satisfied, {@link IConditionMonitor#PROCESS_RECURSIVE} if
   *     conditions were already being processed and no additional action was taken.
   */
  public int handleConditions() {

    /*
     * Since conditions might access the UI thread, we need to skip them
     * in the Native case.
     */
    if (applicationContext.isNative()) return IConditionMonitor.PROCESS_NATIVE;

    // cache current info
    IHoverInfo hoverInfo = getDriver().getCurrentMouseHoverInfo();
    // process conditions
    int result = super.handleConditions();
    // if conditions were handled, restore hover context (if there is one)
    if (hoverInfo != null && result == IConditionMonitor.PROCESS_ONE_OR_MORE) {
      Point location = hoverInfo.getLocation();
      // notice we do this using the driver directly so that we don't retrigger
      // condition-handling...
      if (location != null) getDriver().mouseMove(location.x, location.y);
    }
    return result;
  }