use of org.prebid.mobile.rendering.models.AdConfiguration 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.AdConfiguration in project prebid-mobile-android by prebid.
the class PrebidBannerAdapter method requestBannerAd.
@Override
public void requestBannerAd(@NonNull Context context, @NonNull CustomEventBannerListener adMobListener, @Nullable String serverParameter, @NonNull AdSize adSize, @NonNull MediationAdRequest mediationAdRequest, @Nullable Bundle extras) {
if (extras == null) {
String error = "Extras are empty! Check if you add custom event extras bundle to " + TAG;
Log.e(TAG, error);
adMobListener.onAdFailedToLoad(new AdError(1001, error, "prebid"));
return;
}
String responseId = extras.getString(EXTRA_RESPONSE_ID);
if (responseId == null) {
String error = "Response id is null";
adMobListener.onAdFailedToLoad(new AdError(1002, error, "prebid"));
return;
}
HashMap<String, String> prebidParameters = BidResponseCache.getInstance().getKeywords(responseId);
if (!ParametersMatcher.doParametersMatch(serverParameter, prebidParameters)) {
String error = "Parameters are different";
adMobListener.onAdFailedToLoad(new AdError(1003, error, "prebid"));
return;
}
LogUtil.v(TAG, "Parameters are matched! (" + serverParameter + ")");
BidResponse response = BidResponseCache.getInstance().popBidResponse(responseId);
if (response == null) {
String error = "There's no response for the response id: " + responseId;
adMobListener.onAdFailedToLoad(new AdError(1004, error, "prebid"));
return;
}
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
DisplayViewListener listener = getListener(adMobListener);
adView = new DisplayView(context, listener, adConfiguration, response);
}
use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class InterstitialController method loadAd.
public void loadAd(String responseId, boolean isRewarded) {
BidResponse bidResponse = BidResponseCache.getInstance().popBidResponse(responseId);
if (bidResponse == null) {
if (mListener != null) {
mListener.onInterstitialFailedToLoad(new AdException(AdException.INTERNAL_ERROR, "No bid response found in the cache"));
}
return;
}
AdConfiguration adUnitConfiguration = new AdConfiguration();
adUnitConfiguration.setRewarded(isRewarded);
loadAd(adUnitConfiguration, bidResponse);
}
use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class InterstitialView method setAdViewManagerValues.
protected void setAdViewManagerValues() throws AdException {
mAdViewManager = new AdViewManager(getContext(), mOnAdViewManagerListener, this, mInterstitialManager);
AdConfiguration adConfiguration = mAdViewManager.getAdConfiguration();
adConfiguration.setAutoRefreshDelay(0);
}
use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class AppInfoParameterBuilderTest method whenAppendParametersAndTargetingContextDataNotEmpty_ContextDataAddedToAppExt.
@Test
public void whenAppendParametersAndTargetingContextDataNotEmpty_ContextDataAddedToAppExt() throws JSONException {
Targeting.addContextData("context", "contextData");
AppInfoParameterBuilder builder = new AppInfoParameterBuilder(new AdConfiguration());
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
Ext appExt = adRequestInput.getBidRequest().getApp().getExt();
assertTrue(appExt.getMap().containsKey("data"));
JSONObject appDataJson = (JSONObject) appExt.getMap().get("data");
assertTrue(appDataJson.has("context"));
assertEquals("contextData", appDataJson.getJSONArray("context").get(0));
}
Aggregations