Search in sources :

Example 11 with HTMLCreative

use of org.prebid.mobile.rendering.models.HTMLCreative in project prebid-mobile-android by prebid.

the class MraidControllerTest method handleMraidEventWhenExpandEventAndHelperEmpty_InitExpand.

@Test
public void handleMraidEventWhenExpandEventAndHelperEmpty_InitExpand() {
    MraidEvent event = createMraidEvent(JSInterface.ACTION_EXPAND, null);
    HTMLCreative mockCreative = mock(HTMLCreative.class);
    WebViewBase mockOldWebView = mock(WebViewBase.class);
    when(mockOldWebView.getMraidListener()).thenReturn(mock(MraidEventsManager.MraidListener.class));
    when(mockOldWebView.getContext()).thenReturn(mContext);
    mMraidController.handleMraidEvent(event, mockCreative, mockOldWebView, mock(PrebidWebViewBase.class));
    verify(mMraidController).initMraidExpand(any(View.class), any(MraidController.DisplayCompletionListener.class), any(MraidEvent.class));
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) MraidEvent(org.prebid.mobile.rendering.models.internal.MraidEvent) View(android.view.View) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Example 12 with HTMLCreative

use of org.prebid.mobile.rendering.models.HTMLCreative in project prebid-mobile-android by prebid.

the class CreativeFactoryTest method testAttemptAuidCreative.

@Test
public void testAttemptAuidCreative() throws Exception {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    Handler mockHandler = mock(Handler.class);
    when(mMockModel.getAdConfiguration()).thenReturn(adConfiguration);
    when(mMockModel.getName()).thenReturn(HTML_CREATIVE_TAG);
    when(mMockModel.getImpressionUrl()).thenReturn("impressionUrl");
    when(mMockModel.getClickUrl()).thenReturn("clickUrl");
    // Run the creativeFactory
    CreativeFactory creativeFactory = new CreativeFactory(mMockContext, mMockModel, mMockListener, mMockOmAdSessionManager, mMockInterstitialManager);
    WhiteBox.field(CreativeFactory.class, "mTimeoutHandler").set(creativeFactory, mockHandler);
    creativeFactory.start();
    AbstractCreative creative = creativeFactory.getCreative();
    assertNotNull(creative);
    assertTrue(creative instanceof HTMLCreative);
    verify(mockHandler).postDelayed(any(Runnable.class), eq(6_000L));
}
Also used : AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Handler(android.os.Handler) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Example 13 with HTMLCreative

use of org.prebid.mobile.rendering.models.HTMLCreative in project prebid-mobile-android by prebid.

the class BaseJSInterface method notifyMraidEventHandler.

private void notifyMraidEventHandler() {
    mOrientationBroadcastReceiver.setMraidAction(mMraidEvent.mraidAction);
    HTMLCreative htmlCreative = ((PrebidWebViewBase) mAdBaseView.getPreloadedListener()).getCreative();
    mAdBaseView.post(new MraidEventHandlerNotifierRunnable(htmlCreative, mAdBaseView, mMraidEvent, mJsExecutor));
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) MraidEventHandlerNotifierRunnable(org.prebid.mobile.rendering.mraid.methods.MraidEventHandlerNotifierRunnable) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative)

Example 14 with HTMLCreative

use of org.prebid.mobile.rendering.models.HTMLCreative in project prebid-mobile-android by prebid.

the class MraidEventHandlerNotifierRunnable method run.

@Override
public void run() {
    HTMLCreative htmlCreative = mWeakHtmlCreative.get();
    WebViewBase webViewBase = mWeakWebViewBase.get();
    if (htmlCreative == null || webViewBase == null) {
        LogUtil.debug(TAG, "Unable to pass event to handler. HtmlCreative or webviewBase is null");
        return;
    }
    htmlCreative.handleMRAIDEventsInCreative(mMraidEvent, webViewBase);
    final JsExecutor jsExecutor = mWeakJsExecutor.get();
    if (jsExecutor == null) {
        LogUtil.debug(TAG, "Unable to executeNativeCallComplete(). JsExecutor is null.");
        return;
    }
    jsExecutor.executeNativeCallComplete();
}
Also used : WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) JsExecutor(org.prebid.mobile.rendering.views.webview.mraid.JsExecutor) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative)

Aggregations

HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)14 Test (org.junit.Test)8 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)7 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)5 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)3 View (android.view.View)2 CreativeModel (org.prebid.mobile.rendering.models.CreativeModel)2 MraidEvent (org.prebid.mobile.rendering.models.internal.MraidEvent)2 Handler (android.os.Handler)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 AdException (org.prebid.mobile.rendering.errors.AdException)1 AdInterstitialDialog (org.prebid.mobile.rendering.interstitial.AdInterstitialDialog)1 CreativeViewListener (org.prebid.mobile.rendering.listeners.CreativeViewListener)1 Transaction (org.prebid.mobile.rendering.loading.Transaction)1 AbstractCreative (org.prebid.mobile.rendering.models.AbstractCreative)1 MraidVariableContainer (org.prebid.mobile.rendering.models.internal.MraidVariableContainer)1 MraidEventHandlerNotifierRunnable (org.prebid.mobile.rendering.mraid.methods.MraidEventHandlerNotifierRunnable)1 RedirectUrlListener (org.prebid.mobile.rendering.mraid.methods.network.RedirectUrlListener)1 PrebidWebViewBanner (org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner)1