@Test public void loadInterstitial_shouldScheduleTimeoutRunnableBeforeCallingLoadInterstitial() 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(interstitial) .loadInterstitial( any(Context.class), any(CustomEventInterstitialListener.class), any(Map.class), any(Map.class) ); subject.loadInterstitial(); }
void loadInterstitial() { if (isInvalidated() || mCustomEventInterstitial == null) { return; } if (getTimeoutDelayMilliseconds() > 0) { mHandler.postDelayed(mTimeout, getTimeoutDelayMilliseconds()); } mCustomEventInterstitial.loadInterstitial(mContext, this, mLocalExtras, mServerExtras); }
CustomEventInterstitialAdapter implements CustomEventInterstitialListener { void loadInterstitial() { if (isInvalidated() || mCustomEventInterstitial == null) { return; } if (getTimeoutDelayMilliseconds() > 0) { mHandler.postDelayed(mTimeout, getTimeoutDelayMilliseconds()); } mCustomEventInterstitial.loadInterstitial(mContext, this, mLocalExtras, mServerExtras); } }
CustomEventInterstitialAdapter implements CustomEventInterstitialListener { void loadInterstitial() { if (isInvalidated() || mCustomEventInterstitial == null) { return; } if (getTimeoutDelayMilliseconds() > 0) { mHandler.postDelayed(mTimeout, getTimeoutDelayMilliseconds()); } mCustomEventInterstitial.loadInterstitial(mContext, this, mLocalExtras, mServerExtras); } CustomEventInterstitialAdapter(@NonNull final MoPubInterstitial moPubInterstitial,
            @NonNull final String className,
            @NonNull final Map<String, String> serverExtras,
            long broadcastIdentifier,
            @Nullable AdReport adReport); }
CustomEventInterstitialAdapter implements CustomEventInterstitialListener { void loadInterstitial() { if (isInvalidated() || mCustomEventInterstitial == null) { return; } if (getTimeoutDelayMilliseconds() > 0) { mHandler.postDelayed(mTimeout, getTimeoutDelayMilliseconds()); } mCustomEventInterstitial.loadInterstitial(mContext, this, mLocalExtras, mServerExtras); } CustomEventInterstitialAdapter(@NonNull final MoPubInterstitial moPubInterstitial,
            @NonNull final String className,
            @NonNull final Map<String, String> serverExtras,
            long broadcastIdentifier,
            @Nullable AdReport adReport); @Override void onInterstitialLoaded(); @Override void onInterstitialFailed(MoPubErrorCode errorCode); @Override void onInterstitialShown(); @Override void onInterstitialClicked(); @Override void onLeaveApplication(); @Override void onInterstitialDismissed(); }
CustomEventInterstitialAdapter implements CustomEventInterstitialListener { void loadInterstitial() { if (isInvalidated() || mCustomEventInterstitial == null) { return; } if (getTimeoutDelayMilliseconds() > 0) { mHandler.postDelayed(mTimeout, getTimeoutDelayMilliseconds()); } mCustomEventInterstitial.loadInterstitial(mContext, this, mLocalExtras, mServerExtras); } CustomEventInterstitialAdapter(@NonNull final MoPubInterstitial moPubInterstitial,
            @NonNull final String className,
            @NonNull final Map<String, String> serverExtras,
            long broadcastIdentifier,
            @Nullable AdReport adReport); @Override void onInterstitialLoaded(); @Override void onInterstitialFailed(MoPubErrorCode errorCode); @Override void onInterstitialShown(); @Override void onInterstitialClicked(); @Override void onLeaveApplication(); @Override void onInterstitialDismissed(); static final int DEFAULT_INTERSTITIAL_TIMEOUT_DELAY; }