@Test public void testStartScanningWithListener_shouldCallScanStart() { OptionManager.ScanListener mockListener = mock(OptionManager.ScanListener.class); mOptionManager.setScanListener(mockListener); mOptionManager.clearFocusIfNewTree(mSelectionNode); mOptionManager.selectOption(0); verify(mockListener, times(1)).onScanStart(); verify(mockListener, times(1)).onScanFocusChanged(); verifyNoMoreInteractions(mockListener); }
@Test public void userAbortsScanWithExtraSwitch_shouldCallNoSelection() { OptionManager.ScanListener mockListener = mock(OptionManager.ScanListener.class); mOptionManager.setScanListener(mockListener); mOptionManager.clearFocusIfNewTree(mSelectionNode); mOptionManager.selectOption(0); mOptionManager.selectOption(2); verify(mockListener, times(1)).onScanStart(); verify(mockListener, times(1)).onScanFocusChanged(); verify(mockListener, times(1)).onScanCompletedWithNoSelection(); verifyNoMoreInteractions(mockListener); }
@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); }