@Test public void renderTestTopLayout(){ View descriptionViewMock = Mockito.mock(View.class); Context mContextMock = Mockito.mock(Context.class); when(descriptionViewMock.getContext()).thenReturn(mContextMock); Resources resMock = Mockito.mock(Resources.class); when(mContextMock.getResources()).thenReturn(resMock); when(resMock.getDimension(R.dimen.description_padding)).thenReturn(10f); CoachmarkViewLayout layout = Mockito.mock(CoachmarkViewLayout.class); RectF mCircleRectFMock = Mockito.mock(RectF.class); RectF mScreenRectFMock = Mockito.mock(RectF.class); when(layout.calcCircleRectF()).thenReturn(mCircleRectFMock); when(layout.calcScreenRectF()).thenReturn(mScreenRectFMock); when(mScreenRectFMock.height()).thenReturn(100f); when(mCircleRectFMock.centerY()).thenReturn(51f); new TopOrBottomDescriptionRenderer().render(layout, descriptionViewMock); verify(descriptionViewMock).setY(10f); }
@Override public void render(CoachmarkViewLayout layout, View description) { RectF circle = layout.calcCircleRectF(); RectF screenRectangle = layout.calcScreenRectF(); if (circle.centerY() > screenRectangle.height() / 2) { description.setY(description.getContext().getResources().getDimension(R.dimen.description_padding)); } else { description.setY(screenRectangle.height() - description.getContext().getResources().getDimension(R.dimen.description_padding) - description.getHeight()); } }
TopOrBottomDescriptionRenderer implements DescriptionRenderer { @Override public void render(CoachmarkViewLayout layout, View description) { RectF circle = layout.calcCircleRectF(); RectF screenRectangle = layout.calcScreenRectF(); if (circle.centerY() > screenRectangle.height() / 2) { description.setY(description.getContext().getResources().getDimension(R.dimen.description_padding)); } else { description.setY(screenRectangle.height() - description.getContext().getResources().getDimension(R.dimen.description_padding) - description.getHeight()); } } }
TopOrBottomDescriptionRenderer implements DescriptionRenderer { @Override public void render(CoachmarkViewLayout layout, View description) { RectF circle = layout.calcCircleRectF(); RectF screenRectangle = layout.calcScreenRectF(); if (circle.centerY() > screenRectangle.height() / 2) { description.setY(description.getContext().getResources().getDimension(R.dimen.description_padding)); } else { description.setY(screenRectangle.height() - description.getContext().getResources().getDimension(R.dimen.description_padding) - description.getHeight()); } }  }
TopOrBottomDescriptionRenderer implements DescriptionRenderer { @Override public void render(CoachmarkViewLayout layout, View description) { RectF circle = layout.calcCircleRectF(); RectF screenRectangle = layout.calcScreenRectF(); if (circle.centerY() > screenRectangle.height() / 2) { description.setY(description.getContext().getResources().getDimension(R.dimen.description_padding)); } else { description.setY(screenRectangle.height() - description.getContext().getResources().getDimension(R.dimen.description_padding) - description.getHeight()); } }  @Override void render(CoachmarkViewLayout layout, View description); }
TopOrBottomDescriptionRenderer implements DescriptionRenderer { @Override public void render(CoachmarkViewLayout layout, View description) { RectF circle = layout.calcCircleRectF(); RectF screenRectangle = layout.calcScreenRectF(); if (circle.centerY() > screenRectangle.height() / 2) { description.setY(description.getContext().getResources().getDimension(R.dimen.description_padding)); } else { description.setY(screenRectangle.height() - description.getContext().getResources().getDimension(R.dimen.description_padding) - description.getHeight()); } }  @Override void render(CoachmarkViewLayout layout, View description);  }