use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method whenAppendParametersAndTargetingAccessControlNotEmpty_BiddersAddedToExt.
@Test
public void whenAppendParametersAndTargetingAccessControlNotEmpty_BiddersAddedToExt() throws JSONException {
Targeting.addBidderToAccessControlList("bidder");
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setConfigId("config");
BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), false);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
BidRequest bidRequest = adRequestInput.getBidRequest();
JSONObject prebidJson = bidRequest.getExt().getJsonObject().getJSONObject("prebid");
assertTrue(prebidJson.has("data"));
JSONArray biddersArray = prebidJson.getJSONObject("data").getJSONArray("bidders");
assertEquals("bidder", biddersArray.get(0));
}
use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method whenAppendParametersAndSendMraidSupportParamsFalse_NoMraidApi.
@Test
public void whenAppendParametersAndSendMraidSupportParamsFalse_NoMraidApi() {
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
adConfiguration.addSize(new AdSize(320, 50));
PrebidRenderingSettings.sendMraidSupportParams = false;
BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
Imp actualImp = adRequestInput.getBidRequest().getImp().get(0);
assertEquals(Arrays.toString(new int[] { 7 }), Arrays.toString(actualImp.banner.api));
}
use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method whenAppendUserData_UserDataAddedToUser.
@Test
public void whenAppendUserData_UserDataAddedToUser() throws JSONException {
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setConfigId("config");
DataObject dataObject = new DataObject();
String testName = "testDataObject";
dataObject.setName(testName);
adConfiguration.addUserData(dataObject);
BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), false);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
User user = adRequestInput.getBidRequest().getUser();
assertEquals(1, user.dataObjects.size());
JSONObject jsonUser = user.getJsonObject();
assertTrue(jsonUser.has("data"));
JSONArray jsonData = jsonUser.getJSONArray("data");
JSONObject jsonDataObject = jsonData.getJSONObject(0);
assertTrue(jsonDataObject.has("name"));
String dataName = jsonDataObject.getString("name");
assertEquals(testName, dataName);
}
use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method getExpectedVideoImpValues.
private Video getExpectedVideoImpValues(Imp imp, AdConfiguration adConfiguration) {
Video video = new Video();
// Common values for all video reqs
video.mimes = BasicParameterBuilder.SUPPORTED_VIDEO_MIME_TYPES;
video.protocols = BasicParameterBuilder.SUPPORTED_VIDEO_PROTOCOLS;
video.linearity = BasicParameterBuilder.VIDEO_LINEARITY_LINEAR;
// Interstitial video specific values
// On Leaving Viewport or when Terminated by User
video.playbackend = VIDEO_INTERSTITIAL_PLAYBACK_END;
video.delivery = new int[] { BasicParameterBuilder.VIDEO_DELIVERY_DOWNLOAD };
video.pos = AdPosition.FULLSCREEN.getValue();
if (!adConfiguration.isPlacementTypeValid()) {
video.placement = VIDEO_INTERSTITIAL_PLACEMENT;
Configuration deviceConfiguration = mContext.getResources().getConfiguration();
video.w = deviceConfiguration.screenWidthDp;
video.h = deviceConfiguration.screenHeightDp;
} else {
video.placement = adConfiguration.getPlacementTypeValue();
for (AdSize size : adConfiguration.getAdSizes()) {
video.w = size.width;
video.h = size.height;
break;
}
}
return video;
}
use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method getExpectedBannerImpValues.
private Banner getExpectedBannerImpValues(Imp imp, AdConfiguration adConfiguration) {
Banner banner = new Banner();
banner.api = new int[] { 3, 5, 6, 7 };
if (adConfiguration.isAdType(AdConfiguration.AdUnitIdentifierType.BANNER)) {
for (AdSize size : adConfiguration.getAdSizes()) {
banner.addFormat(size.width, size.height);
}
} else if (adConfiguration.isAdType(AdConfiguration.AdUnitIdentifierType.INTERSTITIAL)) {
Configuration deviceConfiguration = mContext.getResources().getConfiguration();
banner.addFormat(deviceConfiguration.screenWidthDp, deviceConfiguration.screenHeightDp);
}
if (adConfiguration.isAdPositionValid()) {
banner.pos = adConfiguration.getAdPositionValue();
}
return banner;
}
Aggregations