Search in sources :

Example 6 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.

the class UiObject method longClick.

/**
     * Long clicks the center of the visible bounds of the UI element
     *
     * @return true if operation was successful
     * @throws UiObjectNotFoundException
     * @since API Level 16
     */
public boolean longClick() 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.centerX(), rect.centerY());
}
Also used : Rect(android.graphics.Rect) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 7 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.

the class UiObject method isScrollable.

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

Example 8 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.

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 9 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.

the class AccessibilityNodeInfoDumper method dumpNodeRec.

private static void dumpNodeRec(AccessibilityNodeInfo node, XmlSerializer serializer, int index, int width, int height) throws IOException {
    serializer.startTag("", "node");
    if (!nafExcludedClass(node) && !nafCheck(node))
        serializer.attribute("", "NAF", Boolean.toString(true));
    serializer.attribute("", "index", Integer.toString(index));
    serializer.attribute("", "text", safeCharSeqToString(node.getText()));
    serializer.attribute("", "resource-id", safeCharSeqToString(node.getViewIdResourceName()));
    serializer.attribute("", "class", safeCharSeqToString(node.getClassName()));
    serializer.attribute("", "package", safeCharSeqToString(node.getPackageName()));
    serializer.attribute("", "content-desc", safeCharSeqToString(node.getContentDescription()));
    serializer.attribute("", "checkable", Boolean.toString(node.isCheckable()));
    serializer.attribute("", "checked", Boolean.toString(node.isChecked()));
    serializer.attribute("", "clickable", Boolean.toString(node.isClickable()));
    serializer.attribute("", "enabled", Boolean.toString(node.isEnabled()));
    serializer.attribute("", "focusable", Boolean.toString(node.isFocusable()));
    serializer.attribute("", "focused", Boolean.toString(node.isFocused()));
    serializer.attribute("", "scrollable", Boolean.toString(node.isScrollable()));
    serializer.attribute("", "long-clickable", Boolean.toString(node.isLongClickable()));
    serializer.attribute("", "password", Boolean.toString(node.isPassword()));
    serializer.attribute("", "selected", Boolean.toString(node.isSelected()));
    serializer.attribute("", "bounds", AccessibilityNodeInfoHelper.getVisibleBoundsInScreen(node, width, height).toShortString());
    int count = node.getChildCount();
    for (int i = 0; i < count; i++) {
        AccessibilityNodeInfo child = node.getChild(i);
        if (child != null) {
            if (child.isVisibleToUser()) {
                dumpNodeRec(child, serializer, i, width, height);
                child.recycle();
            } else {
                Log.i(LOGTAG, String.format("Skipping invisible child: %s", child.toString()));
            }
        } else {
            Log.i(LOGTAG, String.format("Null child %d/%d, parent: %s", i, count, node.toString()));
        }
    }
    serializer.endTag("", "node");
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 10 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.

the class UiObject method click.

/**
     * Performs a click at the center of the visible bounds of the UI element represented
     * by this UiObject.
     *
     * @return true id successful else false
     * @throws UiObjectNotFoundException
     * @since API Level 16
     */
public boolean click() throws UiObjectNotFoundException {
    Tracer.trace();
    AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
    if (node == null) {
        throw new UiObjectNotFoundException(getSelector().toString());
    }
    Rect rect = getVisibleBounds(node);
    return getInteractionController().clickAndSync(rect.centerX(), rect.centerY(), mConfig.getActionAcknowledgmentTimeout());
}
Also used : Rect(android.graphics.Rect) 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