Search in sources :

Example 11 with AbstractCreative

use of org.prebid.mobile.rendering.models.AbstractCreative in project prebid-mobile-android by prebid.

the class AdViewManagerTest method whenInterstitialHtmlNotResolved_Return.

@Test
public void whenInterstitialHtmlNotResolved_Return() throws IllegalAccessException {
    AbstractCreative mockCreative = mock(AbstractCreative.class);
    when(mockCreative.isDisplay()).thenReturn(true);
    when(mockCreative.isResolved()).thenReturn(false);
    WhiteBox.field(AdViewManager.class, "mCurrentCreative").set(mAdViewManager, mockCreative);
    TransactionManager mockTransactionManager = mock(TransactionManager.class);
    when(mockTransactionManager.getCurrentCreative()).thenReturn(mockCreative);
    WhiteBox.field(AdViewManager.class, "mTransactionManager").set(mAdViewManager, mockTransactionManager);
    ArgumentCaptor exceptionCaptor = ArgumentCaptor.forClass(AdException.class);
    mAdViewManager.show();
    verify(mMockAdViewListener, never()).viewReadyForImmediateDisplay(any(View.class));
    verify(mMockAdViewListener).failedToLoad((AdException) exceptionCaptor.capture());
    assertEquals("SDK internal error: Creative has not been resolved yet", ((AdException) exceptionCaptor.getValue()).getMessage());
}
Also used : AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) ArgumentCaptor(org.mockito.ArgumentCaptor) TransactionManager(org.prebid.mobile.rendering.loading.TransactionManager) InterstitialView(org.prebid.mobile.rendering.bidding.display.InterstitialView) View(android.view.View) VideoCreativeView(org.prebid.mobile.rendering.video.VideoCreativeView) VideoView(org.prebid.mobile.rendering.bidding.display.VideoView) Test(org.junit.Test)

Example 12 with AbstractCreative

use of org.prebid.mobile.rendering.models.AbstractCreative in project prebid-mobile-android by prebid.

the class InterstitialVideoTest method whenVastAndSscOffsetPresent_UseSscOffset.

@Test
public void whenVastAndSscOffsetPresent_UseSscOffset() throws Exception {
    Context context = mock(Context.class);
    AdViewManager adViewManager = new AdViewManager(context, mock(AdViewManagerListener.class), mMockAdView, mMockInterstitialManager);
    AdConfiguration adConfiguration = adViewManager.getAdConfiguration();
    adConfiguration.setVideoSkipOffset(10000);
    AbstractCreative mockCreative = mock(AbstractCreative.class);
    VideoCreativeModel mockModel = mock(VideoCreativeModel.class);
    when(mockModel.getSkipOffset()).thenReturn(20000L);
    when(mockCreative.getCreativeModel()).thenReturn(mockModel);
    WhiteBox.field(AdViewManager.class, "mCurrentCreative").set(adViewManager, mockCreative);
    when(mMockAdView.getMediaOffset()).thenReturn(adViewManager.getSkipOffset());
    mSpyInterstitialVideo.scheduleShowCloseBtnTask(mMockAdView);
    verify(mSpyInterstitialVideo).scheduleTimer(10L * 1000);
}
Also used : Context(android.content.Context) AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) AdViewManager(org.prebid.mobile.rendering.views.AdViewManager) AdViewManagerListener(org.prebid.mobile.rendering.views.AdViewManagerListener) VideoCreativeModel(org.prebid.mobile.rendering.video.VideoCreativeModel) Test(org.junit.Test)

Example 13 with AbstractCreative

use of org.prebid.mobile.rendering.models.AbstractCreative in project prebid-mobile-android by prebid.

the class AdViewManagerTest method creativeDidCollapseTest.

@Test
public void creativeDidCollapseTest() {
    AbstractCreative mockCreative = mock(AbstractCreative.class);
    mAdViewManager.creativeDidCollapse(mockCreative);
    verify(mMockAdViewListener).creativeCollapsed();
}
Also used : AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) Test(org.junit.Test)

Example 14 with AbstractCreative

use of org.prebid.mobile.rendering.models.AbstractCreative in project prebid-mobile-android by prebid.

the class AdViewManagerTest method creativeDidExpandTest.

@Test
public void creativeDidExpandTest() {
    AbstractCreative mockCreative = mock(AbstractCreative.class);
    mAdViewManager.creativeDidExpand(mockCreative);
    verify(mMockAdViewListener).creativeExpanded();
}
Also used : AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) Test(org.junit.Test)

Example 15 with AbstractCreative

use of org.prebid.mobile.rendering.models.AbstractCreative 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

AbstractCreative (org.prebid.mobile.rendering.models.AbstractCreative)18 Test (org.junit.Test)17 View (android.view.View)6 InterstitialView (org.prebid.mobile.rendering.bidding.display.InterstitialView)6 VideoView (org.prebid.mobile.rendering.bidding.display.VideoView)6 TransactionManager (org.prebid.mobile.rendering.loading.TransactionManager)6 VideoCreativeView (org.prebid.mobile.rendering.video.VideoCreativeView)6 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)5 ArgumentCaptor (org.mockito.ArgumentCaptor)4 VideoCreativeModel (org.prebid.mobile.rendering.video.VideoCreativeModel)4 Context (android.content.Context)3 AdViewManager (org.prebid.mobile.rendering.views.AdViewManager)3 AdViewManagerListener (org.prebid.mobile.rendering.views.AdViewManagerListener)3 Handler (android.os.Handler)2 ArrayList (java.util.ArrayList)2 Transaction (org.prebid.mobile.rendering.loading.Transaction)2 ViewGroup (android.view.ViewGroup)1 HashMap (java.util.HashMap)1 CreativeFactory (org.prebid.mobile.rendering.loading.CreativeFactory)1 AdDetails (org.prebid.mobile.rendering.models.AdDetails)1