Search in sources :

Example 1 with BaseJSInterface

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

the class WebViewBaseTest method destroyTest.

@Test
public void destroyTest() throws IllegalAccessException {
    BaseJSInterface mockInterface = mock(BaseJSInterface.class);
    WhiteBox.field(WebViewBase.class, "mMraidInterface").set(mWebViewBase, mockInterface);
    mWebViewBase.destroy();
    verify(mockInterface).destroy();
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) Test(org.junit.Test)

Example 2 with BaseJSInterface

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

the class MraidCalendarEventTest method testCreateCalendarEvent.

@Test
public void testCreateCalendarEvent() {
    BaseJSInterface mockJs = mock(BaseJSInterface.class);
    MraidCalendarEvent event = new MraidCalendarEvent(mockJs);
    event.createCalendarEvent(mCalendarParameters);
    ShadowActivity shadowActivity = shadowOf(mTestActivity);
    Intent startedIntent = shadowActivity.getNextStartedActivity();
    assertFalse("somecrap.calendar/event".equals(startedIntent.getType()));
    assertEquals("vnd.android.cursor.item/event", startedIntent.getType());
    assertFalse("fail.event.type".equals(startedIntent.getType()));
    assertEquals("", startedIntent.getExtras().get(CalendarContract.Events.TITLE));
    assertTrue(startedIntent.getExtras().get(CalendarContract.Events.DESCRIPTION).equals("mayanApocalypse/End of world"));
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) Test(org.junit.Test)

Example 3 with BaseJSInterface

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

the class MraidOrientationBroadcastReceiver method handleOrientationChange.

@Override
public void handleOrientationChange(int currentRotation) {
    super.handleOrientationChange(currentRotation);
    BaseJSInterface baseJSInterface = mBaseJSInterfaceWeakReference.get();
    if (baseJSInterface == null) {
        LogUtil.debug(TAG, "handleOrientationChange failure. BaseJsInterface is null");
        return;
    }
    if (shouldHandleClose()) {
        LogUtil.debug(TAG, "Call 'close' action for MRAID Resize after changing rotation for API 19.");
        baseJSInterface.close();
    }
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface)

Example 4 with BaseJSInterface

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

the class MraidInternalBrowserAction method performAction.

@Override
public void performAction(Context context, UrlHandler urlHandler, Uri uri) throws ActionNotResolvedException {
    BaseJSInterface baseJSInterface = mJSInterfaceWeakReference.get();
    if (baseJSInterface == null) {
        throw new ActionNotResolvedException("Action can't be handled. BaseJSInterface is null");
    }
    handleInternalBrowserAction(context, baseJSInterface, uri.toString());
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) ActionNotResolvedException(org.prebid.mobile.rendering.utils.url.ActionNotResolvedException)

Example 5 with BaseJSInterface

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

the class WebViewInterstitial method setMRAIDInterface.

public void setMRAIDInterface() {
    BaseJSInterface mraid = new InterstitialJSInterface(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) InterstitialJSInterface(org.prebid.mobile.rendering.views.webview.mraid.InterstitialJSInterface) JsExecutor(org.prebid.mobile.rendering.views.webview.mraid.JsExecutor) Handler(android.os.Handler) HandlerQueueManager(org.prebid.mobile.rendering.utils.helpers.HandlerQueueManager)

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