PopUpCoachMarkPresenter { protected void showCoachMark(@DialogDismissButtonPosition int dismissButtonPosition, @PopUpPosition int popUpPosition) { switch (popUpPosition) { case PopUpPosition.LEFT: mPresentation.setPopUpViewPositionWithRespectToImage( CoachMarkAlignPosition.ALIGN_RIGHT); break; case PopUpPosition.TOP: mPresentation.setPopUpViewPositionWithRespectToImage( CoachMarkAlignPosition.ALIGN_BOTTOM); break; case PopUpPosition.RIGHT: mPresentation.setPopUpViewPositionWithRespectToImage( CoachMarkAlignPosition.ALIGN_LEFT); break; case PopUpPosition.BOTTOM: mPresentation.setPopUpViewPositionWithRespectToImage( CoachMarkAlignPosition.ALIGN_TOP); break; case PopUpPosition.NONE: Log.wtf(TAG, "This should not have happened here. No position found case already handled"); break; } if(popUpPosition == PopUpPosition.NONE){ return; } switch (dismissButtonPosition) { case DialogDismissButtonPosition.LEFT: mPresentation.setDismissButtonPositionLeft(); break; case DialogDismissButtonPosition.RIGHT: mPresentation.setDismissButtonPositionRight(); break; } } PopUpCoachMarkPresenter(final IStringResourceProvider stringResourceProvider,
                                   final IDimensionResourceProvider dimensionResourceProvider,
                                   final ITypeFaceProvider typeFaceProvider,
                                   final IScreenInfoProvider screenInfoProvider); void onCreate(CoachMarkBuilder coachMarkBuilder); void onCreateView(IPopUpCoachMarkPresentation popUpCoachMarkPresentation); void onViewCreated(); void onDestroyView(); void onDestroy(); void onOkButtonClicked(); void onShimClicked();  }
@Test public void showCoachMarkPositionLeftTest(){ mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.LEFT, PopUpPosition.LEFT); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)). setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_RIGHT); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)) .setDismissButtonPositionLeft(); Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation); }
@Test public void showCoachMarkPositionRightTest(){ mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.LEFT, PopUpPosition.RIGHT); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)). setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_LEFT); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)) .setDismissButtonPositionLeft(); Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation); }
@Test public void showCoachMarkPositionTopTest(){ mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.LEFT, PopUpPosition.TOP); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)). setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_BOTTOM); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)) .setDismissButtonPositionLeft(); Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation); }
@Test public void showCoachMarkPositionBottomTest(){ mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.LEFT, PopUpPosition.BOTTOM); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)). setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_TOP); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)) .setDismissButtonPositionLeft(); Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation); }
@Test public void showCoachMarkPositionNoneTest(){ PowerMockito.mockStatic(Log.class); PowerMockito.when(Log.wtf(Matchers.anyString(), Matchers.anyString())).thenReturn(1); mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.LEFT, PopUpPosition.NONE); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(0)). setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_TOP); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(0)) .setDismissButtonPositionLeft(); Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation); }
@Test public void showCoachMarkPositionTopDialogDismissButtonRightTest(){ mPopUpCoachMarkPresenter.showCoachMark(DialogDismissButtonPosition.RIGHT, PopUpPosition.TOP); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)). setPopUpViewPositionWithRespectToImage(CoachMarkAlignPosition.ALIGN_BOTTOM); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)) .setDismissButtonPositionRight(); Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation); }