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);
}
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);
}
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;
}
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;
}
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 */
}
}
}
Aggregations