CustomEventBannerAdapter implements CustomEventBannerListener { @Override public void onBannerLoaded(View bannerView) { if (isInvalidated()) { return; } cancelTimeout(); if (mMoPubView != null) { mMoPubView.nativeAdLoaded(); mMoPubView.setAdContentView(bannerView); if (!(bannerView instanceof HtmlBannerWebView)) { mMoPubView.trackNativeImpression(); } } } CustomEventBannerAdapter(MoPubView moPubView, String className, String classData); @Override void onBannerLoaded(View bannerView); @Override void onBannerFailed(MoPubErrorCode errorCode); @Override void onBannerExpanded(); @Override void onBannerCollapsed(); @Override void onBannerClicked(); @Override void onLeaveApplication(); static final int DEFAULT_BANNER_TIMEOUT_DELAY; }
@Test public void onBannerLoaded_shouldSignalMoPubView() throws Exception { View view = new View(new Activity()); subject.onBannerLoaded(view); verify(moPubView).nativeAdLoaded(); verify(moPubView).setAdContentView(eq(view)); verify(moPubView).trackNativeImpression(); }
@Test public void onBannerLoaded_whenViewIsHtmlBannerWebView_shouldNotTrackImpression() throws Exception { View mockHtmlBannerWebView = mock(HtmlBannerWebView.class); subject.onBannerLoaded(mockHtmlBannerWebView); verify(moPubView).nativeAdLoaded(); verify(moPubView).setAdContentView(eq(mockHtmlBannerWebView)); verify(moPubView, never()).trackNativeImpression(); }