private void loadCustomEvent() { MoPubInterstitial.MoPubInterstitialView moPubInterstitialView = subject.new MoPubInterstitialView(activity); serverExtras.put(CUSTOM_EVENT_DATA.getKey(), "data"); moPubInterstitialView.loadCustomEvent("name", serverExtras); }
@Test public void adFailed_shouldNotifyInterstitialAdListener() throws Exception { MoPubInterstitial.MoPubInterstitialView moPubInterstitialView = subject.new MoPubInterstitialView(activity); moPubInterstitialView.adFailed(CANCELLED); verify(interstitialAdListener).onInterstitialFailed(eq(subject), eq(CANCELLED)); }
@Test public void loadCustomEvent_whenParamsMapIsNull_shouldCallLoadFailUrl() throws Exception { MoPubInterstitial.MoPubInterstitialView moPubInterstitialView = subject.new MoPubInterstitialView(activity); moPubInterstitialView.loadCustomEvent(null, null); verify(adViewController).loadFailUrl(eq(ADAPTER_NOT_FOUND)); verify(customEventInterstitialAdapter, never()).invalidate(); verify(customEventInterstitialAdapter, never()).loadInterstitial(); }
@Test public void loadCustomEvent_shouldCreateAndLoadCustomEventInterstitialAdapter() throws Exception { MoPubInterstitial.MoPubInterstitialView moPubInterstitialView = subject.new MoPubInterstitialView(activity); moPubInterstitialView.loadCustomEvent(customEventClassName, serverExtras); assertThat(TestCustomEventInterstitialAdapterFactory.getLatestMoPubInterstitial()) .isSameAs(subject); assertThat(TestCustomEventInterstitialAdapterFactory.getLatestClassName()) .isEqualTo("class name"); assertThat(TestCustomEventInterstitialAdapterFactory.getLatestServerExtras().get("testExtra")) .isEqualTo("class data"); }
private void assertShowsCustomEventInterstitial(boolean shouldBeReady) { MoPubInterstitial.MoPubInterstitialView moPubInterstitialView = subject.new MoPubInterstitialView(activity); moPubInterstitialView.loadCustomEvent(customEventClassName, serverExtras); assertThat(subject.isReady()).isEqualTo(shouldBeReady); assertThat(subject.show()).isEqualTo(shouldBeReady); if (shouldBeReady) { verify(customEventInterstitialAdapter).showInterstitial(); } else { verify(customEventInterstitialAdapter, never()).showInterstitial(); } }
@Test public void loadCustomEvent_shouldInitializeCustomEventInterstitialAdapter() throws Exception { MoPubInterstitial.MoPubInterstitialView moPubInterstitialView = subject.new MoPubInterstitialView(activity); serverExtras.put("testExtra", "data"); moPubInterstitialView.loadCustomEvent("name", serverExtras); assertThat(TestCustomEventInterstitialAdapterFactory.getLatestMoPubInterstitial()) .isEqualTo(subject); assertThat(TestCustomEventInterstitialAdapterFactory.getLatestClassName()).isEqualTo("name"); assertThat(TestCustomEventInterstitialAdapterFactory.getLatestServerExtras().get("testExtra")) .isEqualTo("data"); verify(customEventInterstitialAdapter).setAdapterListener(eq(subject)); verify(customEventInterstitialAdapter).loadInterstitial(); }