diff --git a/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/ForegroundNotifierTest.java b/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/ForegroundNotifierTest.java index 2cedc0b7953..af01be33fb6 100644 --- a/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/ForegroundNotifierTest.java +++ b/firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/ForegroundNotifierTest.java @@ -16,13 +16,14 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.firebase.inappmessaging.internal.InAppMessageStreamManager.ON_FOREGROUND; +import static org.robolectric.Shadows.shadowOf; +import android.os.Looper; import io.reactivex.flowables.ConnectableFlowable; import io.reactivex.subscribers.TestSubscriber; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; @@ -61,7 +62,7 @@ public void notifier_onActivityResumedAfterRunnableExecution_notifiesListener() foregroundNotifier.onActivityResumed(null); // 1 assertThat(subscriber.getEvents().get(0)).hasSize(1); foregroundNotifier.onActivityPaused(null); - Robolectric.flushForegroundThreadScheduler(); + shadowOf(Looper.getMainLooper()).runToEndOfTasks(); foregroundNotifier.onActivityResumed(null); // 2 assertThat(subscriber.getEvents().get(0)).hasSize(2); }