use of org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner in project prebid-mobile-android by prebid.
the class TwoPartExpandRunnable method run.
// NOTE: handleMRAIDEventsInCreative ACTION_EXPAND is invoked from a background thread.
// This means the webview instantiation should be performed from a UI thread.
@Override
public void run() {
HTMLCreative htmlCreative = mWeakHtmlCreative.get();
if (htmlCreative == null) {
LogUtil.error(TAG, "HTMLCreative object is null");
return;
}
PrebidWebViewBase prebidWebViewBanner = new PrebidWebViewBanner(mOldWebViewBase.getContext(), mMraidController.mInterstitialManager);
// inject mraid.js & load url here, for 2part expand
prebidWebViewBanner.setOldWebView(mOldWebViewBase);
prebidWebViewBanner.initTwoPartAndLoad(mMraidEvent.mraidActionHelper);
prebidWebViewBanner.setWebViewDelegate(htmlCreative);
prebidWebViewBanner.setCreative(htmlCreative);
// Set a view before handling any action.
htmlCreative.setCreativeView(prebidWebViewBanner);
htmlCreative.setTwoPartNewWebViewBase(prebidWebViewBanner);
mMraidController.expand(mOldWebViewBase, prebidWebViewBanner, mMraidEvent);
}
use of org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner in project prebid-mobile-android by prebid.
the class ViewPool method getUnoccupiedView.
// Q: why are we keeping it in occupied? Should we not put/get from unoccupied directly?
// A: Because, when a videoCreativeView is created, we will have to, anyways, add the view to the occupied bucket as it is going to be given to adView.
// So, do that step here itself.(distribution of work!)
public View getUnoccupiedView(Context context, VideoCreativeViewListener videoCreativeViewListener, AdConfiguration.AdUnitIdentifierType adType, InterstitialManager interstitialManager) throws AdException {
if (context == null) {
throw new AdException(AdException.INTERNAL_ERROR, "Context is null");
}
if (mUnoccupiedViews != null && mUnoccupiedViews.size() > 0) {
View view = mUnoccupiedViews.get(0);
Views.removeFromParent(view);
// get item from unoccupied & add it to occupied
swapToOccupied(view);
return mOccupiedViews.get(mOccupiedViews.size() - 1);
}
switch(adType) {
case BANNER:
plugPlayView = new PrebidWebViewBanner(context, interstitialManager);
break;
case INTERSTITIAL:
plugPlayView = new PrebidWebViewInterstitial(context, interstitialManager);
// add it to occupied
break;
case VAST:
plugPlayView = new ExoPlayerView(context, videoCreativeViewListener);
break;
}
addToOccupied(plugPlayView);
return plugPlayView;
}
use of org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner in project prebid-mobile-android by prebid.
the class HTMLCreativeTest method loadTest.
@Test
public void loadTest() throws Exception {
PrebidWebViewBanner mockPrebidWebViewBanner = mock(PrebidWebViewBanner.class);
ViewPool mockViewPool = mock(ViewPool.class);
when(mockViewPool.getUnoccupiedView(any(Context.class), any(), any(AdConfiguration.AdUnitIdentifierType.class), any(InterstitialManager.class))).thenReturn(mockPrebidWebViewBanner);
WhiteBox.field(ViewPool.class, "sInstance").set(null, mockViewPool);
// Test null context
try {
WhiteBox.field(HTMLCreative.class, "mContextReference").set(mHtmlCreative, null);
mHtmlCreative.load();
fail("AdException was NOT thrown");
} catch (AdException e) {
}
mHtmlCreative = new HTMLCreative(mContext, mMockModel, mMockOmAdSessionManager, mMockInterstitialManager);
// Test null adType
try {
mHtmlCreative.load();
fail("AdException was NOT thrown");
} catch (AdException e) {
}
// Test empty html
try {
when(mMockConfig.getAdUnitIdentifierType()).thenReturn(AdConfiguration.AdUnitIdentifierType.BANNER);
mHtmlCreative = new HTMLCreative(mContext, mMockModel, mMockOmAdSessionManager, mMockInterstitialManager);
mHtmlCreative.load();
fail("AdException was NOT thrown");
} catch (AdException e) {
}
// Test non-empty html
when(mMockConfig.getAdUnitIdentifierType()).thenReturn(AdConfiguration.AdUnitIdentifierType.BANNER);
when(mMockModel.getHtml()).thenReturn("foo");
mHtmlCreative = new HTMLCreative(mContext, mMockModel, mMockOmAdSessionManager, mMockInterstitialManager);
mHtmlCreative.load();
verify(mockPrebidWebViewBanner).loadHTML(any(), anyInt(), anyInt());
assertEquals(mockPrebidWebViewBanner, mHtmlCreative.getCreativeView());
}
Aggregations