use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.
the class AutoDetectedOpenRtbTest method setup.
@Before
public void setup() {
mActivity = Robolectric.buildActivity(Activity.class).create().get();
ShadowActivity shadowActivity = shadowOf(mActivity);
shadowActivity.grantPermissions("android.permission.ACCESS_FINE_LOCATION");
LocationManager locationManager = (LocationManager) mActivity.getSystemService(Context.LOCATION_SERVICE);
ShadowLocationManager shadowLocationManager = shadowOf(locationManager);
Location location = new Location("");
location.setLatitude(1);
location.setLongitude(1);
shadowLocationManager.setLastKnownLocation("gps", location);
ShadowTelephonyManager shadowTelephonyManager = shadowOf((TelephonyManager) mActivity.getSystemService(Context.TELEPHONY_SERVICE));
shadowTelephonyManager.setNetworkOperatorName("carrier");
shadowTelephonyManager.setNetworkOperator("carrier");
ManagersResolver.getInstance().prepare(mActivity);
mParamBuilderArray = new ArrayList<>();
mOriginalAdRequestInput = new AdRequestInput();
mOriginalOpenRtbParams = new BidRequest();
}
use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.
the class AutoDetectedOpenRtbTest method overwrittenNetworkParameterBuilder.
@Test
public void overwrittenNetworkParameterBuilder() {
mOriginalOpenRtbParams.getDevice().mccmnc = "foo";
mOriginalOpenRtbParams.getDevice().carrier = "foo";
mOriginalOpenRtbParams.getDevice().connectiontype = 0;
mParamBuilderArray.add(new NetworkParameterBuilder());
AdRequestInput newAdRequestInput = URLBuilder.buildParameters(mParamBuilderArray, mOriginalAdRequestInput);
BidRequest newOpenRtbParams = newAdRequestInput.getBidRequest();
assertNotEquals(mOriginalOpenRtbParams.getDevice().mccmnc, newOpenRtbParams.getDevice().mccmnc);
assertNotEquals(mOriginalOpenRtbParams.getDevice().carrier, newOpenRtbParams.getDevice().carrier);
assertNotEquals(mOriginalOpenRtbParams.getDevice().connectiontype, newOpenRtbParams.getDevice().connectiontype);
}
use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.
the class BidUrlComponentsTest method whenGetQueryArgString_ReturnBidRequestJson.
@Test
public void whenGetQueryArgString_ReturnBidRequestJson() throws JSONException {
AdRequestInput adRequestInput = new AdRequestInput();
BidRequest mockBidRequest = mock(BidRequest.class);
JSONObject jsonObject = new JSONObject();
jsonObject.put("test", "test");
when(mockBidRequest.getJsonObject()).thenReturn(jsonObject);
adRequestInput.setBidRequest(mockBidRequest);
BidUrlComponents bidUrlComponents = new BidUrlComponents("", adRequestInput);
assertEquals(jsonObject.toString(), bidUrlComponents.getQueryArgString());
}
use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method whenAppendParametersAndVastWithPlacementType_ImpWithValidVideoObject.
@Test
public void whenAppendParametersAndVastWithPlacementType_ImpWithValidVideoObject() throws JSONException {
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.VAST);
adConfiguration.setPlacementType(PlacementType.IN_BANNER);
adConfiguration.setAdPosition(AdPosition.FULLSCREEN);
adConfiguration.addSize(new AdSize(300, 250));
BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
BidRequest actualBidRequest = adRequestInput.getBidRequest();
BidRequest expectedBidRequest = getExpectedBidRequest(adConfiguration, actualBidRequest.getId());
assertEquals(expectedBidRequest.getJsonObject().toString(), actualBidRequest.getJsonObject().toString());
Imp actualImp = actualBidRequest.getImp().get(0);
assertNotNull(actualImp.video);
assertNull(actualImp.banner);
assertNull(actualImp.secure);
assertEquals(1, actualImp.instl.intValue());
assertEquals(300, actualImp.video.w.intValue());
assertEquals(250, actualImp.video.h.intValue());
assertNotEquals(VIDEO_INTERSTITIAL_PLACEMENT, actualImp.video.placement.intValue());
}
use of org.prebid.mobile.rendering.models.openrtb.BidRequest in project prebid-mobile-android by prebid.
the class BasicParameterBuilderTest method whenAppendParametersAndVastWithoutPlacementType_ImpWithValidVideoObject.
@Test
public void whenAppendParametersAndVastWithoutPlacementType_ImpWithValidVideoObject() throws JSONException {
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.VAST);
adConfiguration.setAdPosition(AdPosition.FULLSCREEN);
BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
BidRequest actualBidRequest = adRequestInput.getBidRequest();
BidRequest expectedBidRequest = getExpectedBidRequest(adConfiguration, actualBidRequest.getId());
assertEquals(expectedBidRequest.getJsonObject().toString(), actualBidRequest.getJsonObject().toString());
Imp actualImp = actualBidRequest.getImp().get(0);
assertNotNull(actualImp.video);
assertNull(actualImp.banner);
assertNull(actualImp.secure);
assertEquals(1920, actualImp.video.w.intValue());
assertEquals(1080, actualImp.video.h.intValue());
assertEquals(VIDEO_INTERSTITIAL_PLACEMENT, actualImp.video.placement.intValue());
assertEquals(1, actualImp.instl.intValue());
}
Aggregations