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);
}
}
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");
}
}
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);
}
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));
}
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());
}
Aggregations