Search in sources :

Example 41 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration 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());
}
Also used : Device(org.prebid.mobile.rendering.models.openrtb.bidRequests.Device) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 42 with AdConfiguration

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

the class AutoDetectedOpenRtbTest method overwrittenDeviceInfoParameterBuilder.

@Test
public void overwrittenDeviceInfoParameterBuilder() {
    mOriginalOpenRtbParams.getDevice().dpidmd5 = "foo";
    mOriginalOpenRtbParams.getDevice().dpidsha1 = "foo";
    mOriginalOpenRtbParams.getDevice().w = 0;
    mOriginalOpenRtbParams.getDevice().h = 0;
    mParamBuilderArray.add(new DeviceInfoParameterBuilder(new AdConfiguration()));
    AdRequestInput newAdRequestInput = URLBuilder.buildParameters(mParamBuilderArray, mOriginalAdRequestInput);
    BidRequest newOpenRtbParams = newAdRequestInput.getBidRequest();
    assertNotEquals(mOriginalOpenRtbParams.getDevice().dpidmd5, newOpenRtbParams.getDevice().dpidmd5);
    assertNotEquals(mOriginalOpenRtbParams.getDevice().dpidsha1, newOpenRtbParams.getDevice().dpidsha1);
    assertNotEquals(mOriginalOpenRtbParams.getDevice().w, newOpenRtbParams.getDevice().w);
    assertNotEquals(mOriginalOpenRtbParams.getDevice().h, newOpenRtbParams.getDevice().h);
}
Also used : AdRequestInput(org.prebid.mobile.rendering.networking.parameters.AdRequestInput) DeviceInfoParameterBuilder(org.prebid.mobile.rendering.networking.parameters.DeviceInfoParameterBuilder) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 43 with AdConfiguration

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

the class AutoDetectedOpenRtbTest method overwrittenAppInfoParameterBuilder.

@Test
public void overwrittenAppInfoParameterBuilder() {
    mOriginalOpenRtbParams.getApp().name = "foo";
    mOriginalOpenRtbParams.getApp().bundle = "foo";
    mOriginalOpenRtbParams.getDevice().ifa = "foo";
    mOriginalOpenRtbParams.getDevice().lmt = 0;
    AppInfoManager.setAppName("bar");
    AppInfoManager.setPackageName("bar");
    AdIdManager.setAdId("bar");
    AdIdManager.setLimitAdTrackingEnabled(true);
    mParamBuilderArray.add(new AppInfoParameterBuilder(new AdConfiguration()));
    AdRequestInput newAdRequestInput = URLBuilder.buildParameters(mParamBuilderArray, mOriginalAdRequestInput);
    BidRequest newOpenRtbParams = newAdRequestInput.getBidRequest();
    assertNotEquals(mOriginalOpenRtbParams.getApp().name, newOpenRtbParams.getApp().name);
    assertNotEquals(mOriginalOpenRtbParams.getApp().bundle, newOpenRtbParams.getApp().bundle);
    assertNotEquals(mOriginalOpenRtbParams.getDevice().ifa, newOpenRtbParams.getDevice().ifa);
    assertNotEquals(mOriginalOpenRtbParams.getDevice().lmt, newOpenRtbParams.getDevice().lmt);
}
Also used : AppInfoParameterBuilder(org.prebid.mobile.rendering.networking.parameters.AppInfoParameterBuilder) AdRequestInput(org.prebid.mobile.rendering.networking.parameters.AdRequestInput) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BidRequest(org.prebid.mobile.rendering.models.openrtb.BidRequest) Test(org.junit.Test)

Example 44 with AdConfiguration

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

the class BasicParameterBuilderTest method whenAppendParametersAndUseExternalBrowserFalseAndBrowserActivityAvailable_ClickBrowserEqualsZero.

@Test
public void whenAppendParametersAndUseExternalBrowserFalseAndBrowserActivityAvailable_ClickBrowserEqualsZero() {
    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(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    Imp actualImp = adRequestInput.getBidRequest().getImp().get(0);
    assertEquals(0, 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)

Example 45 with AdConfiguration

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

the class BasicParameterBuilderTest method whenAppendParametersAndBInterstitialType_ImpWithValidBannerObject.

@Test
public void whenAppendParametersAndBInterstitialType_ImpWithValidBannerObject() throws JSONException {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.INTERSTITIAL);
    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.banner);
    Format expectedFormat = new Format(1920, 1080);
    assertTrue(actualImp.banner.getFormats().contains(expectedFormat));
    assertNull(actualImp.video);
    assertEquals(1, actualImp.secure.intValue());
    assertEquals(1, actualImp.instl.intValue());
}
Also used : Format(org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.pmps.Format) 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

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