Ejemplo n.º 1
0
 @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();
 }
Ejemplo n.º 2
0
 @Test
 public void testLongClickWithTwoOptions_shouldDoNothing() {
   OptionScanSelectionNode superParentNode =
       new OptionScanSelectionNode(mSelectionNode, mSelectionNode);
   mOptionManager.clearFocusIfNewTree(superParentNode);
   mOptionManager.selectOption(0);
   mOptionManager.performLongClick();
   assertEquals(0, mShadowInfo1.getPerformedActions().size());
   assertEquals(0, mShadowInfo2.getPerformedActions().size());
 }
Ejemplo n.º 3
0
 @Test
 public void testMoveToParent_nowhereToGoWithWrap_shouldClearFocus() {
   mOptionManager.clearFocusIfNewTree(mSelectionNode);
   mOptionManager.selectOption(0);
   mOptionManager.moveToParent(true);
   /* Confirm that we're on null selection by moving to a child */
   mOptionManager.selectOption(0);
   assertEquals(0, mShadowInfo1.getPerformedActions().size());
   mOptionManager.selectOption(0);
   assertEquals(1, mShadowInfo1.getPerformedActions().size());
 }
Ejemplo n.º 4
0
 @After
 public void tearDown() {
   if (mSelectionNode != null) {
     mSelectionNode.recycle();
   }
   mCompat1.recycle();
   mCompat2.recycle();
   try {
     assertFalse(ShadowAccessibilityNodeInfo.areThereUnrecycledNodes(true));
   } finally {
     ShadowAccessibilityNodeInfo.resetObtainedInstances();
   }
 }
Ejemplo n.º 5
0
  @Before
  public void setUp() {
    ShadowAccessibilityNodeInfo.resetObtainedInstances();
    mCompat1 = new SwitchAccessNodeCompat(AccessibilityNodeInfo.obtain());
    mShadowInfo1 =
        (ShadowAccessibilityNodeInfo)
            ShadowExtractor.extract((AccessibilityNodeInfo) mCompat1.getInfo());
    mCompat2 = new SwitchAccessNodeCompat(AccessibilityNodeInfo.obtain());
    mShadowInfo2 =
        (ShadowAccessibilityNodeInfo)
            ShadowExtractor.extract((AccessibilityNodeInfo) mCompat2.getInfo());
    mSharedPreferences.edit().clear().commit();
    MockitoAnnotations.initMocks(this);
    mCompat1.setBoundsInScreen(NODE_BOUNDS_1);
    mCompat2.setBoundsInScreen(NODE_BOUNDS_2);
    mActionNode1 =
        new AccessibilityNodeActionNode(
            mCompat1,
            new AccessibilityNodeInfoCompat.AccessibilityActionCompat(
                AccessibilityNodeInfoCompat.ACTION_CLICK, "label1"));
    mActionNode2 =
        new AccessibilityNodeActionNode(
            mCompat2,
            new AccessibilityNodeInfoCompat.AccessibilityActionCompat(
                AccessibilityNodeInfoCompat.ACTION_CLICK, "label2"));
    mSelectionNode = new OptionScanSelectionNode(mActionNode1, mActionNode2);

    when(mOverlayController.getContext()).thenReturn(mContext);
    mOptionManager = new OptionManager(mOverlayController);
  }
Ejemplo n.º 6
0
 @Test
 public void testLongClickWithOneOptionThatSucceeds_shouldLongClickAndClearFocus() {
   mOptionManager.clearFocusIfNewTree(mSelectionNode);
   mOptionManager.selectOption(0);
   mOptionManager.performLongClick();
   List<Integer> info1Actions = mShadowInfo1.getPerformedActions();
   assertEquals(1, info1Actions.size());
   assertEquals(new Integer(AccessibilityNodeInfoCompat.ACTION_LONG_CLICK), info1Actions.get(0));
   verify(mOverlayController, times(3)).clearOverlay();
 }
Ejemplo n.º 7
0
 @Test
 public void testMoveToParent_fromNull_shouldWrap() {
   OptionScanSelectionNode topSelectionNode =
       new OptionScanSelectionNode(mActionNode1, mSelectionNode);
   mOptionManager.clearFocusIfNewTree(topSelectionNode);
   mOptionManager.moveToParent(true);
   /* Confirm that we're on mSelectionNode by moving to a child */
   mOptionManager.selectOption(0);
   assertEquals(1, mShadowInfo1.getPerformedActions().size());
 }
Ejemplo n.º 8
0
 @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();
 }
Ejemplo n.º 9
0
 @Test
 public void testNegativeSelection_shouldBeIgnored() {
   mOptionManager.clearFocusIfNewTree(mActionNode1);
   mOptionManager.selectOption(-1);
   assertEquals(0, mShadowInfo1.getPerformedActions().size());
 }
Ejemplo n.º 10
0
 @Test
 public void testOnlyOneActionNode_shouldPerformActionOnFirstSelect() {
   mOptionManager.clearFocusIfNewTree(mActionNode1);
   mOptionManager.selectOption(0);
   assertEquals(1, mShadowInfo1.getPerformedActions().size());
 }
Ejemplo n.º 11
0
 @Test
 public void testOnlyOneActionNode_shouldDoNothingBeforeSelection() {
   mOptionManager.clearFocusIfNewTree(mActionNode1);
   assertEquals(0, mShadowInfo1.getPerformedActions().size());
 }