Search in sources :

Example 6 with HTMLCreative

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

the class MraidExpandTest method expandTest.

@Test
public void expandTest() {
    doAnswer(invocation -> {
        RedirectUrlListener listener = invocation.getArgument(1);
        listener.onSuccess("test", "html");
        return null;
    }).when(mSpyBaseJsInterface).followToOriginalUrl(anyString(), any(RedirectUrlListener.class));
    PrebidWebViewBase mockPreloadedListener = mock(PrebidWebViewBase.class);
    HTMLCreative mockCreative = mock(HTMLCreative.class);
    when(mockPreloadedListener.getCreative()).thenReturn(mockCreative);
    when(mMockWebViewBase.getPreloadedListener()).thenReturn(mockPreloadedListener);
    CompletedCallBack callBack = mock(CompletedCallBack.class);
    final MraidVariableContainer mraidVariableContainer = mSpyBaseJsInterface.getMraidVariableContainer();
    mraidVariableContainer.setCurrentState(JSInterface.STATE_DEFAULT);
    MraidExpand spyExpand = spy(mMraidExpand);
    doAnswer(invocation -> {
        CompletedCallBack completedCallBack = invocation.getArgument(1);
        completedCallBack.expandDialogShown();
        return null;
    }).when(spyExpand).showExpandDialog(any(), any());
    spyExpand.expand("test", callBack);
    verify(mSpyBaseJsInterface).followToOriginalUrl(anyString(), any(RedirectUrlListener.class));
    assertEquals(mraidVariableContainer.getUrlForLaunching(), "test");
    verify(callBack).expandDialogShown();
    verify(spyExpand).showExpandDialog(any(), any());
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) MraidVariableContainer(org.prebid.mobile.rendering.models.internal.MraidVariableContainer) RedirectUrlListener(org.prebid.mobile.rendering.mraid.methods.network.RedirectUrlListener) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Example 7 with HTMLCreative

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

the class AdViewManager method handleVideoCreativeComplete.

private void handleVideoCreativeComplete(AbstractCreative creative) {
    Transaction transaction = mTransactionManager.getCurrentTransaction();
    boolean isBuiltInVideo = creative.isBuiltInVideo();
    closeInterstitial();
    if (mTransactionManager.hasNextCreative() && mAdView != null) {
        mTransactionManager.incrementCreativesCounter();
        // Assuming the next creative is an HTMLCreative
        HTMLCreative endCardCreative = (HTMLCreative) transaction.getCreativeFactories().get(1).getCreative();
        if (isBuiltInVideo) {
            mInterstitialManager.displayVideoAdViewInInterstitial(mContextReference.get(), mAdView);
        } else {
            mInterstitialManager.setInterstitialDisplayDelegate(endCardCreative);
            mInterstitialManager.displayAdViewInInterstitial(mContextReference.get(), mAdView);
        }
    }
    mAdViewListener.videoCreativePlaybackFinished();
}
Also used : Transaction(org.prebid.mobile.rendering.loading.Transaction) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative)

Example 8 with HTMLCreative

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

the class InterstitialManagerTest method interstitialClosedAndMraidCollapsed_DoNotNotifyMraidDelegate.

@Test
public void interstitialClosedAndMraidCollapsed_DoNotNotifyMraidDelegate() throws IllegalAccessException {
    HTMLCreative mockHtmlCreative = mock(HTMLCreative.class);
    AdInterstitialDialog mockAdInterstitialDialog = mock(AdInterstitialDialog.class);
    WhiteBox.field(InterstitialManager.class, "mInterstitialDialog").set(mSpyInterstitialManager, mockAdInterstitialDialog);
    mSpyInterstitialManager.setInterstitialDisplayDelegate(mockHtmlCreative);
    when(mMockMraidDelegate.collapseMraid()).thenReturn(true);
    mSpyInterstitialManager.interstitialClosed(null);
    verify(mockAdInterstitialDialog, never()).nullifyDialog();
}
Also used : AdInterstitialDialog(org.prebid.mobile.rendering.interstitial.AdInterstitialDialog) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Example 9 with HTMLCreative

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

Example 10 with HTMLCreative

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

the class MraidControllerTest method delegateOnInterstitialClosed_NullifyExpand.

@Test
public void delegateOnInterstitialClosed_NullifyExpand() throws IllegalAccessException {
    mMraidController = new MraidController(mMockInterstitialManager);
    MraidExpand mockMraidExpand = mock(MraidExpand.class);
    HTMLCreative mockCreative = mock(HTMLCreative.class);
    when(mockMraidExpand.isMraidExpanded()).thenReturn(true);
    when(mMockInterstitialManager.getHtmlCreative()).thenReturn(mockCreative);
    Field expandField = WhiteBox.field(MraidController.class, "mMraidExpand");
    expandField.set(mMraidController, mockMraidExpand);
    getMraidDelegate().collapseMraid();
    verify(mockCreative).mraidAdCollapsed();
    verify(mockMraidExpand).nullifyDialog();
    assertNull(expandField.get(mMraidController));
}
Also used : Field(java.lang.reflect.Field) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Aggregations

HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)14 Test (org.junit.Test)8 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)7 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)5 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)3 View (android.view.View)2 CreativeModel (org.prebid.mobile.rendering.models.CreativeModel)2 MraidEvent (org.prebid.mobile.rendering.models.internal.MraidEvent)2 Handler (android.os.Handler)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 AdException (org.prebid.mobile.rendering.errors.AdException)1 AdInterstitialDialog (org.prebid.mobile.rendering.interstitial.AdInterstitialDialog)1 CreativeViewListener (org.prebid.mobile.rendering.listeners.CreativeViewListener)1 Transaction (org.prebid.mobile.rendering.loading.Transaction)1 AbstractCreative (org.prebid.mobile.rendering.models.AbstractCreative)1 MraidVariableContainer (org.prebid.mobile.rendering.models.internal.MraidVariableContainer)1 MraidEventHandlerNotifierRunnable (org.prebid.mobile.rendering.mraid.methods.MraidEventHandlerNotifierRunnable)1 RedirectUrlListener (org.prebid.mobile.rendering.mraid.methods.network.RedirectUrlListener)1 PrebidWebViewBanner (org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner)1