Search in sources :

Example 16 with AdConfiguration

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

Example 17 with AdConfiguration

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));
}
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)

Example 18 with AdConfiguration

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

Example 19 with AdConfiguration

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;
}
Also used : Configuration(android.content.res.Configuration) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Video(org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.Video) AdSize(org.prebid.mobile.rendering.bidding.data.AdSize)

Example 20 with AdConfiguration

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;
}
Also used : Configuration(android.content.res.Configuration) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Banner(org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.Banner) AdSize(org.prebid.mobile.rendering.bidding.data.AdSize)

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