Search in sources :

Example 51 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project android_frameworks_base by ResurrectionRemix.

the class UiObject method clickAndWaitForNewWindow.

/**
     * Performs a click at the center of the visible bounds of the UI element represented
     * by this UiObject and waits for window transitions.
     *
     * This method differ from {@link UiObject#click()} only in that this method waits for a
     * a new window transition as a result of the click. Some examples of a window transition:
     * <li>launching a new activity</li>
     * <li>bringing up a pop-up menu</li>
     * <li>bringing up a dialog</li>
     *
     * @param timeout timeout before giving up on waiting for a new window
     * @return true if the event was triggered, else false
     * @throws UiObjectNotFoundException
     * @since API Level 16
     */
public boolean clickAndWaitForNewWindow(long timeout) throws UiObjectNotFoundException {
    Tracer.trace(timeout);
    AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
    if (node == null) {
        throw new UiObjectNotFoundException(getSelector().toString());
    }
    Rect rect = getVisibleBounds(node);
    return getInteractionController().clickAndWaitForNewWindow(rect.centerX(), rect.centerY(), mConfig.getActionAcknowledgmentTimeout());
}
Also used : Rect(android.graphics.Rect) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 52 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project android_frameworks_base by ResurrectionRemix.

the class UiObject method longClickTopLeft.

/**
     * Long clicks on the top and left corner of the UI element
     *
     * @return true if operation was successful
     * @throws UiObjectNotFoundException
     * @since API Level 16
     */
public boolean longClickTopLeft() throws UiObjectNotFoundException {
    Tracer.trace();
    AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
    if (node == null) {
        throw new UiObjectNotFoundException(getSelector().toString());
    }
    Rect rect = getVisibleBounds(node);
    return getInteractionController().longTapNoSync(rect.left + 5, rect.top + 5);
}
Also used : Rect(android.graphics.Rect) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 53 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project android_frameworks_base by ResurrectionRemix.

the class UiObject method pinchOut.

/**
     * Performs a two-pointer gesture, where each pointer moves diagonally
     * opposite across the other, from the center out towards the edges of the
     * this UiObject.
     * @param percent percentage of the object's diagonal length for the pinch gesture
     * @param steps the number of steps for the gesture. Steps are injected 
     * about 5 milliseconds apart, so 100 steps may take around 0.5 seconds to complete.
     * @return <code>true</code> if all touch events for this gesture are injected successfully,
     *         <code>false</code> otherwise
     * @throws UiObjectNotFoundException
     * @since API Level 18
     */
public boolean pinchOut(int percent, int steps) throws UiObjectNotFoundException {
    // make value between 1 and 100
    percent = (percent < 0) ? 1 : (percent > 100) ? 100 : percent;
    float percentage = percent / 100f;
    AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
    if (node == null) {
        throw new UiObjectNotFoundException(getSelector().toString());
    }
    Rect rect = getVisibleBounds(node);
    if (rect.width() <= FINGER_TOUCH_HALF_WIDTH * 2)
        throw new IllegalStateException("Object width is too small for operation");
    // start from the same point at the center of the control
    Point startPoint1 = new Point(rect.centerX() - FINGER_TOUCH_HALF_WIDTH, rect.centerY());
    Point startPoint2 = new Point(rect.centerX() + FINGER_TOUCH_HALF_WIDTH, rect.centerY());
    // End at the top-left and bottom-right corners of the control
    Point endPoint1 = new Point(rect.centerX() - (int) ((rect.width() / 2) * percentage), rect.centerY());
    Point endPoint2 = new Point(rect.centerX() + (int) ((rect.width() / 2) * percentage), rect.centerY());
    return performTwoPointerGesture(startPoint1, startPoint2, endPoint1, endPoint2, steps);
}
Also used : Rect(android.graphics.Rect) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Point(android.graphics.Point)

Example 54 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project android_frameworks_base by ResurrectionRemix.

the class UiScrollable method scrollBackward.

/**
     * Performs a backward scroll. If the swipe direction is set to vertical,
     * then the swipes will be performed from top to bottom. If the swipe
     * direction is set to horizontal, then the swipes will be performed from
     * left to right. Make sure to take into account devices configured with
     * right-to-left languages like Arabic and Hebrew.
     *
     * @param steps number of steps. Use this to control the speed of the scroll action.
     * @return true if scrolled, false if can't scroll anymore
     * @since API Level 16
     */
public boolean scrollBackward(int steps) throws UiObjectNotFoundException {
    Tracer.trace(steps);
    Log.d(LOG_TAG, "scrollBackward() on selector = " + getSelector());
    AccessibilityNodeInfo node = findAccessibilityNodeInfo(WAIT_FOR_SELECTOR_TIMEOUT);
    if (node == null) {
        throw new UiObjectNotFoundException(getSelector().toString());
    }
    Rect rect = new Rect();
    node.getBoundsInScreen(rect);
    int downX = 0;
    int downY = 0;
    int upX = 0;
    int upY = 0;
    // set otherwise by setAsHorizontalContainer()
    if (mIsVerticalList) {
        int swipeAreaAdjust = (int) (rect.height() * getSwipeDeadZonePercentage());
        Log.d(LOG_TAG, "scrollToBegining() using vertical scroll");
        // scroll vertically: swipe up -> down
        downX = rect.centerX();
        downY = rect.top + swipeAreaAdjust;
        upX = rect.centerX();
        upY = rect.bottom - swipeAreaAdjust;
    } else {
        int swipeAreaAdjust = (int) (rect.width() * getSwipeDeadZonePercentage());
        Log.d(LOG_TAG, "scrollToBegining() using hotizontal scroll");
        // scroll horizontally: swipe left -> right
        // TODO: Assuming device is not in right to left language
        downX = rect.left + swipeAreaAdjust;
        downY = rect.centerY();
        upX = rect.right - swipeAreaAdjust;
        upY = rect.centerY();
    }
    return getInteractionController().scrollSwipe(downX, downY, upX, upY, steps);
}
Also used : Rect(android.graphics.Rect) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 55 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project android_frameworks_base by ResurrectionRemix.

the class UiObject method isFocusable.

/**
     * Check if the UI element's <code>focusable</code> property is currently true.
     *
     * @return true if it is else false
     * @throws UiObjectNotFoundException
     * @since API Level 16
     */
public boolean isFocusable() throws UiObjectNotFoundException {
    Tracer.trace();
    AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
    if (node == null) {
        throw new UiObjectNotFoundException(getSelector().toString());
    }
    return node.isFocusable();
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Aggregations

AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)310 Point (android.graphics.Point)84 Rect (android.graphics.Rect)84 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)45 RemoteException (android.os.RemoteException)30 IAccessibilityInteractionConnectionCallback (android.view.accessibility.IAccessibilityInteractionConnectionCallback)30 SomeArgs (com.android.internal.os.SomeArgs)30 Region (android.graphics.Region)25 Paint (android.graphics.Paint)19 View (android.view.View)12 ViewRootImpl (android.view.ViewRootImpl)11 RemoteView (android.widget.RemoteViews.RemoteView)11 Display (android.view.Display)10 File (java.io.File)10 LinkedList (java.util.LinkedList)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 UiAutomation (android.app.UiAutomation)5 InputFilter (android.text.InputFilter)5 TextPaint (android.text.TextPaint)5