Search in sources :

Example 11 with MraidEvent

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

the class BaseJSInterfaceTest method onOrientationPropertiesChangedTest.

@Test
public void onOrientationPropertiesChangedTest() throws Exception {
    Field field = WhiteBox.field(BaseJSInterface.class, "mMraidEvent");
    mSpyBaseJSInterface.onOrientationPropertiesChanged("test");
    MraidEvent event = (MraidEvent) field.get(mSpyBaseJSInterface);
    assertEquals(JSInterface.ACTION_ORIENTATION_CHANGE, event.mraidAction);
    assertEquals("test", event.mraidActionHelper);
    verify(mMockMraidController).handleMraidEvent(eq(event), eq(mMockCreative), any(WebViewBase.class), any());
}
Also used : Field(java.lang.reflect.Field) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) MraidEvent(org.prebid.mobile.rendering.models.internal.MraidEvent) Test(org.junit.Test)

Example 12 with MraidEvent

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

the class BaseJSInterfaceTest method expandWithUrlTest.

@Test
public void expandWithUrlTest() throws Exception {
    Field field = WhiteBox.field(BaseJSInterface.class, "mMraidEvent");
    mSpyBaseJSInterface.expand(null);
    MraidEvent event = (MraidEvent) field.get(mSpyBaseJSInterface);
    assertEquals(JSInterface.ACTION_EXPAND, event.mraidAction);
    verify(mMockMraidController).handleMraidEvent(eq(event), eq(mMockCreative), any(WebViewBase.class), any());
}
Also used : Field(java.lang.reflect.Field) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) MraidEvent(org.prebid.mobile.rendering.models.internal.MraidEvent) Test(org.junit.Test)

Example 13 with MraidEvent

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

the class PrebidWebViewBannerTest method preloadedTest.

@Test
public void preloadedTest() {
    WebViewDelegate mockDelegate = mock(WebViewDelegate.class);
    InterstitialManager mockManager = mock(InterstitialManager.class);
    mBanner.mWebViewDelegate = mockDelegate;
    mBanner.mInterstitialManager = mockManager;
    MraidEvent mockEvent = mock(MraidEvent.class);
    when(mMockWebViewBanner.getMraidEvent()).thenReturn(mockEvent);
    mBanner.preloaded(null);
    verify(mockDelegate).webViewFailedToLoad(any(AdException.class));
    mMockWebViewBanner.mMRAIDBridgeName = "twopart";
    mBanner.preloaded(mMockWebViewBanner);
    verify(mockManager).displayPrebidWebViewForMraid(eq(mMockWebViewBanner), eq(true));
    mMockWebViewBanner.mMRAIDBridgeName = "else";
    mBanner.preloaded(mMockWebViewBanner);
    // verify render
    verify(mMockWebViewBanner).setAdWidth(anyInt());
    when(mMockWebViewBanner.getParent()).thenReturn(mock(ViewGroup.class));
    mBanner.preloaded(mMockWebViewBanner);
    verify(mMockWebViewBanner).bringToFront();
    verify(mockDelegate, times(3)).webViewReadyToDisplay();
}
Also used : WebViewDelegate(org.prebid.mobile.rendering.listeners.WebViewDelegate) ViewGroup(android.view.ViewGroup) InterstitialManager(org.prebid.mobile.rendering.views.interstitial.InterstitialManager) MraidEvent(org.prebid.mobile.rendering.models.internal.MraidEvent) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 14 with MraidEvent

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

the class BaseJSInterfaceTest method expandNoUrlTest.

@Test
public void expandNoUrlTest() throws Exception {
    Field field = WhiteBox.field(BaseJSInterface.class, "mMraidEvent");
    mSpyBaseJSInterface.expand();
    MraidEvent event = (MraidEvent) field.get(mSpyBaseJSInterface);
    assertEquals(JSInterface.ACTION_EXPAND, event.mraidAction);
    assertNull(event.mraidActionHelper);
    verify(mMockMraidController).handleMraidEvent(eq(event), eq(mMockCreative), any(WebViewBase.class), any());
}
Also used : Field(java.lang.reflect.Field) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) MraidEvent(org.prebid.mobile.rendering.models.internal.MraidEvent) Test(org.junit.Test)

Example 15 with MraidEvent

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

the class MraidControllerTest method handleMraidEventWhenExpandEventAndHelperEmpty_RunTwoPartRunnable.

@Test
public void handleMraidEventWhenExpandEventAndHelperEmpty_RunTwoPartRunnable() {
    HTMLCreative mockCreative = mock(HTMLCreative.class);
    MraidEvent event = createMraidEvent(JSInterface.ACTION_EXPAND, "twoPart");
    WebViewBase mockOldWebView = mock(WebViewBase.class);
    when(mockOldWebView.getMraidListener()).thenReturn(mock(MraidEventsManager.MraidListener.class));
    when(mockOldWebView.getContext()).thenReturn(mContext);
    mMraidController.handleMraidEvent(event, mockCreative, mockOldWebView, mock(PrebidWebViewBase.class));
    ShadowLooper.runUiThreadTasks();
    verify(mMraidController, times(1)).expand(any(WebViewBase.class), any(PrebidWebViewBase.class), eq(event));
}
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) MraidEvent(org.prebid.mobile.rendering.models.internal.MraidEvent) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Aggregations

MraidEvent (org.prebid.mobile.rendering.models.internal.MraidEvent)18 Test (org.junit.Test)17 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)14 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)14 Field (java.lang.reflect.Field)9 View (android.view.View)2 HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)2 WebViewBanner (org.prebid.mobile.rendering.views.webview.WebViewBanner)2 ViewGroup (android.view.ViewGroup)1 AdException (org.prebid.mobile.rendering.errors.AdException)1 AdBaseDialog (org.prebid.mobile.rendering.interstitial.AdBaseDialog)1 WebViewDelegate (org.prebid.mobile.rendering.listeners.WebViewDelegate)1 InterstitialManager (org.prebid.mobile.rendering.views.interstitial.InterstitialManager)1