@Test
  public void isMostlyVisible_whenViewIsInvisibleOrGone_shouldReturnFalse() throws Exception {
    View view = createViewMock(View.INVISIBLE, 100, 100, 100, 100, true, true);
    assertThat(visibilityChecker.isVisible(view, MIN_PERCENTAGE_VIEWED)).isFalse();

    reset(view);
    view = createViewMock(View.GONE, 100, 100, 100, 100, true, true);
    assertThat(visibilityChecker.isVisible(view, MIN_PERCENTAGE_VIEWED)).isFalse();
  }
 @Test
 public void isMostlyVisible_whenViewIsNull_shouldReturnFalse() throws Exception {
   assertThat(visibilityChecker.isVisible(null, MIN_PERCENTAGE_VIEWED)).isFalse();
 }
  @Test
  public void isMostlyVisible_whenViewHasZeroWidthAndHeight_shouldReturnFalse() throws Exception {
    view = createViewMock(View.VISIBLE, 100, 100, 0, 0, true, true);

    assertThat(visibilityChecker.isVisible(view, MIN_PERCENTAGE_VIEWED)).isFalse();
  }
  @Test
  public void isMostlyVisible_whenViewIs49PercentVisible_shouldReturnFalse() throws Exception {
    view = createViewMock(View.VISIBLE, 49, 100, 100, 100, true, true);

    assertThat(visibilityChecker.isVisible(view, MIN_PERCENTAGE_VIEWED)).isFalse();
  }
  @Test
  public void isMostlyVisible_whenViewIsEntirelyOnScreen_shouldReturnTrue() throws Exception {
    view = createViewMock(View.VISIBLE, 100, 100, 100, 100, true, true);

    assertThat(visibilityChecker.isVisible(view, MIN_PERCENTAGE_VIEWED)).isTrue();
  }
 @Test
 public void hasRequiredTimeElapsed_withElapsedTimeLessThanMinTimeViewed_shouldReturnFalse()
     throws Exception {
   assertThat(visibilityChecker.hasRequiredTimeElapsed(SystemClock.uptimeMillis() - 499, 500))
       .isFalse();
 }
 @Test
 public void hasRequiredTimeElapsed_withElapsedTimeGreaterThanMinTimeViewed_shouldReturnTrue()
     throws Exception {
   assertThat(visibilityChecker.hasRequiredTimeElapsed(SystemClock.uptimeMillis() - 501, 500))
       .isTrue();
 }
 @Override
 public VisibilityChecker<?> findAutoDetectVisibility(
     AnnotatedClass ac, VisibilityChecker<?> checker) {
   JsonAutoDetect ann = _findAnnotation(ac, JsonAutoDetect.class);
   return (ann == null) ? checker : checker.with(ann);
 }