Search in sources :

Example 1 with CreativeFactory

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();
}
Also used : VideoCreative(org.prebid.mobile.rendering.video.VideoCreative) Transaction(org.prebid.mobile.rendering.loading.Transaction) TransactionManager(org.prebid.mobile.rendering.loading.TransactionManager) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) ArrayList(java.util.ArrayList) CreativeFactory(org.prebid.mobile.rendering.loading.CreativeFactory) VideoCreativeModel(org.prebid.mobile.rendering.video.VideoCreativeModel) Test(org.junit.Test)

Example 2 with CreativeFactory

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));
}
Also used : AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) Transaction(org.prebid.mobile.rendering.loading.Transaction) ArrayList(java.util.ArrayList) AdDetails(org.prebid.mobile.rendering.models.AdDetails) CreativeFactory(org.prebid.mobile.rendering.loading.CreativeFactory) Test(org.junit.Test)

Example 3 with CreativeFactory

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();
}
Also used : AdDetails(org.prebid.mobile.rendering.models.AdDetails) CreativeFactory(org.prebid.mobile.rendering.loading.CreativeFactory) AdException(org.prebid.mobile.rendering.errors.AdException)

Aggregations

CreativeFactory (org.prebid.mobile.rendering.loading.CreativeFactory)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Transaction (org.prebid.mobile.rendering.loading.Transaction)2 AdDetails (org.prebid.mobile.rendering.models.AdDetails)2 AdException (org.prebid.mobile.rendering.errors.AdException)1 TransactionManager (org.prebid.mobile.rendering.loading.TransactionManager)1 AbstractCreative (org.prebid.mobile.rendering.models.AbstractCreative)1 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)1 VideoCreative (org.prebid.mobile.rendering.video.VideoCreative)1 VideoCreativeModel (org.prebid.mobile.rendering.video.VideoCreativeModel)1