|
18 | 18 | import static org.junit.Assert.assertNotNull;
|
19 | 19 | import static org.junit.Assert.assertTrue;
|
20 | 20 | import static org.junit.Assert.fail;
|
| 21 | +import static org.robolectric.Shadows.shadowOf; |
21 | 22 |
|
22 | 23 | import android.net.Uri;
|
23 | 24 | import android.os.Build;
|
| 25 | +import android.os.Looper; |
24 | 26 | import com.google.android.gms.tasks.Task;
|
25 | 27 | import com.google.firebase.FirebaseApp;
|
26 | 28 | import com.google.firebase.storage.TestDownloadHelper.StreamDownloadResponse;
|
|
40 | 42 | import org.junit.Test;
|
41 | 43 | import org.junit.rules.TemporaryFolder;
|
42 | 44 | import org.junit.runner.RunWith;
|
43 |
| -import org.robolectric.Robolectric; |
44 | 45 | import org.robolectric.RobolectricTestRunner;
|
45 | 46 | import org.robolectric.annotation.Config;
|
46 | 47 |
|
47 | 48 | /** Tests for {@link FirebaseStorage}. */
|
48 | 49 | @SuppressWarnings("ConstantConditions")
|
49 | 50 | @RunWith(RobolectricTestRunner.class)
|
50 |
| -@Config(sdk = Build.VERSION_CODES.LOLLIPOP_MR1) |
| 51 | +@Config(sdk = Build.VERSION_CODES.M) |
51 | 52 | public class DownloadTest {
|
52 | 53 |
|
53 | 54 | @Rule public RetryRule retryRule = new RetryRule(3);
|
@@ -137,7 +138,7 @@ public void streamDownloadStateVerification() throws Exception {
|
137 | 138 | ControllableSchedulerHelper.getInstance().resume();
|
138 | 139 |
|
139 | 140 | for (int i = 0; i < 3000; i++) {
|
140 |
| - Robolectric.flushForegroundThreadScheduler(); |
| 141 | + shadowOf(Looper.getMainLooper()).runToEndOfTasks(); |
141 | 142 | if (semaphore.tryAcquire(2, 1, TimeUnit.MILLISECONDS)) {
|
142 | 143 | Assert.assertEquals(bytesDownloaded.get(), bytesTransferred.get());
|
143 | 144 | return;
|
@@ -256,7 +257,7 @@ public void byteDownload() throws Exception {
|
256 | 257 | TestDownloadHelper.byteDownload(
|
257 | 258 | new StringBuilder(), bitmap -> assertEquals(1076408, bitmap.length));
|
258 | 259 | for (int i = 0; i < 3000; i++) {
|
259 |
| - Robolectric.flushForegroundThreadScheduler(); |
| 260 | + shadowOf(Looper.getMainLooper()).runToEndOfTasks(); |
260 | 261 | if (semaphore.tryAcquire(1, 1, TimeUnit.MILLISECONDS)) {
|
261 | 262 | // success!
|
262 | 263 | factory.verifyOldMock();
|
|
0 commit comments