コード例 #1
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);
  }
コード例 #2
0
 @After
 public void tearDown() {
   if (mSelectionNode != null) {
     mSelectionNode.recycle();
   }
   mCompat1.recycle();
   mCompat2.recycle();
   try {
     assertFalse(ShadowAccessibilityNodeInfo.areThereUnrecycledNodes(true));
   } finally {
     ShadowAccessibilityNodeInfo.resetObtainedInstances();
   }
 }
コード例 #3
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();
 }