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