Search in sources :

Example 1 with MraidVariableContainer

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

the class AdBaseDialog method handleExpandPropertiesResult.

private void handleExpandPropertiesResult(String expandProperties) {
    if (mWebViewBase == null || mWebViewBase.getMRAIDInterface() == null) {
        LogUtil.debug(TAG, "handleExpandPropertiesResult: WebViewBase or MraidInterface is null. Skipping.");
        return;
    }
    final MraidVariableContainer mraidVariableContainer = mWebViewBase.getMRAIDInterface().getMraidVariableContainer();
    mraidVariableContainer.setExpandProperties(expandProperties);
    // Fill interstitial manager with expand properties.
    mDisplayView = mWebViewBase;
    mHasExpandProperties = true;
    MraidContinue();
}
Also used : MraidVariableContainer(org.prebid.mobile.rendering.models.internal.MraidVariableContainer)

Example 2 with MraidVariableContainer

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

the class BaseJSInterfaceTest method setOrientationPropertiesTest.

@Test
public void setOrientationPropertiesTest() throws IllegalAccessException {
    final MraidVariableContainer mraidVariableContainer = mSpyBaseJSInterface.getMraidVariableContainer();
    assertNull(mraidVariableContainer.getOrientationProperties());
    String properties = "test";
    mraidVariableContainer.setOrientationProperties(properties);
    assertEquals(properties, mraidVariableContainer.getOrientationProperties());
}
Also used : MraidVariableContainer(org.prebid.mobile.rendering.models.internal.MraidVariableContainer) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 3 with MraidVariableContainer

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

the class BaseJSInterfaceTest method setExpandPropertiesTest.

@Test
public void setExpandPropertiesTest() {
    final MraidVariableContainer mraidVariableContainer = mSpyBaseJSInterface.getMraidVariableContainer();
    String expandProperties = mraidVariableContainer.getExpandProperties();
    assertNull(expandProperties);
    mraidVariableContainer.setExpandProperties("test");
    assertEquals("test", mraidVariableContainer.getExpandProperties());
}
Also used : MraidVariableContainer(org.prebid.mobile.rendering.models.internal.MraidVariableContainer) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 4 with MraidVariableContainer

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

the class MraidExpandTest method expandTest.

@Test
public void expandTest() {
    doAnswer(invocation -> {
        RedirectUrlListener listener = invocation.getArgument(1);
        listener.onSuccess("test", "html");
        return null;
    }).when(mSpyBaseJsInterface).followToOriginalUrl(anyString(), any(RedirectUrlListener.class));
    PrebidWebViewBase mockPreloadedListener = mock(PrebidWebViewBase.class);
    HTMLCreative mockCreative = mock(HTMLCreative.class);
    when(mockPreloadedListener.getCreative()).thenReturn(mockCreative);
    when(mMockWebViewBase.getPreloadedListener()).thenReturn(mockPreloadedListener);
    CompletedCallBack callBack = mock(CompletedCallBack.class);
    final MraidVariableContainer mraidVariableContainer = mSpyBaseJsInterface.getMraidVariableContainer();
    mraidVariableContainer.setCurrentState(JSInterface.STATE_DEFAULT);
    MraidExpand spyExpand = spy(mMraidExpand);
    doAnswer(invocation -> {
        CompletedCallBack completedCallBack = invocation.getArgument(1);
        completedCallBack.expandDialogShown();
        return null;
    }).when(spyExpand).showExpandDialog(any(), any());
    spyExpand.expand("test", callBack);
    verify(mSpyBaseJsInterface).followToOriginalUrl(anyString(), any(RedirectUrlListener.class));
    assertEquals(mraidVariableContainer.getUrlForLaunching(), "test");
    verify(callBack).expandDialogShown();
    verify(spyExpand).showExpandDialog(any(), any());
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) MraidVariableContainer(org.prebid.mobile.rendering.models.internal.MraidVariableContainer) RedirectUrlListener(org.prebid.mobile.rendering.mraid.methods.network.RedirectUrlListener) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Example 5 with MraidVariableContainer

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

the class MraidInternalBrowserAction method launchBrowserActivity.

@VisibleForTesting
void launchBrowserActivity(final Context context, BaseJSInterface jsInterface, String url) {
    final MraidVariableContainer mraidVariableContainer = jsInterface.getMraidVariableContainer();
    if (url != null) {
        mraidVariableContainer.setUrlForLaunching(url);
    }
    ExternalViewerUtils.startBrowser(context, mraidVariableContainer.getUrlForLaunching(), mBroadcastId, true, null);
}
Also used : MraidVariableContainer(org.prebid.mobile.rendering.models.internal.MraidVariableContainer) VisibleForTesting(androidx.annotation.VisibleForTesting)

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