use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class InterstitialViewTest method loadAd_ExecuteBidTransactionLoad.
@Test
public void loadAd_ExecuteBidTransactionLoad() {
AdConfiguration mockAdUnitConfiguration = mock(AdConfiguration.class);
BidResponse mockBidResponse = mock(BidResponse.class);
mSpyBidInterstitialView.loadAd(mockAdUnitConfiguration, mockBidResponse);
verify(mMockAdViewManager, times(1)).loadBidTransaction(eq(mockAdUnitConfiguration), eq(mockBidResponse));
}
use of org.prebid.mobile.rendering.models.AdConfiguration 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.AdConfiguration in project prebid-mobile-android by prebid.
the class BannerViewTest method setVideoPlacementType_AdUnitIdentifierTypeIsVASTAndVideoPlacementIsUpdated.
@Test
public void setVideoPlacementType_AdUnitIdentifierTypeIsVASTAndVideoPlacementIsUpdated() throws IllegalAccessException {
final VideoPlacementType videoPlacement = VideoPlacementType.IN_BANNER;
AdConfiguration mockAdConfiguration = mock(AdConfiguration.class);
WhiteBox.field(BannerView.class, "mAdUnitConfig").set(mBannerView, mockAdConfiguration);
mBannerView.setVideoPlacementType(videoPlacement);
verify(mockAdConfiguration, times(1)).setPlacementType(eq(VideoPlacementType.mapToPlacementType(videoPlacement)));
verify(mockAdConfiguration, times(1)).setAdUnitIdentifierType(eq(AdConfiguration.AdUnitIdentifierType.VAST));
}
use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class PrebidTest method whenGetJsonObjectForImp_EqualsExpected.
@Test
public void whenGetJsonObjectForImp_EqualsExpected() throws JSONException {
final String configId = "test";
final AdConfiguration adUnitConfiguration = new AdConfiguration();
adUnitConfiguration.setConfigId(configId);
JSONObject expected = new JSONObject();
StoredRequest storedRequest = new StoredRequest(configId);
expected.put("storedrequest", storedRequest.toJSONObject());
assertEquals(expected.toString(), Prebid.getJsonObjectForImp(adUnitConfiguration).toString());
expected.put("is_rewarded_inventory", 1);
adUnitConfiguration.setRewarded(true);
assertEquals(expected.toString(), Prebid.getJsonObjectForImp(adUnitConfiguration).toString());
}
use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class InterstitialView method showVideoAsInterstitial.
public void showVideoAsInterstitial() {
try {
final AdConfiguration adConfiguration = mAdViewManager.getAdConfiguration();
mInterstitialManager.configureInterstitialProperties(adConfiguration);
mInterstitialVideo = new InterstitialVideo(getContext(), InterstitialView.this, mInterstitialManager, adConfiguration);
mInterstitialVideo.setDialogListener(this::handleDialogEvent);
mInterstitialVideo.show();
} catch (final Exception e) {
LogUtil.error(TAG, "Video interstitial failed to show:" + Log.getStackTraceString(e));
notifyErrorListeners(new AdException(AdException.INTERNAL_ERROR, e.getMessage()));
}
}
Aggregations