@Test public void testScrollWithParent_shouldScrollAndClearFocus() { AccessibilityNodeInfoCompat parent = AccessibilityNodeInfoCompat.obtain(); ((ShadowAccessibilityNodeInfoCompat) ShadowExtractor.extract(parent)).addChild(mCompat1); ShadowAccessibilityNodeInfo shadowParent = (ShadowAccessibilityNodeInfo) ShadowExtractor.extract(parent.getInfo()); parent.setScrollable(true); mActionNode1.recycle(); mActionNode1 = new AccessibilityNodeActionNode( mCompat1, new AccessibilityNodeInfoCompat.AccessibilityActionCompat( AccessibilityNodeInfoCompat.ACTION_CLICK, "label1")); mSelectionNode = new OptionScanSelectionNode(mActionNode1, mActionNode2); mOptionManager.clearFocusIfNewTree(mSelectionNode); mOptionManager.selectOption(0); mOptionManager.performScrollAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD); assertEquals(0, mShadowInfo1.getPerformedActions().size()); List<Integer> parentActions = shadowParent.getPerformedActions(); assertEquals(1, parentActions.size()); assertEquals( new Integer(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD), parentActions.get(0)); verify(mOverlayController, times(3)).clearOverlay(); parent.recycle(); }
/** Logs the tree using the input node as the root. */ public static void logNodeTree(AccessibilityNodeInfoCompat node) { if (node == null) { return; } HashSet<AccessibilityNodeInfoCompat> seen = new HashSet<AccessibilityNodeInfoCompat>(); logNodeTree(AccessibilityNodeInfoCompat.obtain(node), "", seen); for (AccessibilityNodeInfoCompat n : seen) { n.recycle(); } }
@Override public void onInitializeAccessibilityNodeInfo(View object, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { AccessibilityNodeInfoCompat accessibilityNodeInfoCompat2 = AccessibilityNodeInfoCompat.obtain(accessibilityNodeInfoCompat); super.onInitializeAccessibilityNodeInfo((View)object, accessibilityNodeInfoCompat2); this.copyNodeInfoNoChildren(accessibilityNodeInfoCompat, accessibilityNodeInfoCompat2); accessibilityNodeInfoCompat2.recycle(); accessibilityNodeInfoCompat.setClassName((CharSequence)SlidingPaneLayout.class.getName()); accessibilityNodeInfoCompat.setSource((View)object); object = ViewCompat.getParentForAccessibility((View)object); if (object instanceof View) { accessibilityNodeInfoCompat.setParent((View)object); } int n = SlidingPaneLayout.this.getChildCount(); for (int i = 0; i < n; ++i) { object = SlidingPaneLayout.this.getChildAt(i); if (this.filter((View)object) || object.getVisibility() != 0) continue; ViewCompat.setImportantForAccessibility((View)object, 1); accessibilityNodeInfoCompat.addChild((View)object); } }
public final void onInitializeAccessibilityNodeInfo( View view, AccessibilityNodeInfoCompat accessibilitynodeinfocompat) { AccessibilityNodeInfoCompat accessibilitynodeinfocompat1 = AccessibilityNodeInfoCompat.obtain(accessibilitynodeinfocompat); super.onInitializeAccessibilityNodeInfo(view, accessibilitynodeinfocompat1); accessibilitynodeinfocompat.setClassName( com / roidapp / baselib / view / FixedDrawerLayout.getName()); accessibilitynodeinfocompat.setSource(view); Object obj = ViewCompat.getParentForAccessibility(view); if (obj instanceof View) { accessibilitynodeinfocompat.setParent((View) obj); } obj = b; accessibilitynodeinfocompat1.getBoundsInParent(((Rect) (obj))); accessibilitynodeinfocompat.setBoundsInParent(((Rect) (obj))); accessibilitynodeinfocompat1.getBoundsInScreen(((Rect) (obj))); accessibilitynodeinfocompat.setBoundsInScreen(((Rect) (obj))); accessibilitynodeinfocompat.setVisibleToUser(accessibilitynodeinfocompat1.isVisibleToUser()); accessibilitynodeinfocompat.setPackageName(accessibilitynodeinfocompat1.getPackageName()); accessibilitynodeinfocompat.setClassName(accessibilitynodeinfocompat1.getClassName()); accessibilitynodeinfocompat.setContentDescription( accessibilitynodeinfocompat1.getContentDescription()); accessibilitynodeinfocompat.setEnabled(accessibilitynodeinfocompat1.isEnabled()); accessibilitynodeinfocompat.setClickable(accessibilitynodeinfocompat1.isClickable()); accessibilitynodeinfocompat.setFocusable(accessibilitynodeinfocompat1.isFocusable()); accessibilitynodeinfocompat.setFocused(accessibilitynodeinfocompat1.isFocused()); accessibilitynodeinfocompat.setAccessibilityFocused( accessibilitynodeinfocompat1.isAccessibilityFocused()); accessibilitynodeinfocompat.setSelected(accessibilitynodeinfocompat1.isSelected()); accessibilitynodeinfocompat.setLongClickable(accessibilitynodeinfocompat1.isLongClickable()); accessibilitynodeinfocompat.addAction(accessibilitynodeinfocompat1.getActions()); accessibilitynodeinfocompat1.recycle(); view = (ViewGroup) view; int j = view.getChildCount(); for (int i = 0; i < j; i++) { View view1 = view.getChildAt(i); if (FixedDrawerLayout.h(view1)) { accessibilitynodeinfocompat.addChild(view1); } } }