@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(); }
@Test public void scanningReachesClearFocusNode_shouldCallNoSelection() { OptionManager.ScanListener mockListener = mock(OptionManager.ScanListener.class); mOptionManager.setScanListener(mockListener); mActionNode2.recycle(); mSelectionNode = new OptionScanSelectionNode(mActionNode1, new ClearFocusNode()); mOptionManager.clearFocusIfNewTree(mSelectionNode); mOptionManager.selectOption(0); mOptionManager.selectOption(1); verify(mockListener, times(1)).onScanStart(); verify(mockListener, times(1)).onScanFocusChanged(); verify(mockListener, times(1)).onScanCompletedWithNoSelection(); verifyNoMoreInteractions(mockListener); }
@Test public void testScrollWithOneOptionThatSucceeds_shouldScrollAndClearFocus() { mCompat1.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); List<Integer> info1Actions = mShadowInfo1.getPerformedActions(); assertEquals(1, info1Actions.size()); assertEquals( new Integer(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD), info1Actions.get(0)); verify(mOverlayController, times(3)).clearOverlay(); }