Search in sources :

Example 11 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration 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 12 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration 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)

Example 13 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method whenAppendParametersAndTargetingUserDataNotEmpty_UserDataAddedToUserExt.

@Test
public void whenAppendParametersAndTargetingUserDataNotEmpty_UserDataAddedToUserExt() throws JSONException {
    Targeting.addUserData("user", "userData");
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setConfigId("config");
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), false);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    User user = adRequestInput.getBidRequest().getUser();
    assertTrue(user.getExt().getMap().containsKey("data"));
    JSONObject userDataJson = (JSONObject) user.getExt().getMap().get("data");
    assertTrue(userDataJson.has("user"));
    assertEquals("userData", userDataJson.getJSONArray("user").get(0));
}
Also used : User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User) JSONObject(org.json.JSONObject) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Test(org.junit.Test)

Example 14 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method whenAppendParametersAndCoppaTrue_CoppaEqualsOne.

@Test
public void whenAppendParametersAndCoppaTrue_CoppaEqualsOne() {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    PrebidRenderingSettings.isCoppaEnabled = true;
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    BidRequest actualBidRequest = adRequestInput.getBidRequest();
    assertEquals(1, actualBidRequest.getRegs().coppa.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) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 15 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.

the class BasicParameterBuilderTest method whenAppendParametersAndUseExternalBrowserFalseAndBrowserActivityNotAvailable_ClickBrowserEqualsOne.

@Test
public void whenAppendParametersAndUseExternalBrowserFalseAndBrowserActivityNotAvailable_ClickBrowserEqualsOne() {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    PrebidRenderingSettings.useExternalBrowser = false;
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), false);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    Imp actualImp = adRequestInput.getBidRequest().getImp().get(0);
    assertEquals(1, actualImp.clickBrowser.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) Test(org.junit.Test)

Aggregations

AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)57 Test (org.junit.Test)38 BasicParameterBuilder (org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)15 AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)13 BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)11 Before (org.junit.Before)8 Imp (org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)8 Context (android.content.Context)6 JSONObject (org.json.JSONObject)6 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)6 Activity (android.app.Activity)5 AdException (org.prebid.mobile.rendering.errors.AdException)5 AbstractCreative (org.prebid.mobile.rendering.models.AbstractCreative)5 VideoCreativeModel (org.prebid.mobile.rendering.video.VideoCreativeModel)5 AdViewManager (org.prebid.mobile.rendering.views.AdViewManager)5 Handler (android.os.Handler)3 JSONArray (org.json.JSONArray)3 HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)3 Ext (org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext)3 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)3