Search in sources :

Example 36 with AdConfiguration

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

the class MraidController method handleMraidEvent.

public void handleMraidEvent(MraidEvent event, HTMLCreative creative, WebViewBase oldWebViewBase, PrebidWebViewBase twoPartNewWebViewBase) {
    switch(event.mraidAction) {
        case ACTION_EXPAND:
            if (Utils.isBlank(event.mraidActionHelper)) {
                LogUtil.debug(TAG, "One part expand");
                expand(oldWebViewBase, twoPartNewWebViewBase, event);
            } else {
                // 2 part : new webview
                Handler handler = new Handler(Looper.getMainLooper());
                handler.post(new TwoPartExpandRunnable(creative, event, oldWebViewBase, this));
            }
            break;
        case ACTION_CLOSE:
            close(oldWebViewBase);
            break;
        case ACTION_PLAY_VIDEO:
            playVideo(oldWebViewBase, event);
            break;
        case ACTION_OPEN:
            final AdConfiguration adConfiguration = creative.getCreativeModel().getAdConfiguration();
            open(oldWebViewBase, event.mraidActionHelper, adConfiguration.getBroadcastId());
            break;
        case ACTION_STORE_PICTURE:
            storePicture(oldWebViewBase, event.mraidActionHelper);
            break;
        case ACTION_CREATE_CALENDAR_EVENT:
            createCalendarEvent(oldWebViewBase.getMRAIDInterface(), event.mraidActionHelper);
            break;
        case ACTION_ORIENTATION_CHANGE:
            changeOrientation();
            break;
        case ACTION_RESIZE:
            resize(oldWebViewBase);
            break;
        case ACTION_UNLOAD:
            unload(creative, oldWebViewBase);
            break;
    }
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Handler(android.os.Handler)

Example 37 with AdConfiguration

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

the class BasicParameterBuilderTest method whenAppendParametersAndUseExternalBrowserTrueAndBrowserActivityAvailable_ClickBrowserEqualsOne.

@Test
public void whenAppendParametersAndUseExternalBrowserTrueAndBrowserActivityAvailable_ClickBrowserEqualsOne() {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    PrebidRenderingSettings.useExternalBrowser = true;
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    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)

Example 38 with AdConfiguration

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

the class BasicParameterBuilderTest method whenAppendParametersAndTargetingParamsWereSet_TargetingParamsWereAppend.

@Test
public void whenAppendParametersAndTargetingParamsWereSet_TargetingParamsWereAppend() throws JSONException {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    Targeting.setUserId(USER_ID);
    Targeting.setUserAge(USER_AGE);
    Targeting.setUserKeywords(USER_KEYWORDS);
    Targeting.setUserCustomData(USER_CUSTOM);
    Targeting.setUserGender(UserParameters.Gender.MALE);
    Targeting.setBuyerUid(USER_BUYER_ID);
    Targeting.setUserExt(new Ext());
    Targeting.setEids(new JSONArray());
    Targeting.setUserLatLng(USER_LAT, USER_LON);
    BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, mContext.getResources(), mBrowserActivityAvailable);
    AdRequestInput adRequestInput = new AdRequestInput();
    builder.appendBuilderParameters(adRequestInput);
    User actualUser = adRequestInput.getBidRequest().getUser();
    User expectedUser = getExpectedUser();
    assertEquals(expectedUser.getJsonObject().toString(), actualUser.getJsonObject().toString());
}
Also used : Ext(org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext) User(org.prebid.mobile.rendering.models.openrtb.bidRequests.User) AdSize(org.prebid.mobile.rendering.bidding.data.AdSize) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) JSONArray(org.json.JSONArray) BasicParameterBuilder(org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder) Test(org.junit.Test)

Example 39 with AdConfiguration

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

the class BasicParameterBuilderTest method whenAppendParametersAndBannerType_ImpWithValidBannerObject.

@Test
public void whenAppendParametersAndBannerType_ImpWithValidBannerObject() throws JSONException {
    AdConfiguration adConfiguration = new AdConfiguration();
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    adConfiguration.addSize(new AdSize(320, 50));
    adConfiguration.setPbAdSlot("12345");
    PrebidRenderingSettings.addStoredBidResponse("bidderTest", "123456");
    PrebidRenderingSettings.setStoredAuctionResponse("storedResponse");
    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);
    assertTrue(actualImp.banner.getFormats().containsAll(expectedBidRequest.getImp().get(0).banner.getFormats()));
    assertNull(actualImp.video);
    assertEquals(1, actualImp.secure.intValue());
    assertEquals(0, actualImp.instl.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 40 with AdConfiguration

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

the class AppInfoParameterBuilderTest method testAppendBuilderParameters.

@Test
public void testAppendBuilderParameters() throws Exception {
    AdConfiguration adConfiguration = new AdConfiguration();
    ContentObject contentObject = new ContentObject();
    contentObject.setUrl("test.com");
    adConfiguration.setAppContent(contentObject);
    AppInfoParameterBuilder builder = new AppInfoParameterBuilder(adConfiguration);
    AdRequestInput adRequestInput = new AdRequestInput();
    final String expectedStoreurl = "https://google.play.com";
    final String expectedPublisherName = "prebid";
    Targeting.setPublisherName(expectedPublisherName);
    Targeting.setAppStoreMarketUrl(expectedStoreurl);
    builder.appendBuilderParameters(adRequestInput);
    BidRequest expectedBidRequest = new BidRequest();
    final App expectedApp = expectedBidRequest.getApp();
    expectedApp.name = APP_NAME;
    expectedApp.bundle = APP_BUNDLE;
    expectedApp.storeurl = expectedStoreurl;
    expectedApp.getPublisher().name = expectedPublisherName;
    expectedApp.getExt().put("prebid", Prebid.getJsonObjectForApp(BasicParameterBuilder.DISPLAY_MANAGER_VALUE, PrebidRenderingSettings.SDK_VERSION));
    ContentObject expectedContentObject = new ContentObject();
    expectedContentObject.setUrl("test.com");
    expectedApp.contentObject = expectedContentObject;
    assertEquals(expectedBidRequest.getJsonObject().toString(), adRequestInput.getBidRequest().getJsonObject().toString());
}
Also used : App(org.prebid.mobile.rendering.models.openrtb.bidRequests.App) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) ContentObject(org.prebid.mobile.ContentObject) 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