Search in sources :

Example 11 with BaseJSInterface

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

the class WebViewBanner method setMRAIDInterface.

public void setMRAIDInterface() {
    BaseJSInterface mraid = new BannerJSInterface(getContext(), this, new JsExecutor(this, new Handler(Looper.getMainLooper()), new HandlerQueueManager()));
    addJavascriptInterface(mraid, "jsBridge");
    LogUtil.debug(TAG, "JS bridge initialized");
    setBaseJSInterface(mraid);
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) BannerJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BannerJSInterface) JsExecutor(org.prebid.mobile.rendering.views.webview.mraid.JsExecutor) Handler(android.os.Handler) HandlerQueueManager(org.prebid.mobile.rendering.utils.helpers.HandlerQueueManager)

Example 12 with BaseJSInterface

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

the class MraidResizeTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    PrebidWebViewBase prebidWebViewBase = mock(PrebidWebViewBase.class);
    mMockContext = Robolectric.buildActivity(Activity.class).create().get().getApplicationContext();
    mSpyBaseJsInterface = spy(new BaseJSInterface(mMockContext, mMockWebViewBase, mMockJsExecutor));
    when(mSpyBaseJsInterface.getMraidVariableContainer()).thenReturn(mMockMraidVariableContainer);
    when(mMockWebViewBase.post(any(Runnable.class))).thenAnswer(invocation -> {
        Runnable runnable = invocation.getArgument(0);
        runnable.run();
        return null;
    });
    doAnswer(invocation -> {
        Handler handler = invocation.getArgument(0);
        Message message = new Message();
        Bundle data = new Bundle();
        data.putString(JSInterface.JSON_VALUE, "{\"width\":320,\"height\":250,\"customClosePosition\":\"top-right\",\"offsetX\":0,\"offsetY\":0,\"allowOffscreen\":true}");
        message.setData(data);
        handler.handleMessage(message);
        return null;
    }).when(mMockJsExecutor).executeGetResizeProperties(any(Handler.class));
    when(mMockWebViewBase.getParent()).thenReturn(prebidWebViewBase);
    when(mSpyBaseJsInterface.getDefaultAdContainer()).thenReturn(prebidWebViewBase);
    mMraidResize = new MraidResize(mMockContext, mSpyBaseJsInterface, mMockWebViewBase, mMockManager);
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) Message(android.os.Message) Bundle(android.os.Bundle) Handler(android.os.Handler) Before(org.junit.Before)

Example 13 with BaseJSInterface

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

Aggregations

BaseJSInterface (org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface)13 Test (org.junit.Test)8 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)4 Handler (android.os.Handler)3 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)3 JsExecutor (org.prebid.mobile.rendering.views.webview.mraid.JsExecutor)3 HandlerQueueManager (org.prebid.mobile.rendering.utils.helpers.HandlerQueueManager)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Message (android.os.Message)1 Before (org.junit.Before)1 InterstitialView (org.prebid.mobile.rendering.bidding.display.InterstitialView)1 HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)1 MraidVariableContainer (org.prebid.mobile.rendering.models.internal.MraidVariableContainer)1 ActionNotResolvedException (org.prebid.mobile.rendering.utils.url.ActionNotResolvedException)1 VideoCreative (org.prebid.mobile.rendering.video.VideoCreative)1 PrebidWebViewInterstitial (org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial)1 BannerJSInterface (org.prebid.mobile.rendering.views.webview.mraid.BannerJSInterface)1 InterstitialJSInterface (org.prebid.mobile.rendering.views.webview.mraid.InterstitialJSInterface)1 LooperMode (org.robolectric.annotation.LooperMode)1