use of org.prebid.mobile.rendering.loading.Transaction in project prebid-mobile-android by prebid.
the class AdViewManagerTest method creativeDidCompleteTest.
@Test
public void creativeDidCompleteTest() throws Exception {
VideoCreative mockVideoCreative = mock(VideoCreative.class);
when(mockVideoCreative.getCreativeModel()).thenReturn(new VideoCreativeModel(mock(TrackingManager.class), mock(OmEventTracker.class), new AdConfiguration()));
when(mockVideoCreative.isVideo()).thenReturn(true);
Transaction mockTransaction = mock(Transaction.class);
ArrayList<CreativeFactory> creativeFactories = new ArrayList<>();
TransactionManager mockTransactionManager = mock(TransactionManager.class);
when(mockTransactionManager.getCurrentTransaction()).thenReturn(mockTransaction);
when(mockTransaction.getCreativeFactories()).thenReturn(creativeFactories);
WhiteBox.field(AdViewManager.class, "mTransactionManager").set(mAdViewManager, mockTransactionManager);
WhiteBox.field(AdViewManager.class, "mAdView").set(mAdViewManager, mockAdView);
mAdViewManager.creativeDidComplete(mockVideoCreative);
verify(mockAdView).closeInterstitialVideo();
verify(mMockAdViewListener, times(1)).adCompleted();
mAdViewManager.creativeDidComplete(mockVideoCreative);
verify(mMockAdViewListener, times(2)).adCompleted();
}
use of org.prebid.mobile.rendering.loading.Transaction 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.loading.Transaction in project prebid-mobile-android by prebid.
the class AdViewManager method creativeInterstitialDidClose.
@Override
public void creativeInterstitialDidClose(AbstractCreative creative) {
LogUtil.debug(TAG, "creativeInterstitialDidClose");
Transaction currentTransaction = mTransactionManager.getCurrentTransaction();
if (creative.isDisplay() && creative.isEndCard()) {
// Call ad close event for video tracking event
currentTransaction.getCreativeFactories().get(0).getCreative().trackVideoEvent(VideoAdEvent.Event.AD_CLOSE);
}
// Transaction is complete
resetTransactionState();
mAdViewListener.creativeInterstitialClosed();
}
use of org.prebid.mobile.rendering.loading.Transaction in project prebid-mobile-android by prebid.
the class AdViewManagerTest method creativeInterstitialDidCloseTest.
@Test
public void creativeInterstitialDidCloseTest() throws IllegalAccessException {
AbstractCreative mockCreative = mock(AbstractCreative.class);
TransactionManager mock = mock(TransactionManager.class);
Transaction transaction = mock(Transaction.class);
when(mock.getCurrentTransaction()).thenReturn(transaction);
WhiteBox.field(AdViewManager.class, "mTransactionManager").set(mAdViewManager, mock);
mAdViewManager.creativeInterstitialDidClose(mockCreative);
verify(mMockAdViewListener).creativeInterstitialClosed();
}
use of org.prebid.mobile.rendering.loading.Transaction in project prebid-mobile-android by prebid.
the class AdViewManagerTest method whenFetchedSuccessful_ProcessTransaction.
@Test
public void whenFetchedSuccessful_ProcessTransaction() {
Transaction mockTransaction = mock(Transaction.class);
CreativeFactory mockFactory = mock(CreativeFactory.class);
AbstractCreative mockCreative = mock(AbstractCreative.class);
when(mockFactory.getCreative()).thenReturn(mockCreative);
List<CreativeFactory> creativeFactories = new ArrayList<>();
creativeFactories.add(mockFactory);
when(mockTransaction.getTransactionState()).thenReturn("state");
when(mockTransaction.getCreativeFactories()).thenReturn(creativeFactories);
mAdViewManager.onFetchingCompleted(mockTransaction);
verify(mockCreative).createOmAdSession();
verify(mMockAdViewListener).adLoaded(any(AdDetails.class));
}
Aggregations