PopUpCoachMarkPresenter { protected void displayCoachMark() { CoachMarkPixelInfo coachMarkDimenInPixel = createCoachMarkPixelInfo(); @PopUpPosition int popUpPosition = findCoachMarkTextPopUpDisplayPosition(mCoachMarkBuilder.getAnchorTop(), mCoachMarkBuilder.getAnchorBottom(), mCoachMarkBuilder.getUserDesiredPopUpPositionWithRespectToView(), coachMarkDimenInPixel); if (popUpPosition == PopUpPosition.NONE) { mPresentation.dismissWithError( mStringResourceProvider.getStringFromResource(R.string.coachmark_no_position_found)); return; } setTypeFaceForDismissButton(mCoachMarkBuilder.getFontStyleForDismissButton()); setTypeFaceForCoachMarkText(mCoachMarkBuilder.getFontStyleForCoachMarkText()); setGravityForCoachMarkText(mCoachMarkBuilder.getCoachMarkTextGravity()); setMessageForCoachMarkText(mCoachMarkBuilder.getCoachMarkMessage()); setNotchDisplayEdge(popUpPosition, mCoachMarkBuilder.getAnchorTop().y, mCoachMarkBuilder.getAnchorBottom().y, mCoachMarkBuilder.getAnchorTop().x, coachMarkDimenInPixel); detectAndCreateShimOutViews(mCoachMarkBuilder.getInfoForViewToMaskList()); setImageParamsAndPosition(mCoachMarkBuilder.getAnchorTop(), mCoachMarkBuilder.getAnchorBottom(), coachMarkDimenInPixel.getImageWidthInPixels(), coachMarkDimenInPixel.getImageHeightInPixels(), mCoachMarkBuilder.getBackGroundTintForImage(), mCoachMarkBuilder.getImageDrawableRes()); mPresentation.startAnimationOnImage(mCoachMarkBuilder.getAnimationOnImage()); showCoachMark(mCoachMarkBuilder.getPopUpCoachMarkDismissButtonPosition(), popUpPosition); } 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 displayCoachMarkTest(){ PopUpCoachMarkPresenter spiedPopUpCoachMarkPresenter = Mockito.spy(new PopUpCoachMarkPresenter(mStringResourceProvider, mDimensionResourceProvider, mTypeFaceProvider, mScreenInfoProvider)); MockedPoint pointTop = new MockedPoint(400, 0); MockedPoint pointBottom = new MockedPoint(600,600); CoachMarkBuilder coachMarkBuilder = CoachMarkBuilder.create(pointTop, pointBottom, mockedStringRes).build(); spiedPopUpCoachMarkPresenter.onCreate(coachMarkBuilder); spiedPopUpCoachMarkPresenter.onCreateView(mPopUpCoachMarkPresentation); Mockito.doReturn(mCoachMarkPixelInfo).when(spiedPopUpCoachMarkPresenter) .createCoachMarkPixelInfo(); spiedPopUpCoachMarkPresenter.displayCoachMark(); Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)) .createCoachMarkPixelInfo(); Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)) .findCoachMarkTextPopUpDisplayPosition((Point) Matchers.anyObject(), (Point) Matchers.anyObject(), Matchers.anyInt(), (CoachMarkPixelInfo) Matchers.anyObject() ); Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)) .setTypeFaceForDismissButton(Matchers.anyString()); Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)) .setTypeFaceForCoachMarkText(Matchers.anyString()); Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)) .setGravityForCoachMarkText(Matchers.anyInt()); Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)) .setMessageForCoachMarkText(Matchers.anyInt()); Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)) .setNotchDisplayEdge(Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), (CoachMarkPixelInfo) Matchers.anyObject()); Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)) .detectAndCreateShimOutViews(Matchers.anyList()); Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)) .setImageParamsAndPosition((Point)Matchers.anyObject(),(Point)Matchers.anyObject(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt()); Mockito.verify(spiedPopUpCoachMarkPresenter, Mockito.times(1)) .showCoachMark(Matchers.anyInt(), Matchers.anyInt()); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)) .startAnimationOnImage(Matchers.anyInt()); }