Search in sources :

Example 11 with MraidVariableContainer

use of org.prebid.mobile.rendering.models.internal.MraidVariableContainer 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 12 with MraidVariableContainer

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

the class PrebidWebViewBanner method handleExpandPropertiesResult.

private void handleExpandPropertiesResult(String expandProperties) {
    JSONObject jsonExpandProperties;
    WebViewBase currentWebView = (mWebView != null) ? mWebView : mMraidWebView;
    final MraidVariableContainer mraidVariableContainer = currentWebView.getMRAIDInterface().getMraidVariableContainer();
    mraidVariableContainer.setExpandProperties(expandProperties);
    try {
        jsonExpandProperties = new JSONObject(expandProperties);
        mDefinedWidthForExpand = jsonExpandProperties.optInt("width", 0);
        mDefinedHeightForExpand = jsonExpandProperties.optInt("height", 0);
        if (mInterstitialManager.getInterstitialDisplayProperties() != null) {
            mInterstitialManager.getInterstitialDisplayProperties().expandWidth = mDefinedWidthForExpand;
            mInterstitialManager.getInterstitialDisplayProperties().expandHeight = mDefinedHeightForExpand;
        }
    } catch (Exception e) {
        LogUtil.error(TAG, "handleExpandPropertiesResult: Failed. Reason: " + Log.getStackTraceString(e));
    }
}
Also used : JSONObject(org.json.JSONObject) MraidVariableContainer(org.prebid.mobile.rendering.models.internal.MraidVariableContainer) AdException(org.prebid.mobile.rendering.errors.AdException)

Aggregations

MraidVariableContainer (org.prebid.mobile.rendering.models.internal.MraidVariableContainer)12 Test (org.junit.Test)7 JSONObject (org.json.JSONObject)2 Matchers.anyString (org.mockito.Matchers.anyString)2 AdException (org.prebid.mobile.rendering.errors.AdException)2 HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)2 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)2 Context (android.content.Context)1 Handler (android.os.Handler)1 ViewGroup (android.view.ViewGroup)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 RedirectUrlListener (org.prebid.mobile.rendering.mraid.methods.network.RedirectUrlListener)1 AdBrowserActivity (org.prebid.mobile.rendering.views.browser.AdBrowserActivity)1 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)1 BaseJSInterface (org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface)1