コード例 #1
0
  private void loadCustomEvent() {
    MoPubInterstitial.MoPubInterstitialView moPubInterstitialView =
        subject.new MoPubInterstitialView(activity);

    serverExtras.put(CUSTOM_EVENT_DATA.getKey(), "data");
    moPubInterstitialView.loadCustomEvent("name", serverExtras);
  }
コード例 #2
0
  @Test
  public void adFailed_shouldNotifyInterstitialAdListener() throws Exception {
    MoPubInterstitial.MoPubInterstitialView moPubInterstitialView =
        subject.new MoPubInterstitialView(activity);
    moPubInterstitialView.adFailed(CANCELLED);

    verify(interstitialAdListener).onInterstitialFailed(eq(subject), eq(CANCELLED));
  }
コード例 #3
0
  @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();
  }
コード例 #4
0
  @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");
  }
コード例 #5
0
  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();
    }
  }
コード例 #6
0
  @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();
  }