PopUpCoachMarkPresenter { protected void setNotchDisplayEdge(int position, int anchorTopY, int anchorBottomY, int anchorTopX, CoachMarkPixelInfo coachMarkDimenInPixel) { int notchPosition; int actualTopMargin; int actualLeftMargin; int centerY = (anchorTopY + anchorBottomY) / 2; Rect notchMarginRect; Rect coachMarkMarginRect; Rect notchUiAdjustmentMarginRect; switch (position) { case PopUpPosition.LEFT: actualTopMargin = getActualTopMargin(centerY, coachMarkDimenInPixel); coachMarkMarginRect = new Rect(coachMarkDimenInPixel.getMarginRectInPixels().left, actualTopMargin - coachMarkDimenInPixel.getMarginRectInPixels().bottom, coachMarkDimenInPixel.getMarginRectInPixels().right + coachMarkDimenInPixel.getImageWidthInPixels(), NO_MARGIN); mPresentation.setPopUpViewTopLeft(coachMarkMarginRect, CoachMarkLayoutOrientation.HORIZONTAL); notchPosition = getMarginTopForNotch(mCoachMarkBuilder.getNotchPosition(), coachMarkDimenInPixel.getPopUpHeightInPixels(), coachMarkDimenInPixel.getNotchDimenInPixels()); notchMarginRect = new Rect(-coachMarkDimenInPixel.getMarginOffsetForNotchInPixels(), notchPosition, NO_MARGIN, NO_MARGIN); mPresentation.setNotchPositionIfPopUpTopLeft(notchMarginRect, ROTATION_90); break; case PopUpPosition.TOP: actualLeftMargin = getActualLeftMargin(anchorTopX, coachMarkDimenInPixel); coachMarkMarginRect = new Rect(actualLeftMargin - coachMarkDimenInPixel.getMarginRectInPixels().right, coachMarkDimenInPixel.getMarginRectInPixels().top, NO_MARGIN, coachMarkDimenInPixel.getMarginRectInPixels().bottom + coachMarkDimenInPixel.getImageHeightInPixels()); mPresentation.setPopUpViewTopLeft(coachMarkMarginRect, CoachMarkLayoutOrientation.VERTICAL); notchPosition = getMarginLeftForNotch(mCoachMarkBuilder.getNotchPosition(), coachMarkDimenInPixel.getPopUpWidthInPixels(), coachMarkDimenInPixel.getNotchDimenInPixels()); notchMarginRect = new Rect(notchPosition + coachMarkDimenInPixel.getMarginOffsetForNotchInPixels(), -coachMarkDimenInPixel.getMarginOffsetForNotchInPixels(), NO_MARGIN, NO_MARGIN); mPresentation.setNotchPositionIfPopUpTopLeft(notchMarginRect, ROTATION_180); break; case PopUpPosition.RIGHT: actualTopMargin = getActualTopMargin(centerY, coachMarkDimenInPixel); coachMarkMarginRect = new Rect(coachMarkDimenInPixel.getMarginRectInPixels().left + coachMarkDimenInPixel.getImageWidthInPixels(), actualTopMargin - coachMarkDimenInPixel.getMarginRectInPixels().bottom, coachMarkDimenInPixel.getMarginRectInPixels().right, NO_MARGIN); mPresentation.setPopUpViewBottomRight(coachMarkMarginRect, CoachMarkLayoutOrientation.HORIZONTAL); notchPosition = getMarginTopForNotch(mCoachMarkBuilder.getNotchPosition(), coachMarkDimenInPixel.getPopUpHeightInPixels(), coachMarkDimenInPixel.getNotchDimenInPixels()); notchMarginRect = new Rect(NO_MARGIN, notchPosition - (int) (MULTIPLICATION_FACTOR_NOTCH_POSITION * coachMarkDimenInPixel.getMarginOffsetForNotchInPixels()), NO_MARGIN, NO_MARGIN); mPresentation.setNotchPositionIfPopUpBottomRight(notchMarginRect, ROTATION_270); notchUiAdjustmentMarginRect = new Rect(NO_MARGIN, notchPosition + (int) (MULTIPLICATION_FACTOR_FOR_UI_ADJUSTMENT_RIGHT * coachMarkDimenInPixel.getMarginOffsetForNotchInPixels() + PIXEL_ADJUSTMENT_NOTCH), NO_MARGIN, NO_MARGIN); mPresentation.uiAdjustmentForNotchIfPopUpRight(notchUiAdjustmentMarginRect); break; case PopUpPosition.BOTTOM: actualLeftMargin = getActualLeftMargin(anchorTopX, coachMarkDimenInPixel); coachMarkMarginRect = new Rect(actualLeftMargin - coachMarkDimenInPixel.getMarginRectInPixels().right, coachMarkDimenInPixel.getMarginRectInPixels().top + coachMarkDimenInPixel.getImageHeightInPixels(), NO_MARGIN, coachMarkDimenInPixel.getMarginRectInPixels().bottom); mPresentation.setPopUpViewBottomRight(coachMarkMarginRect, CoachMarkLayoutOrientation.VERTICAL); notchPosition = getMarginLeftForNotch(mCoachMarkBuilder.getNotchPosition(), coachMarkDimenInPixel.getPopUpWidthInPixels(), coachMarkDimenInPixel.getNotchDimenInPixels()); notchMarginRect = new Rect(notchPosition + coachMarkDimenInPixel.getMarginOffsetForNotchInPixels(), NO_MARGIN, NO_MARGIN, NO_MARGIN); mPresentation.setNotchPositionIfPopUpBottomRight(notchMarginRect, ROTATION_0); notchUiAdjustmentMarginRect = new Rect(notchPosition + (int) (MULTIPLICATION_FACTOR_FOR_NOTCH_UI_ADJUSTMENT_BOTTOM * coachMarkDimenInPixel.getMarginOffsetForNotchInPixels()), NO_MARGIN, NO_MARGIN, NO_MARGIN); mPresentation.uiAdjustmentForNotchIfPopUpBottom(notchUiAdjustmentMarginRect); 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 setNotchDisplayEdgePopUpPositionLeftTest(){ mPopUpCoachMarkPresenter.setNotchDisplayEdge(PopUpPosition.LEFT, 600, 0, 600, mCoachMarkPixelInfo); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewTopLeft( (Rect)Matchers.anyObject(), Matchers.anyInt()); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setNotchPositionIfPopUpTopLeft((Rect)Matchers.anyObject(), Matchers.anyInt()); Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation); }
@Test public void setNotchDisplayEdgePopUpPositionTopTest(){ mPopUpCoachMarkPresenter.setNotchDisplayEdge(PopUpPosition.TOP, 600, 0, 600, mCoachMarkPixelInfo); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewTopLeft( (Rect)Matchers.anyObject(), Matchers.anyInt()); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setNotchPositionIfPopUpTopLeft((Rect)Matchers.anyObject(), Matchers.anyInt()); Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation); }
@Test public void setNotchDisplayEdgePopUpPositionBottomTest(){ mPopUpCoachMarkPresenter.setNotchDisplayEdge(PopUpPosition.BOTTOM, 600, 0, 600, mCoachMarkPixelInfo); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewBottomRight( (Rect)Matchers.anyObject(), Matchers.anyInt()); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)). setNotchPositionIfPopUpBottomRight((Rect)Matchers.anyObject(), Matchers.anyInt()); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).uiAdjustmentForNotchIfPopUpBottom ((Rect)Matchers.anyObject()); Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation); }
@Test public void setNotchDisplayEdgePopUpPositionRightTest(){ mPopUpCoachMarkPresenter.setNotchDisplayEdge(PopUpPosition.RIGHT, 600, 0, 600, mCoachMarkPixelInfo); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setPopUpViewBottomRight( (Rect)Matchers.anyObject(), Matchers.anyInt()); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).setNotchPositionIfPopUpBottomRight((Rect)Matchers.anyObject(), Matchers.anyInt()); Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(1)).uiAdjustmentForNotchIfPopUpRight ((Rect)Matchers.anyObject()); Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation); }