Search in sources :

Example 1 with TransactionManager

use of org.prebid.mobile.rendering.loading.TransactionManager 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 TransactionManager

use of org.prebid.mobile.rendering.loading.TransactionManager in project prebid-mobile-android by prebid.

the class AdViewManagerTest method showTest.

@Test
public void showTest() throws Exception {
    AbstractCreative mock = mock(AbstractCreative.class);
    when(mock.getCreativeView()).thenReturn(mock(View.class));
    TransactionManager mockTransactionManager = mock(TransactionManager.class);
    when(mockTransactionManager.getCurrentCreative()).thenReturn(mock);
    WhiteBox.field(AdViewManager.class, "mTransactionManager").set(mAdViewManager, mockTransactionManager);
    mAdViewManager.show();
    verify(mMockAdViewListener).viewReadyForImmediateDisplay(any(View.class));
}
Also used : AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) 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 3 with TransactionManager

use of org.prebid.mobile.rendering.loading.TransactionManager in project prebid-mobile-android by prebid.

the class AdViewManagerTest method whenBannerHtmlNotResolved_Return.

@Test
public void whenBannerHtmlNotResolved_Return() throws IllegalAccessException, AdException {
    ViewGroup mockBanner = mock(ViewGroup.class);
    mAdViewManager = new AdViewManager(mContext, mMockAdViewListener, mockBanner, mock(InterstitialManager.class));
    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) ViewGroup(android.view.ViewGroup) 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 4 with TransactionManager

use of org.prebid.mobile.rendering.loading.TransactionManager in project prebid-mobile-android by prebid.

the class AdViewManagerTest method whenInterstitialVideoNotResolved_Return.

@Test
public void whenInterstitialVideoNotResolved_Return() throws IllegalAccessException {
    AbstractCreative mockCreative = mock(AbstractCreative.class);
    when(mockCreative.isDisplay()).thenReturn(false);
    when(mockCreative.isVideo()).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 5 with TransactionManager

use of org.prebid.mobile.rendering.loading.TransactionManager in project prebid-mobile-android by prebid.

the class AdViewManagerTest method whenVideoNotResolved_Return.

@Test
public void whenVideoNotResolved_Return() throws AdException, IllegalAccessException {
    VideoView mockVideoView = mock(VideoView.class);
    mAdViewManager = new AdViewManager(mContext, mMockAdViewListener, mockVideoView, mock(InterstitialManager.class));
    AbstractCreative mockCreative = mock(AbstractCreative.class);
    when(mockCreative.isVideo()).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) VideoView(org.prebid.mobile.rendering.bidding.display.VideoView) 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)

Aggregations

Test (org.junit.Test)8 TransactionManager (org.prebid.mobile.rendering.loading.TransactionManager)8 AbstractCreative (org.prebid.mobile.rendering.models.AbstractCreative)6 View (android.view.View)5 InterstitialView (org.prebid.mobile.rendering.bidding.display.InterstitialView)5 VideoView (org.prebid.mobile.rendering.bidding.display.VideoView)5 VideoCreativeView (org.prebid.mobile.rendering.video.VideoCreativeView)5 ArgumentCaptor (org.mockito.ArgumentCaptor)4 Transaction (org.prebid.mobile.rendering.loading.Transaction)2 ViewGroup (android.view.ViewGroup)1 ArrayList (java.util.ArrayList)1 CreativeFactory (org.prebid.mobile.rendering.loading.CreativeFactory)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