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());
}
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();
}
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();
}
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));
}
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));
}
Aggregations