Search in sources :

Example 6 with AdSize

use of org.prebid.mobile.rendering.bidding.data.AdSize 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 7 with AdSize

use of org.prebid.mobile.rendering.bidding.data.AdSize 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 8 with AdSize

use of org.prebid.mobile.rendering.bidding.data.AdSize 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)

Example 9 with AdSize

use of org.prebid.mobile.rendering.bidding.data.AdSize in project prebid-mobile-android by prebid.

the class BasicParameterBuilder method setBannerImpValues.

private void setBannerImpValues(Imp imp) {
    Banner banner = new Banner();
    banner.api = getApiFrameworks();
    if (mAdConfiguration.isAdType(AdUnitIdentifierType.BANNER)) {
        for (AdSize size : mAdConfiguration.getAdSizes()) {
            banner.addFormat(size.width, size.height);
        }
    } else if (mAdConfiguration.isAdType(AdUnitIdentifierType.INTERSTITIAL) && mResources != null) {
        Configuration deviceConfiguration = mResources.getConfiguration();
        banner.addFormat(deviceConfiguration.screenWidthDp, deviceConfiguration.screenHeightDp);
    }
    if (mAdConfiguration.isAdPositionValid()) {
        banner.pos = mAdConfiguration.getAdPositionValue();
    }
    imp.banner = 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)

Example 10 with AdSize

use of org.prebid.mobile.rendering.bidding.data.AdSize in project prebid-mobile-android by prebid.

the class MediationInterstitialAdUnitTest method whenInitAdConfig_PrepareAdConfigForInterstitial.

@Test
public void whenInitAdConfig_PrepareAdConfigForInterstitial() {
    AdSize adSize = new AdSize(1, 2);
    mMediationInterstitialAdUnit.initAdConfig("config", adSize);
    AdConfiguration adConfiguration = mMediationInterstitialAdUnit.mAdUnitConfig;
    assertEquals("config", adConfiguration.getConfigId());
    assertEquals(AdConfiguration.AdUnitIdentifierType.INTERSTITIAL, adConfiguration.getAdUnitIdentifierType());
    assertEquals(adSize, adConfiguration.getMinSizePercentage());
}
Also used : AdSize(org.prebid.mobile.rendering.bidding.data.AdSize) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Test(org.junit.Test)

Aggregations

AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)25 Test (org.junit.Test)15 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)15 BasicParameterBuilder (org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)9 Imp (org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)6 Configuration (android.content.res.Configuration)4 BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)4 Banner (org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.Banner)2 Video (org.prebid.mobile.rendering.models.openrtb.bidRequests.imps.Video)2 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 TypedArray (android.content.res.TypedArray)1 HashSet (java.util.HashSet)1 JSONArray (org.json.JSONArray)1 Before (org.junit.Before)1 MockMediationUtils (org.prebid.mobile.rendering.bidding.config.MockMediationUtils)1 Device (org.prebid.mobile.rendering.models.openrtb.bidRequests.Device)1 Ext (org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext)1 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)1 DeviceInfoManager (org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager)1