@Test public void loadAd_shouldScheduleTimeoutRunnableBeforeCallingLoadBanner() throws Exception { Robolectric.pauseMainLooper(); assertThat(Robolectric.getUiThreadScheduler().enqueuedTaskCount()).isEqualTo(0); Answer assertTimeoutRunnableHasStarted = new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { assertThat(Robolectric.getUiThreadScheduler().enqueuedTaskCount()).isEqualTo(1); return null; } }; doAnswer(assertTimeoutRunnableHasStarted) .when(banner) .loadBanner( any(Context.class), any(CustomEventBannerListener.class), any(Map.class), any(Map.class) ); subject.loadAd(); }
void loadAd() { if (isInvalidated() || mCustomEventBanner == null) { return; } if (getTimeoutDelayMilliseconds() > 0) { mHandler.postDelayed(mTimeout, getTimeoutDelayMilliseconds()); } mCustomEventBanner.loadBanner(mContext, this, mLocalExtras, mServerExtras); }
CustomEventBannerAdapter implements CustomEventBannerListener { void loadAd() { if (isInvalidated() || mCustomEventBanner == null) { return; } if (getTimeoutDelayMilliseconds() > 0) { mHandler.postDelayed(mTimeout, getTimeoutDelayMilliseconds()); } mCustomEventBanner.loadBanner(mContext, this, mLocalExtras, mServerExtras); } }
CustomEventBannerAdapter implements CustomEventBannerListener { void loadAd() { if (isInvalidated() || mCustomEventBanner == null) { return; } if (getTimeoutDelayMilliseconds() > 0) { mHandler.postDelayed(mTimeout, getTimeoutDelayMilliseconds()); } mCustomEventBanner.loadBanner(mContext, this, mLocalExtras, mServerExtras); } CustomEventBannerAdapter(@NonNull MoPubView moPubView,
            @NonNull String className,
            @NonNull Map<String, String> serverExtras,
            long broadcastIdentifier,
            @Nullable AdReport adReport); }
CustomEventBannerAdapter implements CustomEventBannerListener { void loadAd() { if (isInvalidated() || mCustomEventBanner == null) { return; } if (getTimeoutDelayMilliseconds() > 0) { mHandler.postDelayed(mTimeout, getTimeoutDelayMilliseconds()); } mCustomEventBanner.loadBanner(mContext, this, mLocalExtras, mServerExtras); } CustomEventBannerAdapter(@NonNull MoPubView moPubView,
            @NonNull String className,
            @NonNull Map<String, String> serverExtras,
            long broadcastIdentifier,
            @Nullable AdReport adReport); @Override void onBannerLoaded(View bannerView); @Override void onBannerFailed(MoPubErrorCode errorCode); @Override void onBannerExpanded(); @Override void onBannerCollapsed(); @Override void onBannerClicked(); @Override void onLeaveApplication(); }
CustomEventBannerAdapter implements CustomEventBannerListener { void loadAd() { if (isInvalidated() || mCustomEventBanner == null) { return; } if (getTimeoutDelayMilliseconds() > 0) { mHandler.postDelayed(mTimeout, getTimeoutDelayMilliseconds()); } mCustomEventBanner.loadBanner(mContext, this, mLocalExtras, mServerExtras); } CustomEventBannerAdapter(@NonNull MoPubView moPubView,
            @NonNull String className,
            @NonNull Map<String, String> serverExtras,
            long broadcastIdentifier,
            @Nullable AdReport adReport); @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; }