Search in sources :

Example 6 with AbstractCreative

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

the class InterstitialVideoTest method whenRemainingTimePresent_UseRemainingTime.

@Test
public void whenRemainingTimePresent_UseRemainingTime() throws Exception {
    Context context = mock(Context.class);
    AdViewManager adViewManager = new AdViewManager(context, mock(AdViewManagerListener.class), mMockAdView, mock(InterstitialManager.class));
    AdConfiguration adConfiguration = adViewManager.getAdConfiguration();
    adConfiguration.setVideoSkipOffset(10);
    AbstractCreative mockCreative = mock(AbstractCreative.class);
    VideoCreativeModel mockModel = mock(VideoCreativeModel.class);
    when(mockModel.getSkipOffset()).thenReturn(20L);
    when(mockCreative.getCreativeModel()).thenReturn(mockModel);
    WhiteBox.field(AdViewManager.class, "mCurrentCreative").set(adViewManager, mockCreative);
    when(mMockAdView.getMediaOffset()).thenReturn(adViewManager.getSkipOffset());
    mSpyInterstitialVideo.setRemainingTimeInMs(3000);
    mSpyInterstitialVideo.scheduleShowCloseBtnTask(mMockAdView, 3000);
    verify(mSpyInterstitialVideo).scheduleTimer(3L * 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 7 with AbstractCreative

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

the class InterstitialVideoTest method whenAllOffsetsPresent_UseSscOffset.

@Test
public void whenAllOffsetsPresent_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 8 with AbstractCreative

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

the class CreativeFactoryTest method testAttemptVastCreative.

@Test
public void testAttemptVastCreative() throws Exception {
    VideoCreativeModel mockVideoModel = mock(VideoCreativeModel.class);
    AdConfiguration adConfiguration = new AdConfiguration();
    Handler mockHandler = mock(Handler.class);
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.VAST);
    HashMap<VideoAdEvent.Event, ArrayList<String>> videoEventsUrls = new HashMap<>();
    videoEventsUrls.put(VideoAdEvent.Event.AD_EXPAND, new ArrayList<>(Arrays.asList("AD_EXPAND")));
    when(mockVideoModel.getVideoEventUrls()).thenReturn(videoEventsUrls);
    when(mockVideoModel.getAdConfiguration()).thenReturn(adConfiguration);
    CreativeFactory creativeFactory;
    // Blank media URL
    when(mockVideoModel.getMediaUrl()).thenReturn("");
    creativeFactory = new CreativeFactory(mMockContext, mockVideoModel, mMockListener, mMockOmAdSessionManager, mMockInterstitialManager);
    creativeFactory.start();
    assertNull(WhiteBox.getInternalState(creativeFactory, "mCreative"));
    // Valid
    when(mockVideoModel.getMediaUrl()).thenReturn("mediaUrl");
    creativeFactory = new CreativeFactory(mMockContext, mockVideoModel, mMockListener, mMockOmAdSessionManager, mMockInterstitialManager);
    WhiteBox.field(CreativeFactory.class, "mTimeoutHandler").set(creativeFactory, mockHandler);
    creativeFactory.start();
    AbstractCreative creative = creativeFactory.getCreative();
    assertNotNull(creative);
    assertTrue(creative instanceof VideoCreative);
    verify(mockHandler).postDelayed(any(Runnable.class), eq(30_000L));
}
Also used : AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) VideoCreative(org.prebid.mobile.rendering.video.VideoCreative) HashMap(java.util.HashMap) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) ArrayList(java.util.ArrayList) Handler(android.os.Handler) VideoAdEvent(org.prebid.mobile.rendering.video.VideoAdEvent) VideoCreativeModel(org.prebid.mobile.rendering.video.VideoCreativeModel) Test(org.junit.Test)

Example 9 with AbstractCreative

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

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

the class AdViewManagerTest method setAdVisibilityTest.

@Test
public void setAdVisibilityTest() throws IllegalAccessException {
    AbstractCreative mockCreative = mock(AbstractCreative.class);
    WhiteBox.field(AdViewManager.class, "mCurrentCreative").set(mAdViewManager, mockCreative);
    mAdViewManager.setAdVisibility(View.INVISIBLE);
    verify(mockCreative).handleAdWindowNoFocus();
    mAdViewManager.setAdVisibility(View.VISIBLE);
    verify(mockCreative).handleAdWindowFocus();
}
Also used : AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) 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