@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();
  }
  @Test
  public void invalidate_shouldCauseBannerListenerMethodsToDoNothing() throws Exception {
    subject.invalidate();

    subject.onBannerLoaded(null);
    subject.onBannerFailed(null);
    subject.onBannerExpanded();
    subject.onBannerCollapsed();
    subject.onBannerClicked();
    subject.onLeaveApplication();

    verify(moPubView, never()).nativeAdLoaded();
    verify(moPubView, never()).setAdContentView(any(View.class));
    verify(moPubView, never()).trackNativeImpression();
    verify(moPubView, never()).loadFailUrl(any(MoPubErrorCode.class));
    verify(moPubView, never()).setAutorefreshEnabled(any(boolean.class));
    verify(moPubView, never()).adClosed();
    verify(moPubView, never()).registerClick();
  }
  @Test
  public void loadAd_shouldScheduleTimeout_bannerLoadedAndFailed_shouldCancelTimeout()
      throws Exception {
    Robolectric.pauseMainLooper();

    assertThat(Robolectric.getUiThreadScheduler().enqueuedTaskCount()).isEqualTo(0);

    subject.loadAd();
    assertThat(Robolectric.getUiThreadScheduler().enqueuedTaskCount()).isEqualTo(1);

    subject.onBannerLoaded(null);
    assertThat(Robolectric.getUiThreadScheduler().enqueuedTaskCount()).isEqualTo(0);

    subject.loadAd();
    assertThat(Robolectric.getUiThreadScheduler().enqueuedTaskCount()).isEqualTo(1);

    subject.onBannerFailed(null);
    assertThat(Robolectric.getUiThreadScheduler().enqueuedTaskCount()).isEqualTo(0);
  }