Search in sources :

Example 6 with ViewExposure

use of org.prebid.mobile.rendering.utils.exposure.ViewExposure in project prebid-mobile-android by prebid.

the class JsExecutorTest method whenExecuteExposureChange_EvaluateMraidScript.

@Test
public void whenExecuteExposureChange_EvaluateMraidScript() {
    ViewExposure viewExposure = new ViewExposure();
    String expectedString = String.format("mraid.onExposureChange('%1$s');", viewExposure.toString());
    mSpyJsExecutor.executeExposureChange(viewExposure);
    assertEquals(viewExposure.toString(), mMraidVariableContainer.getCurrentExposure());
    verify(mSpyJsExecutor).evaluateMraidScript(expectedString);
}
Also used : ViewExposure(org.prebid.mobile.rendering.utils.exposure.ViewExposure) Test(org.junit.Test)

Example 7 with ViewExposure

use of org.prebid.mobile.rendering.utils.exposure.ViewExposure 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)

Example 8 with ViewExposure

use of org.prebid.mobile.rendering.utils.exposure.ViewExposure in project prebid-mobile-android by prebid.

the class VisibilityChecker method checkViewExposure.

public ViewExposure checkViewExposure(@Nullable final View view) {
    if (view == null) {
        return null;
    }
    ViewExposure exposure = mViewExposureChecker.exposure(view);
    LogUtil.debug(TAG, exposure != null ? exposure.toString() : "null exposure");
    return exposure;
}
Also used : ViewExposure(org.prebid.mobile.rendering.utils.exposure.ViewExposure)

Aggregations

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