@Test public void loadBanner_whenNoHtmlResponse_shouldNotifyBannerFailed() throws Exception { serverExtras.remove(HTML_RESPONSE_BODY_KEY); subject.loadBanner(context, customEventBannerListener, localExtras, serverExtras); verify(customEventBannerListener).onBannerFailed(eq(NETWORK_INVALID_STATE)); assertThat(TestHtmlBannerWebViewFactory.getLatestListener()).isNull(); assertThat(TestHtmlBannerWebViewFactory.getLatestIsScrollable()).isFalse(); assertThat(TestHtmlBannerWebViewFactory.getLatestRedirectUrl()).isNull(); assertThat(TestHtmlBannerWebViewFactory.getLatestClickthroughUrl()).isNull(); verify(htmlBannerWebView, never()).loadHtmlResponse(anyString()); }
@Override protected void loadBanner( Context context, CustomEventBannerListener customEventBannerListener, Map<String, Object> localExtras, Map<String, String> serverExtras) { String htmlData; String redirectUrl; String clickthroughUrl; Boolean isScrollable; AdReport adReport; if (extrasAreValid(serverExtras)) { htmlData = serverExtras.get(DataKeys.HTML_RESPONSE_BODY_KEY); redirectUrl = serverExtras.get(DataKeys.REDIRECT_URL_KEY); clickthroughUrl = serverExtras.get(DataKeys.CLICKTHROUGH_URL_KEY); isScrollable = Boolean.valueOf(serverExtras.get(DataKeys.SCROLLABLE_KEY)); try { adReport = (AdReport) localExtras.get(AD_REPORT_KEY); } catch (ClassCastException e) { MoPubLog.e("LocalExtras contained an incorrect type."); customEventBannerListener.onBannerFailed(INTERNAL_ERROR); return; } } else { customEventBannerListener.onBannerFailed(NETWORK_INVALID_STATE); return; } mHtmlBannerWebView = HtmlBannerWebViewFactory.create(context, adReport, customEventBannerListener, isScrollable, redirectUrl, clickthroughUrl); AdViewController.setShouldHonorServerDimensions(mHtmlBannerWebView); mHtmlBannerWebView.loadHtmlResponse(htmlData); }
HtmlBanner extends CustomEventBanner { @Override protected void loadBanner( Context context, CustomEventBannerListener customEventBannerListener, Map<String, Object> localExtras, Map<String, String> serverExtras) { String htmlData; String redirectUrl; String clickthroughUrl; Boolean isScrollable; AdReport adReport; if (extrasAreValid(serverExtras)) { htmlData = serverExtras.get(DataKeys.HTML_RESPONSE_BODY_KEY); redirectUrl = serverExtras.get(DataKeys.REDIRECT_URL_KEY); clickthroughUrl = serverExtras.get(DataKeys.CLICKTHROUGH_URL_KEY); isScrollable = Boolean.valueOf(serverExtras.get(DataKeys.SCROLLABLE_KEY)); try { adReport = (AdReport) localExtras.get(AD_REPORT_KEY); } catch (ClassCastException e) { MoPubLog.e("LocalExtras contained an incorrect type."); customEventBannerListener.onBannerFailed(INTERNAL_ERROR); return; } } else { customEventBannerListener.onBannerFailed(NETWORK_INVALID_STATE); return; } mHtmlBannerWebView = HtmlBannerWebViewFactory.create(context, adReport, customEventBannerListener, isScrollable, redirectUrl, clickthroughUrl); AdViewController.setShouldHonorServerDimensions(mHtmlBannerWebView); mHtmlBannerWebView.loadHtmlResponse(htmlData); } }
HtmlBanner extends CustomEventBanner { @Override protected void loadBanner( Context context, CustomEventBannerListener customEventBannerListener, Map<String, Object> localExtras, Map<String, String> serverExtras) { String htmlData; String redirectUrl; String clickthroughUrl; Boolean isScrollable; AdReport adReport; if (extrasAreValid(serverExtras)) { htmlData = serverExtras.get(DataKeys.HTML_RESPONSE_BODY_KEY); redirectUrl = serverExtras.get(DataKeys.REDIRECT_URL_KEY); clickthroughUrl = serverExtras.get(DataKeys.CLICKTHROUGH_URL_KEY); isScrollable = Boolean.valueOf(serverExtras.get(DataKeys.SCROLLABLE_KEY)); try { adReport = (AdReport) localExtras.get(AD_REPORT_KEY); } catch (ClassCastException e) { MoPubLog.e("LocalExtras contained an incorrect type."); customEventBannerListener.onBannerFailed(INTERNAL_ERROR); return; } } else { customEventBannerListener.onBannerFailed(NETWORK_INVALID_STATE); return; } mHtmlBannerWebView = HtmlBannerWebViewFactory.create(context, adReport, customEventBannerListener, isScrollable, redirectUrl, clickthroughUrl); AdViewController.setShouldHonorServerDimensions(mHtmlBannerWebView); mHtmlBannerWebView.loadHtmlResponse(htmlData); }  }
HtmlBanner extends CustomEventBanner { @Override protected void loadBanner( Context context, CustomEventBannerListener customEventBannerListener, Map<String, Object> localExtras, Map<String, String> serverExtras) { String htmlData; String redirectUrl; String clickthroughUrl; Boolean isScrollable; AdReport adReport; if (extrasAreValid(serverExtras)) { htmlData = serverExtras.get(DataKeys.HTML_RESPONSE_BODY_KEY); redirectUrl = serverExtras.get(DataKeys.REDIRECT_URL_KEY); clickthroughUrl = serverExtras.get(DataKeys.CLICKTHROUGH_URL_KEY); isScrollable = Boolean.valueOf(serverExtras.get(DataKeys.SCROLLABLE_KEY)); try { adReport = (AdReport) localExtras.get(AD_REPORT_KEY); } catch (ClassCastException e) { MoPubLog.e("LocalExtras contained an incorrect type."); customEventBannerListener.onBannerFailed(INTERNAL_ERROR); return; } } else { customEventBannerListener.onBannerFailed(NETWORK_INVALID_STATE); return; } mHtmlBannerWebView = HtmlBannerWebViewFactory.create(context, adReport, customEventBannerListener, isScrollable, redirectUrl, clickthroughUrl); AdViewController.setShouldHonorServerDimensions(mHtmlBannerWebView); mHtmlBannerWebView.loadHtmlResponse(htmlData); }   }
HtmlBanner extends CustomEventBanner { @Override protected void loadBanner( Context context, CustomEventBannerListener customEventBannerListener, Map<String, Object> localExtras, Map<String, String> serverExtras) { String htmlData; String redirectUrl; String clickthroughUrl; Boolean isScrollable; AdReport adReport; if (extrasAreValid(serverExtras)) { htmlData = serverExtras.get(DataKeys.HTML_RESPONSE_BODY_KEY); redirectUrl = serverExtras.get(DataKeys.REDIRECT_URL_KEY); clickthroughUrl = serverExtras.get(DataKeys.CLICKTHROUGH_URL_KEY); isScrollable = Boolean.valueOf(serverExtras.get(DataKeys.SCROLLABLE_KEY)); try { adReport = (AdReport) localExtras.get(AD_REPORT_KEY); } catch (ClassCastException e) { MoPubLog.e("LocalExtras contained an incorrect type."); customEventBannerListener.onBannerFailed(INTERNAL_ERROR); return; } } else { customEventBannerListener.onBannerFailed(NETWORK_INVALID_STATE); return; } mHtmlBannerWebView = HtmlBannerWebViewFactory.create(context, adReport, customEventBannerListener, isScrollable, redirectUrl, clickthroughUrl); AdViewController.setShouldHonorServerDimensions(mHtmlBannerWebView); mHtmlBannerWebView.loadHtmlResponse(htmlData); }    }