@Test public void testOptionScanningEnabled_highlightsMenuButton() { mSharedPreferences .edit() .putString( mContext.getString(R.string.pref_scanning_methods_key), mContext.getString(R.string.option_scanning_key)) .commit(); mOptionManager.onSharedPreferenceChanged(mSharedPreferences, null); when(mOverlayController.getMenuButtonLocation()).thenReturn(MENU_BUTTON_BOUNDS); /* add a context menu with two items to the tree */ CharSequence globalActionLabel0 = "global action label 0"; CharSequence globalActionLabel1 = "global action label 1"; GlobalActionNode globalNode0 = new GlobalActionNode(0, null, globalActionLabel0); GlobalActionNode globalNode1 = new GlobalActionNode(1, null, globalActionLabel1); ContextMenuNode contextMenu = new ContextMenuNode(globalNode0, globalNode1); mSelectionNode = new OptionScanSelectionNode(mSelectionNode, contextMenu); mOptionManager.clearFocusIfNewTree(mSelectionNode); mOptionManager.selectOption(0); verify(mOverlayController, times(1)).drawMenuButton(); ShadowHandler.runMainLooperToEndOfTasks(); verify(mOverlayController, times(2)) .highlightPerimeterOfRects(mHighlightCaptor.capture(), mPaintCaptor.capture()); List<Collection<Rect>> capturedHighlights = mHighlightCaptor.getAllValues(); assertTrue(capturedHighlights.get(0).contains(NODE_BOUNDS_1)); assertTrue(capturedHighlights.get(0).contains(NODE_BOUNDS_2)); assertTrue(capturedHighlights.get(1).contains(MENU_BUTTON_BOUNDS)); }