Search in sources :

Example 1 with CreativeModel

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

the class Transaction method startCreativeFactories.

public void startCreativeFactories() {
    try {
        // Initialize list of CreativeFactories
        mCreativeFactories.clear();
        for (CreativeModel creativeModel : mCreativeModels) {
            CreativeFactory creativeFactory = new CreativeFactory(mContextReference.get(), creativeModel, new CreativeFactoryListener(this), mOmAdSessionManager, mInterstitialManager);
            mCreativeFactories.add(creativeFactory);
        }
        // Start first CreativeFactory, if any
        // On success, the CreativeFactoryListener will start the next CreativeFactory
        mCreativeFactoryIterator = mCreativeFactories.iterator();
        startNextCreativeFactory();
    } catch (AdException e) {
        mListener.onTransactionFailure(e, mLoaderIdentifier);
    }
}
Also used : CreativeModel(org.prebid.mobile.rendering.models.CreativeModel) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 2 with CreativeModel

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

the class Transaction method checkForBuiltInVideo.

private void checkForBuiltInVideo() {
    try {
        if (mCreativeModels != null && mCreativeModels.size() > 1) {
            CreativeModel creativeModel = mCreativeModels.get(0);
            boolean isBannerVideo = creativeModel.getAdConfiguration().isBuiltInVideo();
            if (isBannerVideo) {
                CreativeModel possibleEndCard = mCreativeModels.get(1);
                possibleEndCard.getAdConfiguration().setBuiltInVideo(true);
            }
        }
    } catch (Exception e) {
        LogUtil.error(TAG, "Failed to check for built in video override");
    }
}
Also used : CreativeModel(org.prebid.mobile.rendering.models.CreativeModel) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 3 with CreativeModel

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

the class PrebidWebViewBannerTest method loadHTMLTest.

@Test
public void loadHTMLTest() throws IOException {
    HTMLCreative mockCreative = mock(HTMLCreative.class);
    CreativeModel mockCreativeModel = mock(CreativeModel.class);
    when(mockCreative.getCreativeModel()).thenReturn(mockCreativeModel);
    when(mockCreativeModel.getHtml()).thenReturn(ResourceUtils.convertResourceToString("ad_contains_iframe"));
    when(mockCreativeModel.getAdConfiguration()).thenReturn(new AdConfiguration());
    mBanner.mCreative = mockCreative;
    mBanner.loadHTML(mAdHTML, 100, 200);
    assertNotNull(mBanner.mWebView);
    assertEquals("1part", mBanner.mWebView.mMRAIDBridgeName);
}
Also used : CreativeModel(org.prebid.mobile.rendering.models.CreativeModel) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Example 4 with CreativeModel

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

the class MraidControllerTest method callControllerHandler.

private void callControllerHandler(MraidEvent event) {
    final HTMLCreative mockCreative = mock(HTMLCreative.class);
    final CreativeModel mockCreativeModel = mock(CreativeModel.class);
    final WebViewBase mockOldWebView = mock(WebViewBase.class);
    when(mockCreative.getCreativeModel()).thenReturn(mockCreativeModel);
    when(mockCreativeModel.getAdConfiguration()).thenReturn(mock(AdConfiguration.class));
    when(mockOldWebView.getContext()).thenReturn(mContext);
    mMraidController.handleMraidEvent(event, mockCreative, mockOldWebView, mock(PrebidWebViewBase.class));
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) CreativeModel(org.prebid.mobile.rendering.models.CreativeModel) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative)

Example 5 with CreativeModel

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

the class TransactionTest method testCreativeFactoryListener.

// Tests when creative factories return
@Test
public void testCreativeFactoryListener() throws Exception {
    List<CreativeModel> mockCreativeModels = Collections.singletonList(mock(CreativeModel.class));
    Transaction.Listener mockListener = mock(Transaction.Listener.class);
    Transaction transaction = Transaction.createTransaction(mMockContext, createModelResult(mockCreativeModels, ""), mock(InterstitialManager.class), mockListener);
    Transaction.CreativeFactoryListener creativeFactoryListener = new Transaction.CreativeFactoryListener(transaction);
    // No more Creatives to construct
    // Transaction.Listener.onSuccess is called
    creativeFactoryListener.onSuccess();
    verify(mockListener).onTransactionSuccess(transaction);
    // More Creatives to construct
    // Transaction.Listener.onSuccess is not called
    reset(mockListener);
    Iterator<CreativeFactory> mockIterator = mock(Iterator.class);
    when(mockIterator.hasNext()).thenReturn(true);
    when(mockIterator.next()).thenReturn(mock(CreativeFactory.class));
    WhiteBox.setInternalState(transaction, "mCreativeFactoryIterator", mockIterator);
    creativeFactoryListener.onSuccess();
    verify(mockListener, never()).onTransactionSuccess(transaction);
    // On failure, Transaction.Listener.onFailure should be called
    AdException adException = new AdException("type", "message");
    creativeFactoryListener.onFailure(adException);
    verify(mockListener).onTransactionFailure(eq(adException), anyString());
}
Also used : CreativeModel(org.prebid.mobile.rendering.models.CreativeModel) InterstitialManager(org.prebid.mobile.rendering.views.interstitial.InterstitialManager) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Aggregations

CreativeModel (org.prebid.mobile.rendering.models.CreativeModel)10 Test (org.junit.Test)7 AdException (org.prebid.mobile.rendering.errors.AdException)6 HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)4 InterstitialManager (org.prebid.mobile.rendering.views.interstitial.InterstitialManager)4 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)3 ArrayList (java.util.ArrayList)2 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)1 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)1