Search in sources :

Example 6 with BidRequest

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();
}
Also used : ShadowLocationManager(org.robolectric.shadows.ShadowLocationManager) LocationManager(android.location.LocationManager) AdRequestInput(org.prebid.mobile.rendering.networking.parameters.AdRequestInput) ShadowTelephonyManager(org.robolectric.shadows.ShadowTelephonyManager) ShadowLocationManager(org.robolectric.shadows.ShadowLocationManager) ShadowActivity(org.robolectric.shadows.ShadowActivity) Activity(android.app.Activity) ShadowActivity(org.robolectric.shadows.ShadowActivity) Location(android.location.Location) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Before(org.junit.Before)

Example 7 with 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);
}
Also used : AdRequestInput(org.prebid.mobile.rendering.networking.parameters.AdRequestInput) NetworkParameterBuilder(org.prebid.mobile.rendering.networking.parameters.NetworkParameterBuilder) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 8 with BidRequest

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());
}
Also used : AdRequestInput(org.prebid.mobile.rendering.networking.parameters.AdRequestInput) JSONObject(org.json.JSONObject) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 9 with BidRequest

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());
}
Also used : AdSize(org.prebid.mobile.rendering.bidding.data.AdSize) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 10 with BidRequest

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());
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Imp(org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Aggregations

BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)24 Test (org.junit.Test)20 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)11 AdRequestInput (org.prebid.mobile.rendering.networking.parameters.AdRequestInput)8 BasicParameterBuilder (org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)7 Imp (org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)5 AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)4 NetworkInfo (android.net.NetworkInfo)2 JSONObject (org.json.JSONObject)2 Device (org.prebid.mobile.rendering.models.openrtb.bidRequests.Device)2 Activity (android.app.Activity)1 Location (android.location.Location)1 LocationManager (android.location.LocationManager)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 Before (org.junit.Before)1 ContentObject (org.prebid.mobile.ContentObject)1 App (org.prebid.mobile.rendering.models.openrtb.bidRequests.App)1 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)1 Geo (org.prebid.mobile.rendering.models.openrtb.bidRequests.devices.Geo)1