Search in sources :

Example 1 with Transaction

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

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();
}
Also used : Transaction(org.prebid.mobile.rendering.loading.Transaction) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative)

Example 3 with Transaction

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();
}
Also used : Transaction(org.prebid.mobile.rendering.loading.Transaction)

Example 4 with Transaction

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

Example 5 with Transaction

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

Aggregations

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