use of org.prebid.mobile.rendering.loading.CreativeFactory 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.CreativeFactory 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));
}
use of org.prebid.mobile.rendering.loading.CreativeFactory in project prebid-mobile-android by prebid.
the class AdViewManager method processTransaction.
private void processTransaction(Transaction transaction) {
List<CreativeFactory> creativeFactories = transaction.getCreativeFactories();
if (!creativeFactories.isEmpty()) {
mCurrentCreative = creativeFactories.get(0).getCreative();
mCurrentCreative.createOmAdSession();
}
try {
final AdDetails adDetails = new AdDetails();
adDetails.setTransactionId(transaction.getTransactionState());
mAdViewListener.adLoaded(adDetails);
trackAdLoaded();
} catch (Exception e) {
LogUtil.error(TAG, "adLoaded failed: " + Log.getStackTraceString(e));
}
handleAutoDisplay();
}
Aggregations