Search in sources :

Example 11 with WebViewBase

use of org.prebid.mobile.rendering.views.webview.WebViewBase 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 WebViewBase

use of org.prebid.mobile.rendering.views.webview.WebViewBase in project prebid-mobile-android by prebid.

the class MraidControllerTest method handleMraidEventWhenResizeEvent_CallResize.

@Test
public void handleMraidEventWhenResizeEvent_CallResize() throws Exception {
    BaseJSInterface mockJsInterface = mock(BaseJSInterface.class);
    MraidVariableContainer container = new MraidVariableContainer();
    container.setCurrentState(JSInterface.STATE_LOADING);
    when(mockJsInterface.getMraidVariableContainer()).thenReturn(container);
    WebViewBase mockOldWebView = mock(WebViewBase.class);
    when(mockOldWebView.getContext()).thenReturn(mContext);
    when(mockOldWebView.getMRAIDInterface()).thenReturn(mockJsInterface);
    mMraidController.handleMraidEvent(createMraidEvent(JSInterface.ACTION_RESIZE, null), mock(HTMLCreative.class), mockOldWebView, mock(PrebidWebViewBase.class));
    assertNotNull(WhiteBox.getInternalState(mMraidController, "mMraidResize"));
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) MraidVariableContainer(org.prebid.mobile.rendering.models.internal.MraidVariableContainer) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Example 13 with WebViewBase

use of org.prebid.mobile.rendering.views.webview.WebViewBase in project prebid-mobile-android by prebid.

the class MraidController method initMraidExpand.

@VisibleForTesting
protected void initMraidExpand(final View adBaseView, final DisplayCompletionListener displayCompletionListener, final MraidEvent mraidEvent) {
    mMraidExpand = new MraidExpand(adBaseView.getContext(), ((WebViewBase) adBaseView), mInterstitialManager);
    if (mraidEvent.mraidAction.equals(JSInterface.ACTION_EXPAND)) {
        mMraidExpand.setMraidExpanded(true);
    }
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(() -> {
        try {
            LogUtil.debug(TAG, "mraidExpand");
            // send click event on expand
            ((WebViewBase) adBaseView).sendClickCallBack(mraidEvent.mraidActionHelper);
            mMraidExpand.expand(mraidEvent.mraidActionHelper, () -> {
                if (displayCompletionListener != null) {
                    displayCompletionListener.onDisplayCompleted();
                    // send expandedCallback to pubs
                    mInterstitialManager.getHtmlCreative().mraidAdExpanded();
                }
            });
        } catch (Exception e) {
            LogUtil.error(TAG, "mraidExpand failed at displayViewInInterstitial: " + Log.getStackTraceString(e));
        }
    });
}
Also used : WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) Handler(android.os.Handler) AdException(org.prebid.mobile.rendering.errors.AdException) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 14 with WebViewBase

use of org.prebid.mobile.rendering.views.webview.WebViewBase in project prebid-mobile-android by prebid.

the class HTMLCreative method createOmAdSession.

@Override
public void createOmAdSession() {
    if (getCreativeView() == null || getCreativeView().getWebView() == null) {
        LogUtil.error(TAG, "initOmAdSession error. Opex webView is null");
        return;
    }
    OmAdSessionManager omAdSessionManager = mWeakOmAdSessionManager.get();
    if (omAdSessionManager == null) {
        LogUtil.error(TAG, "Error creating adSession. OmAdSessionManager is null");
        return;
    }
    WebViewBase webView = getCreativeView().getWebView();
    AdConfiguration adConfiguration = getCreativeModel().getAdConfiguration();
    ContentObject contentObject = adConfiguration.getAppContent();
    String contentUrl = null;
    if (contentObject != null)
        contentUrl = contentObject.getUrl();
    omAdSessionManager.initWebAdSessionManager(webView, contentUrl);
    startOmSession(omAdSessionManager, webView);
}
Also used : OmAdSessionManager(org.prebid.mobile.rendering.session.manager.OmAdSessionManager) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) ContentObject(org.prebid.mobile.ContentObject)

Example 15 with WebViewBase

use of org.prebid.mobile.rendering.views.webview.WebViewBase in project prebid-mobile-android by prebid.

the class MraidClose method closeThroughJS.

public void closeThroughJS() {
    final Context context = mContext;
    if (context == null) {
        LogUtil.error(TAG, "Context is null");
        return;
    }
    Handler uiHandler = new Handler(Looper.getMainLooper());
    uiHandler.post(() -> {
        try {
            String state = mJsi.getMraidVariableContainer().getCurrentState();
            WebViewBase webViewBase = mWebViewBase;
            if (isContainerStateInvalid(state)) {
                LogUtil.debug(TAG, "closeThroughJS: Skipping. Wrong container state: " + state);
                return;
            }
            changeState(state);
            if (webViewBase instanceof WebViewBanner && webViewBase.getMRAIDInterface().getDefaultLayoutParams() != null) {
                webViewBase.setLayoutParams(webViewBase.getMRAIDInterface().getDefaultLayoutParams());
            }
        } catch (Exception e) {
            LogUtil.error(TAG, "closeThroughJS failed: " + Log.getStackTraceString(e));
        }
    });
}
Also used : Context(android.content.Context) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) Handler(android.os.Handler) WebViewBanner(org.prebid.mobile.rendering.views.webview.WebViewBanner)

Aggregations

WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)16 Test (org.junit.Test)10 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)10 HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)5 MraidEvent (org.prebid.mobile.rendering.models.internal.MraidEvent)4 BaseJSInterface (org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface)4 View (android.view.View)3 InterstitialView (org.prebid.mobile.rendering.bidding.display.InterstitialView)3 Handler (android.os.Handler)2 VideoView (org.prebid.mobile.rendering.bidding.display.VideoView)2 AdBaseDialog (org.prebid.mobile.rendering.interstitial.AdBaseDialog)2 PrebidWebViewInterstitial (org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial)2 WebViewBanner (org.prebid.mobile.rendering.views.webview.WebViewBanner)2 JsExecutor (org.prebid.mobile.rendering.views.webview.mraid.JsExecutor)2 Context (android.content.Context)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 ContentObject (org.prebid.mobile.ContentObject)1 AdException (org.prebid.mobile.rendering.errors.AdException)1 AdInterstitialDialog (org.prebid.mobile.rendering.interstitial.AdInterstitialDialog)1 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)1