Search in sources :

Example 6 with BaseJSInterface

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

the class InterstitialManagerTest method interstitialClosedWithView_NotifyInterstitialDelegate.

@Test
public void interstitialClosedWithView_NotifyInterstitialDelegate() {
    WebViewBase mockWebView = mock(WebViewBase.class);
    BaseJSInterface mockInterface = mock(BaseJSInterface.class);
    when(mockWebView.getMRAIDInterface()).thenReturn(mockInterface);
    mSpyInterstitialManager.interstitialClosed(mockWebView);
    verify(mMockInterstitialManagerDisplayDelegate, times(1)).interstitialAdClosed();
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) Test(org.junit.Test)

Example 7 with BaseJSInterface

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

the class InterstitialManagerTest method displayViewAsInterstitialSuccess_ShowInterstitialAdView.

@Test
@LooperMode(LooperMode.Mode.PAUSED)
public void displayViewAsInterstitialSuccess_ShowInterstitialAdView() {
    VideoCreative mockVideoCreative = mock(VideoCreative.class);
    when(mockVideoCreative.isResolved()).thenReturn(true);
    BaseJSInterface mockJsInterface = mock(BaseJSInterface.class);
    when(mockJsInterface.getJsExecutor()).thenReturn(mock(JsExecutor.class));
    WebViewBase mockWebViewBase = mock(WebViewBase.class);
    when(mockWebViewBase.getMRAIDInterface()).thenReturn(mockJsInterface);
    PrebidWebViewInterstitial mockPrebidWebViewInterstitial = mock(PrebidWebViewInterstitial.class);
    when(mockPrebidWebViewInterstitial.getWebView()).thenReturn(mockWebViewBase);
    InterstitialView mockInterstitialView = mock(InterstitialView.class);
    when(mockInterstitialView.getCreativeView()).thenReturn(mockPrebidWebViewInterstitial);
    mSpyInterstitialManager.displayAdViewInInterstitial(mContext, mockInterstitialView);
    verify(mMockAdViewDelegate).showInterstitial();
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) PrebidWebViewInterstitial(org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial) VideoCreative(org.prebid.mobile.rendering.video.VideoCreative) JsExecutor(org.prebid.mobile.rendering.views.webview.mraid.JsExecutor) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) InterstitialView(org.prebid.mobile.rendering.bidding.display.InterstitialView) Test(org.junit.Test) LooperMode(org.robolectric.annotation.LooperMode)

Example 8 with BaseJSInterface

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

the class WebViewBaseTest method startLoadingAssetsTest.

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

Example 9 with BaseJSInterface

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

the class WebViewBaseTest method adAssetsLoadedTest.

@Test
public void adAssetsLoadedTest() {
    BaseJSInterface mockBaseJsInterface = mock(BaseJSInterface.class);
    mWebViewBase.setBaseJSInterface(mockBaseJsInterface);
    mWebViewBase.mIsMRAID = false;
    mWebViewBase.adAssetsLoaded();
    verify(mockBaseJsInterface, times(0)).prepareAndSendReady();
    verify(mMockPreloadListener, times(1)).preloaded(eq(mWebViewBase));
    mWebViewBase.mIsMRAID = true;
    mWebViewBase.adAssetsLoaded();
    verify(mockBaseJsInterface, times(1)).prepareAndSendReady();
    verify(mMockPreloadListener, times(2)).preloaded(eq(mWebViewBase));
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) Test(org.junit.Test)

Example 10 with BaseJSInterface

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

the class HTMLCreativeTest method adSessionSuccessInitializationTest.

@Test
public void adSessionSuccessInitializationTest() throws Exception {
    PrebidWebViewBase prebidWebView = new PrebidWebViewBase(mContext, mMockInterstitialManager);
    WebViewBase mockWebViewBase = mock(WebViewBase.class);
    BaseJSInterface baseJSInterface = mock(BaseJSInterface.class);
    when(mockWebViewBase.getMRAIDInterface()).thenReturn(baseJSInterface);
    WhiteBox.setInternalState(prebidWebView, "mWebView", mockWebViewBase);
    mHtmlCreative.setCreativeView(prebidWebView);
    mHtmlCreative.setCreativeView(prebidWebView);
    HTMLCreative spyHtmlCreative = spy(mHtmlCreative);
    spyHtmlCreative.display();
}
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) 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