use of org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption in project prebid-mobile-android by prebid.
the class CreativeVisibilityTrackerTest method visibilityRunnable_runWithViewNotVisible_CallOnVisibilityChangedWithFalseValues_ImpTrackerFiredFalse_IsVisibilityScheduledTrue.
@Test
public void visibilityRunnable_runWithViewNotVisible_CallOnVisibilityChangedWithFalseValues_ImpTrackerFiredFalse_IsVisibilityScheduledTrue() throws Exception {
when(mMockView.getVisibility()).thenReturn(View.INVISIBLE);
VisibilityTrackerResult result = new VisibilityTrackerResult(NativeEventTracker.EventType.IMPRESSION, null, false, false);
when(mSpyVisibilityChecker.checkViewExposure(any(View.class))).thenReturn(null);
mCreativeVisibilityTracker.mVisibilityRunnable.run();
verify(mMockVisibilityTrackerListener).onVisibilityChanged(result);
final VisibilityTrackerOption visibilityTrackerOption = mSpyVisibilityChecker.getVisibilityTrackerOption();
assertFalse(visibilityTrackerOption.isImpressionTracked());
assertTrue((Boolean) getFieldValue("mIsVisibilityScheduled"));
}
use of org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption in project prebid-mobile-android by prebid.
the class CreativeVisibilityTrackerTest method visibilityRunnable_runWitViewVisibleForLessThanMinDuration_ShouldNotCallOnVisibilityChanged_ImpTrackerFiredFalse_IsVisibilityScheduledTrue.
@Test
public void visibilityRunnable_runWitViewVisibleForLessThanMinDuration_ShouldNotCallOnVisibilityChanged_ImpTrackerFiredFalse_IsVisibilityScheduledTrue() throws Exception {
ViewExposure viewExposure = new ViewExposure(5.0f, null, null);
when(mSpyVisibilityChecker.isVisible(any(View.class))).thenReturn(true);
when(mSpyVisibilityChecker.hasBeenVisible()).thenReturn(false);
when(mSpyVisibilityChecker.hasRequiredTimeElapsed()).thenReturn(false);
when(mSpyVisibilityChecker.checkViewExposure(any(View.class))).thenReturn(viewExposure);
VisibilityTrackerResult result = new VisibilityTrackerResult(NativeEventTracker.EventType.IMPRESSION, viewExposure, true, false);
mCreativeVisibilityTracker.mVisibilityRunnable.run();
verify(mMockVisibilityTrackerListener).onVisibilityChanged(result);
final VisibilityTrackerOption visibilityTrackerOption = mSpyVisibilityChecker.getVisibilityTrackerOption();
assertFalse(visibilityTrackerOption.isImpressionTracked());
assertTrue((Boolean) getFieldValue("mIsVisibilityScheduled"));
}
Aggregations