Search in sources :

Example 6 with VisibilityTrackerResult

use of org.prebid.mobile.rendering.models.internal.VisibilityTrackerResult 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"));
}
Also used : VisibilityTrackerResult(org.prebid.mobile.rendering.models.internal.VisibilityTrackerResult) View(android.view.View) VisibilityTrackerOption(org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption) Test(org.junit.Test)

Example 7 with VisibilityTrackerResult

use of org.prebid.mobile.rendering.models.internal.VisibilityTrackerResult 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"));
}
Also used : VisibilityTrackerResult(org.prebid.mobile.rendering.models.internal.VisibilityTrackerResult) ViewExposure(org.prebid.mobile.rendering.utils.exposure.ViewExposure) View(android.view.View) VisibilityTrackerOption(org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 VisibilityTrackerResult (org.prebid.mobile.rendering.models.internal.VisibilityTrackerResult)7 ViewExposure (org.prebid.mobile.rendering.utils.exposure.ViewExposure)5 VisibilityTrackerOption (org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption)4 View (android.view.View)3 Rect (android.graphics.Rect)2 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)2 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)2 HashSet (java.util.HashSet)1