Search in sources :

Example 11 with VisibilityTrackerOption

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"));
}
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 12 with VisibilityTrackerOption

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"));
}
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

VisibilityTrackerOption (org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption)12 Test (org.junit.Test)5 VisibilityChecker (org.prebid.mobile.rendering.utils.helpers.VisibilityChecker)5 View (android.view.View)4 VisibilityTrackerResult (org.prebid.mobile.rendering.models.internal.VisibilityTrackerResult)4 ViewExposure (org.prebid.mobile.rendering.utils.exposure.ViewExposure)3 Rect (android.graphics.Rect)2 CreativeVisibilityTracker (org.prebid.mobile.rendering.models.CreativeVisibilityTracker)2 AdView (com.google.android.gms.ads.AdView)1 MoPubView (com.mopub.mobileads.MoPubView)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 BidLoader (org.prebid.mobile.rendering.bidding.loader.BidLoader)1