Search in sources :

Example 31 with AccessibilityNodeInfo

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

the class ShadowAccessibilityNodeInfoTest method shouldWriteAndReadFromParcelCorrectly.

@Test
public void shouldWriteAndReadFromParcelCorrectly() {
    Parcel p = Parcel.obtain();
    node.setContentDescription("test");
    node.writeToParcel(p, 0);
    p.setDataPosition(0);
    AccessibilityNodeInfo anotherNode = AccessibilityNodeInfo.CREATOR.createFromParcel(p);
    assertThat(node).isEqualTo(anotherNode);
    node.setContentDescription(null);
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Parcel(android.os.Parcel) Test(org.junit.Test)

Example 32 with AccessibilityNodeInfo

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

the class ShadowAccessibilityWindowInfoTest method shouldHaveAssignedRoot.

@Test
public void shouldHaveAssignedRoot() {
    AccessibilityNodeInfo node = AccessibilityNodeInfo.obtain();
    shadow.setRoot(node);
    assertThat(shadow.getRoot()).isEqualTo(node);
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Test(org.junit.Test)

Example 33 with AccessibilityNodeInfo

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

the class ShadowAccessibilityNodeInfo method obtain.

@Implementation
public static AccessibilityNodeInfo obtain(View view) {
    // We explicitly avoid allocating the AccessibilityNodeInfo from the actual pool by using the
    // private constructor. Not doing so affects test suites which use both shadow and
    // non-shadow objects.
    final AccessibilityNodeInfo obtainedInstance = ReflectionHelpers.callConstructor(AccessibilityNodeInfo.class);
    final ShadowAccessibilityNodeInfo shadowObtained = ((ShadowAccessibilityNodeInfo) ShadowExtractor.extract(obtainedInstance));
    /*
     * We keep a separate list of actions for each object newly obtained
     * from a view, and perform a shallow copy during getClone. That way the
     * list of actions performed contains all actions performed on the view
     * by the tree of nodes initialized from it. Note that initializing two
     * nodes with the same view will not merge the two lists, as so the list
     * of performed actions will not contain all actions performed on the
     * underlying view.
     */
    shadowObtained.performedActionAndArgsList = new LinkedList<>();
    shadowObtained.view = view;
    sAllocationCount++;
    StrictEqualityNodeWrapper wrapper = new StrictEqualityNodeWrapper(obtainedInstance);
    obtainedInstances.put(wrapper, Thread.currentThread().getStackTrace());
    orderedInstances.put(sAllocationCount, wrapper);
    return obtainedInstance;
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Implementation(org.robolectric.annotation.Implementation)

Example 34 with AccessibilityNodeInfo

use of android.view.accessibility.AccessibilityNodeInfo in project cornerstone by Onskreen.

the class ViewRootImpl method setAccessibilityFocus.

void setAccessibilityFocus(View view, AccessibilityNodeInfo node) {
    // to clear the focus and invalidate the virtual view bounds.
    if (mAccessibilityFocusedVirtualView != null) {
        AccessibilityNodeInfo focusNode = mAccessibilityFocusedVirtualView;
        View focusHost = mAccessibilityFocusedHost;
        focusHost.clearAccessibilityFocusNoCallbacks();
        // Wipe the state of the current accessibility focus since
        // the call into the provider to clear accessibility focus
        // will fire an accessibility event which will end up calling
        // this method and we want to have clean state when this
        // invocation happens.
        mAccessibilityFocusedHost = null;
        mAccessibilityFocusedVirtualView = null;
        AccessibilityNodeProvider provider = focusHost.getAccessibilityNodeProvider();
        if (provider != null) {
            // Invalidate the area of the cleared accessibility focus.
            focusNode.getBoundsInParent(mTempRect);
            focusHost.invalidate(mTempRect);
            // Clear accessibility focus in the virtual node.
            final int virtualNodeId = AccessibilityNodeInfo.getVirtualDescendantId(focusNode.getSourceNodeId());
            provider.performAction(virtualNodeId, AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS, null);
        }
        focusNode.recycle();
    }
    if (mAccessibilityFocusedHost != null) {
        // Clear accessibility focus in the view.
        mAccessibilityFocusedHost.clearAccessibilityFocusNoCallbacks();
    }
    // Set the new focus host and node.
    mAccessibilityFocusedHost = view;
    mAccessibilityFocusedVirtualView = node;
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) AccessibilityNodeProvider(android.view.accessibility.AccessibilityNodeProvider) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 35 with AccessibilityNodeInfo

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

the class AccessibilityInteractionController method findAccessibilityNodeInfosByViewIdUiThread.

private void findAccessibilityNodeInfosByViewIdUiThread(Message message) {
    final int flags = message.arg1;
    final int accessibilityViewId = message.arg2;
    SomeArgs args = (SomeArgs) message.obj;
    final int interactionId = args.argi1;
    final IAccessibilityInteractionConnectionCallback callback = (IAccessibilityInteractionConnectionCallback) args.arg1;
    final MagnificationSpec spec = (MagnificationSpec) args.arg2;
    final String viewId = (String) args.arg3;
    args.recycle();
    final List<AccessibilityNodeInfo> infos = mTempAccessibilityNodeInfoList;
    infos.clear();
    try {
        if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {
            return;
        }
        mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = flags;
        View root = null;
        if (accessibilityViewId != AccessibilityNodeInfo.UNDEFINED) {
            root = findViewByAccessibilityId(accessibilityViewId);
        } else {
            root = mViewRootImpl.mView;
        }
        if (root != null) {
            final int resolvedViewId = root.getContext().getResources().getIdentifier(viewId, null, null);
            if (resolvedViewId <= 0) {
                return;
            }
            if (mAddNodeInfosForViewId == null) {
                mAddNodeInfosForViewId = new AddNodeInfosForViewId();
            }
            mAddNodeInfosForViewId.init(resolvedViewId, infos);
            root.findViewByPredicate(mAddNodeInfosForViewId);
            mAddNodeInfosForViewId.reset();
        }
    } finally {
        try {
            mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0;
            applyAppScaleAndMagnificationSpecIfNeeded(infos, spec);
            if (spec != null) {
                spec.recycle();
            }
            callback.setFindAccessibilityNodeInfosResult(infos, interactionId);
        } catch (RemoteException re) {
        /* ignore - the other side will time out */
        }
    }
}
Also used : IAccessibilityInteractionConnectionCallback(android.view.accessibility.IAccessibilityInteractionConnectionCallback) SomeArgs(com.android.internal.os.SomeArgs) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

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