use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Device in project prebid-mobile-android by prebid.
the class URLComponentsTest method testEncoding.
/**
* Test urlencoding of keys
*/
@Test
public void testEncoding() throws Exception {
BidRequest bidRequest = new BidRequest();
AdRequestInput mockAdRequestInput = new AdRequestInput();
Device device = new Device();
device.carrier = "tmobile";
bidRequest.setId("123");
bidRequest.setDevice(device);
mockAdRequestInput.setBidRequest(bidRequest);
URLComponents urlComponents = new URLComponents("", mockAdRequestInput);
String expected = "openrtb=%7B%22id%22%3A%22123%22%2C%22device%22%3A%7B%22carrier%22%3A%22tmobile%22%7D%7D";
assertEquals(expected, urlComponents.getQueryArgString());
}
use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Device in project prebid-mobile-android by prebid.
the class BidRequestTest method getJsonObject.
@Test
public void getJsonObject() throws Exception {
BidRequest bidReq = new BidRequest();
App app = new App();
app.id = "auid";
bidReq.setApp(app);
Device device = new Device();
device.h = 1111;
bidReq.setDevice(device);
Imp imp = new Imp();
imp.instl = 0;
ArrayList<Imp> imps = new ArrayList<>();
imps.add(imp);
bidReq.setImp(imps);
Regs regs = new Regs();
regs.coppa = 0;
bidReq.setRegs(regs);
User user = new User();
user.keywords = "q, o";
bidReq.setUser(user);
JSONObject actualObj = bidReq.getJsonObject();
String expectedString = "{\"app\":{\"id\":\"auid\"},\"regs\":{\"coppa\":0},\"imp\":[{\"instl\":0}],\"device\":{\"h\":1111},\"user\":{\"keywords\":\"q, o\"}}";
assertEquals("got: " + actualObj.toString(), expectedString, actualObj.toString());
bidReq.getJsonObject();
}
use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Device in project prebid-mobile-android by prebid.
the class DeviceInfoParameterBuilderTest method testAppendBuilderParameters.
@Test
public void testAppendBuilderParameters() throws Exception {
BidRequest expectedBidRequest = new BidRequest();
final Device expectedBidRequestDevice = expectedBidRequest.getDevice();
final String ipAddress = "192.168.0.1";
final String carrier = "carrier";
AdConfiguration adConfiguration = new AdConfiguration();
ParameterBuilder builder = new DeviceInfoParameterBuilder(adConfiguration);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
expectedBidRequestDevice.os = DeviceInfoParameterBuilder.PLATFORM_VALUE;
expectedBidRequestDevice.w = SCREEN_WIDTH;
expectedBidRequestDevice.h = SCREEN_HEIGHT;
expectedBidRequestDevice.language = Locale.getDefault().getLanguage();
expectedBidRequestDevice.osv = "4.4";
expectedBidRequestDevice.os = "Android";
expectedBidRequestDevice.model = "robolectric";
expectedBidRequestDevice.make = "unknown";
expectedBidRequestDevice.pxratio = 1f;
expectedBidRequestDevice.ua = AppInfoManager.getUserAgent();
expectedBidRequestDevice.ifa = AdIdManager.getAdId();
expectedBidRequestDevice.lmt = AdIdManager.isLimitAdTrackingEnabled() ? 1 : 0;
assertJsonEquals(expectedBidRequest.getJsonObject(), adRequestInput.getBidRequest().getJsonObject());
}
use of org.prebid.mobile.rendering.models.openrtb.bidRequests.Device in project prebid-mobile-android by prebid.
the class DeviceInfoParameterBuilder method appendBuilderParameters.
@Override
public void appendBuilderParameters(AdRequestInput adRequestInput) {
DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
if (deviceManager != null) {
int screenWidth = deviceManager.getScreenWidth();
int screenHeight = deviceManager.getScreenHeight();
Device device = adRequestInput.getBidRequest().getDevice();
device.pxratio = Utils.DENSITY;
if (screenWidth > 0 && screenHeight > 0) {
device.w = screenWidth;
device.h = screenHeight;
}
String advertisingId = AdIdManager.getAdId();
if (Utils.isNotBlank(advertisingId)) {
device.ifa = advertisingId;
}
device.make = Build.MANUFACTURER;
device.model = Build.MODEL;
device.os = PLATFORM_VALUE;
device.osv = Build.VERSION.RELEASE;
device.language = Locale.getDefault().getLanguage();
device.ua = AppInfoManager.getUserAgent();
// lmt and APP_ADVERTISING_ID_ENABLED are opposites
boolean lmt = AdIdManager.isLimitAdTrackingEnabled();
device.lmt = lmt ? 1 : 0;
final AdSize minSizePercentage = mAdConfiguration.getMinSizePercentage();
if (minSizePercentage != null) {
device.getExt().put("prebid", Prebid.getJsonObjectForDeviceMinSizePerc(minSizePercentage));
}
}
}
Aggregations