Skip to content

Commit ec4b353

Browse files
authored
Migrate from Robolectric.flushForegroundThreadScheduler to ShadowLooper.runToEndOfTasks (#6918)
Robolectric.flushForegroundThreadScheduler is going to be removed in a forthcoming Robolectric release. The Robolectric Scheduler APIs are designed for LEGACY Looper mode which has been deprecated for years.
1 parent 9f5839f commit ec4b353

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

firebase-inappmessaging/src/test/java/com/google/firebase/inappmessaging/internal/ForegroundNotifierTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
import static com.google.common.truth.Truth.assertThat;
1818
import static com.google.firebase.inappmessaging.internal.InAppMessageStreamManager.ON_FOREGROUND;
19+
import static org.robolectric.Shadows.shadowOf;
1920

21+
import android.os.Looper;
2022
import io.reactivex.flowables.ConnectableFlowable;
2123
import io.reactivex.subscribers.TestSubscriber;
2224
import org.junit.Before;
2325
import org.junit.Test;
2426
import org.junit.runner.RunWith;
25-
import org.robolectric.Robolectric;
2627
import org.robolectric.RobolectricTestRunner;
2728
import org.robolectric.annotation.Config;
2829

@@ -61,7 +62,7 @@ public void notifier_onActivityResumedAfterRunnableExecution_notifiesListener()
6162
foregroundNotifier.onActivityResumed(null); // 1
6263
assertThat(subscriber.getEvents().get(0)).hasSize(1);
6364
foregroundNotifier.onActivityPaused(null);
64-
Robolectric.flushForegroundThreadScheduler();
65+
shadowOf(Looper.getMainLooper()).runToEndOfTasks();
6566
foregroundNotifier.onActivityResumed(null); // 2
6667
assertThat(subscriber.getEvents().get(0)).hasSize(2);
6768
}

0 commit comments

Comments
 (0)