Search in sources :

Example 26 with AdConfiguration

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

the class InterstitialViewTest method loadAd_ExecuteBidTransactionLoad.

@Test
public void loadAd_ExecuteBidTransactionLoad() {
    AdConfiguration mockAdUnitConfiguration = mock(AdConfiguration.class);
    BidResponse mockBidResponse = mock(BidResponse.class);
    mSpyBidInterstitialView.loadAd(mockAdUnitConfiguration, mockBidResponse);
    verify(mMockAdViewManager, times(1)).loadBidTransaction(eq(mockAdUnitConfiguration), eq(mockBidResponse));
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Test(org.junit.Test)

Example 27 with AdConfiguration

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

the class CreativeFactoryTest method testAttemptVastCreative.

@Test
public void testAttemptVastCreative() throws Exception {
    VideoCreativeModel mockVideoModel = mock(VideoCreativeModel.class);
    AdConfiguration adConfiguration = new AdConfiguration();
    Handler mockHandler = mock(Handler.class);
    adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.VAST);
    HashMap<VideoAdEvent.Event, ArrayList<String>> videoEventsUrls = new HashMap<>();
    videoEventsUrls.put(VideoAdEvent.Event.AD_EXPAND, new ArrayList<>(Arrays.asList("AD_EXPAND")));
    when(mockVideoModel.getVideoEventUrls()).thenReturn(videoEventsUrls);
    when(mockVideoModel.getAdConfiguration()).thenReturn(adConfiguration);
    CreativeFactory creativeFactory;
    // Blank media URL
    when(mockVideoModel.getMediaUrl()).thenReturn("");
    creativeFactory = new CreativeFactory(mMockContext, mockVideoModel, mMockListener, mMockOmAdSessionManager, mMockInterstitialManager);
    creativeFactory.start();
    assertNull(WhiteBox.getInternalState(creativeFactory, "mCreative"));
    // Valid
    when(mockVideoModel.getMediaUrl()).thenReturn("mediaUrl");
    creativeFactory = new CreativeFactory(mMockContext, mockVideoModel, mMockListener, mMockOmAdSessionManager, mMockInterstitialManager);
    WhiteBox.field(CreativeFactory.class, "mTimeoutHandler").set(creativeFactory, mockHandler);
    creativeFactory.start();
    AbstractCreative creative = creativeFactory.getCreative();
    assertNotNull(creative);
    assertTrue(creative instanceof VideoCreative);
    verify(mockHandler).postDelayed(any(Runnable.class), eq(30_000L));
}
Also used : AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) VideoCreative(org.prebid.mobile.rendering.video.VideoCreative) HashMap(java.util.HashMap) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) ArrayList(java.util.ArrayList) Handler(android.os.Handler) VideoAdEvent(org.prebid.mobile.rendering.video.VideoAdEvent) VideoCreativeModel(org.prebid.mobile.rendering.video.VideoCreativeModel) Test(org.junit.Test)

Example 28 with AdConfiguration

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

the class BannerViewTest method setVideoPlacementType_AdUnitIdentifierTypeIsVASTAndVideoPlacementIsUpdated.

@Test
public void setVideoPlacementType_AdUnitIdentifierTypeIsVASTAndVideoPlacementIsUpdated() throws IllegalAccessException {
    final VideoPlacementType videoPlacement = VideoPlacementType.IN_BANNER;
    AdConfiguration mockAdConfiguration = mock(AdConfiguration.class);
    WhiteBox.field(BannerView.class, "mAdUnitConfig").set(mBannerView, mockAdConfiguration);
    mBannerView.setVideoPlacementType(videoPlacement);
    verify(mockAdConfiguration, times(1)).setPlacementType(eq(VideoPlacementType.mapToPlacementType(videoPlacement)));
    verify(mockAdConfiguration, times(1)).setAdUnitIdentifierType(eq(AdConfiguration.AdUnitIdentifierType.VAST));
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) VideoPlacementType(org.prebid.mobile.rendering.bidding.enums.VideoPlacementType) Test(org.junit.Test)

Example 29 with AdConfiguration

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

the class PrebidTest method whenGetJsonObjectForImp_EqualsExpected.

@Test
public void whenGetJsonObjectForImp_EqualsExpected() throws JSONException {
    final String configId = "test";
    final AdConfiguration adUnitConfiguration = new AdConfiguration();
    adUnitConfiguration.setConfigId(configId);
    JSONObject expected = new JSONObject();
    StoredRequest storedRequest = new StoredRequest(configId);
    expected.put("storedrequest", storedRequest.toJSONObject());
    assertEquals(expected.toString(), Prebid.getJsonObjectForImp(adUnitConfiguration).toString());
    expected.put("is_rewarded_inventory", 1);
    adUnitConfiguration.setRewarded(true);
    assertEquals(expected.toString(), Prebid.getJsonObjectForImp(adUnitConfiguration).toString());
}
Also used : JSONObject(org.json.JSONObject) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Test(org.junit.Test)

Example 30 with AdConfiguration

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

the class InterstitialView method showVideoAsInterstitial.

public void showVideoAsInterstitial() {
    try {
        final AdConfiguration adConfiguration = mAdViewManager.getAdConfiguration();
        mInterstitialManager.configureInterstitialProperties(adConfiguration);
        mInterstitialVideo = new InterstitialVideo(getContext(), InterstitialView.this, mInterstitialManager, adConfiguration);
        mInterstitialVideo.setDialogListener(this::handleDialogEvent);
        mInterstitialVideo.show();
    } catch (final Exception e) {
        LogUtil.error(TAG, "Video interstitial failed to show:" + Log.getStackTraceString(e));
        notifyErrorListeners(new AdException(AdException.INTERNAL_ERROR, e.getMessage()));
    }
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) InterstitialVideo(org.prebid.mobile.rendering.views.interstitial.InterstitialVideo) AdException(org.prebid.mobile.rendering.errors.AdException) AdException(org.prebid.mobile.rendering.errors.AdException)

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