Search in sources :

Example 1 with WebViewBase

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

the class InterstitialManagerTest method addOldViewToBackStackIntControllerNull_ZeroViewStackInteractions.

@Test
public void addOldViewToBackStackIntControllerNull_ZeroViewStackInteractions() throws IllegalAccessException {
    WebViewBase mockWebViewBase = mock(WebViewBase.class);
    Stack<View> mockViewStack = spy(new Stack<>());
    WhiteBox.field(InterstitialManager.class, "mViewStack").set(mSpyInterstitialManager, mockViewStack);
    mSpyInterstitialManager.addOldViewToBackStack(mockWebViewBase, null, null);
    verifyZeroInteractions(mockViewStack);
}
Also used : WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) InterstitialView(org.prebid.mobile.rendering.bidding.display.InterstitialView) View(android.view.View) VideoView(org.prebid.mobile.rendering.bidding.display.VideoView) Test(org.junit.Test)

Example 2 with WebViewBase

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

the class MraidControllerTest method delegateDisplayViewInInterstitialAndExpandNotNull_SetExpandDisplayViewAndInitMraidExpanded.

@Test
public void delegateDisplayViewInInterstitialAndExpandNotNull_SetExpandDisplayViewAndInitMraidExpanded() throws IllegalAccessException {
    mMraidController = new MraidController(mMockInterstitialManager);
    WebViewBase mockWebView = mock(WebViewBase.class);
    MraidEvent mockEvent = mock(MraidEvent.class);
    MraidExpand mockMraidExpand = mock(MraidExpand.class);
    PrebidWebViewBase mockWebViewBase = mock(PrebidWebViewBase.class);
    mockEvent.mraidAction = JSInterface.ACTION_EXPAND;
    mockEvent.mraidActionHelper = "test";
    when(mockMraidExpand.getInterstitialViewController()).thenReturn(mock(AdBaseDialog.class));
    when(mockWebView.getPreloadedListener()).thenReturn(mockWebViewBase);
    WhiteBox.field(MraidController.class, "mMraidExpand").set(mMraidController, mockMraidExpand);
    getMraidDelegate().displayPrebidWebViewForMraid(mockWebView, true, mockEvent);
    verify(mockMraidExpand, times(1)).setDisplayView(mockWebView);
    verify(mockWebViewBase).initMraidExpanded();
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) AdBaseDialog(org.prebid.mobile.rendering.interstitial.AdBaseDialog) MraidEvent(org.prebid.mobile.rendering.models.internal.MraidEvent) Test(org.junit.Test)

Example 3 with WebViewBase

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

the class MraidControllerTest method callControllerHandler.

private void callControllerHandler(MraidEvent event) {
    final HTMLCreative mockCreative = mock(HTMLCreative.class);
    final CreativeModel mockCreativeModel = mock(CreativeModel.class);
    final WebViewBase mockOldWebView = mock(WebViewBase.class);
    when(mockCreative.getCreativeModel()).thenReturn(mockCreativeModel);
    when(mockCreativeModel.getAdConfiguration()).thenReturn(mock(AdConfiguration.class));
    when(mockOldWebView.getContext()).thenReturn(mContext);
    mMraidController.handleMraidEvent(event, mockCreative, mockOldWebView, mock(PrebidWebViewBase.class));
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) CreativeModel(org.prebid.mobile.rendering.models.CreativeModel) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative)

Example 4 with WebViewBase

use of org.prebid.mobile.rendering.views.webview.WebViewBase 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 5 with WebViewBase

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

Aggregations

WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)16 Test (org.junit.Test)10 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)10 HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)5 MraidEvent (org.prebid.mobile.rendering.models.internal.MraidEvent)4 BaseJSInterface (org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface)4 View (android.view.View)3 InterstitialView (org.prebid.mobile.rendering.bidding.display.InterstitialView)3 Handler (android.os.Handler)2 VideoView (org.prebid.mobile.rendering.bidding.display.VideoView)2 AdBaseDialog (org.prebid.mobile.rendering.interstitial.AdBaseDialog)2 PrebidWebViewInterstitial (org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial)2 WebViewBanner (org.prebid.mobile.rendering.views.webview.WebViewBanner)2 JsExecutor (org.prebid.mobile.rendering.views.webview.mraid.JsExecutor)2 Context (android.content.Context)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 ContentObject (org.prebid.mobile.ContentObject)1 AdException (org.prebid.mobile.rendering.errors.AdException)1 AdInterstitialDialog (org.prebid.mobile.rendering.interstitial.AdInterstitialDialog)1 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)1