Search in sources :

Example 1 with MraidEvent

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

the class BaseJSInterfaceTest method storePictureTest.

@Test
public void storePictureTest() throws Exception {
    Field field = WhiteBox.field(BaseJSInterface.class, "mMraidEvent");
    mSpyBaseJSInterface.storePicture("test");
    MraidEvent event = (MraidEvent) field.get(mSpyBaseJSInterface);
    assertEquals(JSInterface.ACTION_STORE_PICTURE, 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 2 with MraidEvent

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

the class BaseJSInterfaceTest method openTest.

@Test
public void openTest() throws Exception {
    Field field = WhiteBox.field(BaseJSInterface.class, "mMraidEvent");
    mSpyBaseJSInterface.open("test");
    MraidEvent event = (MraidEvent) field.get(mSpyBaseJSInterface);
    verify(mMockWebViewBase, times(1)).sendClickCallBack(anyString());
    assertEquals(JSInterface.ACTION_OPEN, 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 3 with MraidEvent

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

the class BaseJSInterfaceTest method closeTest.

@Test
public void closeTest() throws Exception {
    Field field = WhiteBox.field(BaseJSInterface.class, "mMraidEvent");
    mSpyBaseJSInterface.close();
    MraidEvent event = (MraidEvent) field.get(mSpyBaseJSInterface);
    assertEquals(JSInterface.ACTION_CLOSE, 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 4 with MraidEvent

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

the class BaseJSInterfaceTest method playVideoTest.

@Test
public void playVideoTest() throws Exception {
    Field field = WhiteBox.field(BaseJSInterface.class, "mMraidEvent");
    mSpyBaseJSInterface.playVideo("test");
    MraidEvent event = (MraidEvent) field.get(mSpyBaseJSInterface);
    assertEquals(JSInterface.ACTION_PLAY_VIDEO, 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 5 with MraidEvent

use of org.prebid.mobile.rendering.models.internal.MraidEvent 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)

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