Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion firebase-storage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Unreleased
* [fixed] Fixed an issue where tests were depending on a deprecated feature of the test framework (#6927)

# 21.0.1
* [fixed] Fixed an issue where `maxUploadRetryTimeMillis` parameter is ignored when uploading using
Expand Down Expand Up @@ -208,4 +209,3 @@ updates.
`UploadTask.TaskSnapshot.getDownloadUrl()` methods. To get a current download
URL, use
[`StorageReference.getDownloadUr()`](/docs/reference/android/com/google/firebase/storage/StorageReference.html#getDownloadUrl()).

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.robolectric.Shadows.shadowOf;

import android.net.Uri;
import android.os.Build;
import android.os.Looper;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp;
import com.google.firebase.storage.TestDownloadHelper.StreamDownloadResponse;
Expand All @@ -40,14 +42,13 @@
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

/** Tests for {@link FirebaseStorage}. */
@SuppressWarnings("ConstantConditions")
@RunWith(RobolectricTestRunner.class)
@Config(sdk = Build.VERSION_CODES.LOLLIPOP_MR1)
@Config(sdk = Build.VERSION_CODES.M)
public class DownloadTest {

@Rule public RetryRule retryRule = new RetryRule(3);
Expand Down Expand Up @@ -137,7 +138,7 @@ public void streamDownloadStateVerification() throws Exception {
ControllableSchedulerHelper.getInstance().resume();

for (int i = 0; i < 3000; i++) {
Robolectric.flushForegroundThreadScheduler();
shadowOf(Looper.getMainLooper()).runToEndOfTasks();
if (semaphore.tryAcquire(2, 1, TimeUnit.MILLISECONDS)) {
Assert.assertEquals(bytesDownloaded.get(), bytesTransferred.get());
return;
Expand Down Expand Up @@ -256,7 +257,7 @@ public void byteDownload() throws Exception {
TestDownloadHelper.byteDownload(
new StringBuilder(), bitmap -> assertEquals(1076408, bitmap.length));
for (int i = 0; i < 3000; i++) {
Robolectric.flushForegroundThreadScheduler();
shadowOf(Looper.getMainLooper()).runToEndOfTasks();
if (semaphore.tryAcquire(1, 1, TimeUnit.MILLISECONDS)) {
// success!
factory.verifyOldMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

package com.google.firebase.storage;

import static org.robolectric.Shadows.shadowOf;

import android.os.Looper;
import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import com.google.android.gms.tasks.Task;
Expand All @@ -26,7 +29,6 @@
import java.io.StringReader;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.robolectric.Robolectric;

/** Test helpers. */
public class TestUtil {
Expand Down Expand Up @@ -138,7 +140,7 @@ static void await(Task<?> task, int timeout, TimeUnit timeUnit) throws Interrupt
long timeoutMillis = timeUnit.toMillis(timeout);

for (int i = 0; i < timeoutMillis; i++) {
Robolectric.flushForegroundThreadScheduler();
shadowOf(Looper.getMainLooper()).runToEndOfTasks();
if (task.isComplete()) {
// success!
return;
Expand Down
Loading