PopUpCoachMarkPresenter { @PopUpPosition protected int getDisplayPosition(Point viewCenterPoint, @PopUpPosition int defaultPopUpPosition, CoachMarkPixelInfo coachMarkDimenInPixel) { @PopUpPosition int correctPosition = 0; switch (defaultPopUpPosition) { case PopUpPosition.LEFT: if (checkIfLeftPossible(viewCenterPoint, coachMarkDimenInPixel)) { correctPosition = defaultPopUpPosition; } else { correctPosition = getCorrectPositionOfCoachMarkIfDefaultFails(viewCenterPoint, coachMarkDimenInPixel); } break; case PopUpPosition.RIGHT: if (checkIfRightPossible(viewCenterPoint, coachMarkDimenInPixel)) { correctPosition = defaultPopUpPosition; } else { correctPosition = getCorrectPositionOfCoachMarkIfDefaultFails(viewCenterPoint, coachMarkDimenInPixel); } break; case PopUpPosition.BOTTOM: if (checkIfBottomPossible(viewCenterPoint, coachMarkDimenInPixel)) { correctPosition = defaultPopUpPosition; } else { correctPosition = getCorrectPositionOfCoachMarkIfDefaultFails(viewCenterPoint, coachMarkDimenInPixel); } break; case PopUpPosition.TOP: if (checkIfTopPossible(viewCenterPoint, coachMarkDimenInPixel)) { correctPosition = defaultPopUpPosition; } else { correctPosition = getCorrectPositionOfCoachMarkIfDefaultFails(viewCenterPoint, coachMarkDimenInPixel); } break; case PopUpPosition.NONE: correctPosition = getCorrectPositionOfCoachMarkIfDefaultFails(viewCenterPoint, coachMarkDimenInPixel); break; } return correctPosition; } 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 getDisplayPositionLeftDefaultPassTest(){ MockedPoint point = new MockedPoint(600, 300); assertEquals(PopUpPosition.LEFT,mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.LEFT, mCoachMarkPixelInfo)); }
@Test public void getDisplayPositionLeftDefaultFailTest(){ MockedPoint point = new MockedPoint(0, 300); assertEquals(PopUpPosition.RIGHT,mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.LEFT, mCoachMarkPixelInfo)); }
@Test public void getDisplayPositionRightDefaultPassTest(){ MockedPoint point = new MockedPoint(400, 300); assertEquals(PopUpPosition.RIGHT,mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.RIGHT, mCoachMarkPixelInfo)); }
@Test public void getDisplayPositionRightDefaultFailTest(){ MockedPoint point = new MockedPoint(760, 300); assertEquals(PopUpPosition.BOTTOM,mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.RIGHT, mCoachMarkPixelInfo)); }
@Test public void getDisplayPositionTopDefaultPassTest(){ MockedPoint point = new MockedPoint(400, 300); assertEquals(PopUpPosition.TOP,mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.TOP, mCoachMarkPixelInfo)); }
@Test public void getDisplayPositionTopDefaultFailTest(){ MockedPoint point = new MockedPoint(760, 10); assertEquals(PopUpPosition.BOTTOM,mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.TOP, mCoachMarkPixelInfo)); }
@Test public void getDisplayPositionBottomDefaultPassTest(){ MockedPoint point = new MockedPoint(400, 300); assertEquals(PopUpPosition.BOTTOM,mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.BOTTOM, mCoachMarkPixelInfo)); }
@Test public void getDisplayPositionBottomDefaultFailTest(){ MockedPoint point = new MockedPoint(760, 1000); assertEquals(PopUpPosition.LEFT,mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.BOTTOM, mCoachMarkPixelInfo)); }
@Test public void getDisplayPositionNoneDefaultPositionTest(){ MockedPoint point = new MockedPoint(760, 1000); assertEquals(PopUpPosition.LEFT,mPopUpCoachMarkPresenter.getDisplayPosition(point, PopUpPosition.NONE, mCoachMarkPixelInfo)); }