DownloadManagerTest: Address remaining flakiness
#minor-release PiperOrigin-RevId: 351158541
This commit is contained in:
parent
09c49f3ca8
commit
01b9ae6325
@ -25,7 +25,6 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.offline.DownloadManager.Listener;
|
|
||||||
import com.google.android.exoplayer2.robolectric.TestDownloadManagerListener;
|
import com.google.android.exoplayer2.robolectric.TestDownloadManagerListener;
|
||||||
import com.google.android.exoplayer2.scheduler.Requirements;
|
import com.google.android.exoplayer2.scheduler.Requirements;
|
||||||
import com.google.android.exoplayer2.testutil.DownloadBuilder;
|
import com.google.android.exoplayer2.testutil.DownloadBuilder;
|
||||||
@ -600,6 +599,7 @@ public class DownloadManagerTest {
|
|||||||
|
|
||||||
FakeDownloader downloader = getDownloaderAt(1);
|
FakeDownloader downloader = getDownloaderAt(1);
|
||||||
downloader.finish();
|
downloader.finish();
|
||||||
|
assertCompleted(ID1);
|
||||||
|
|
||||||
assertDownloadIndexSize(1);
|
assertDownloadIndexSize(1);
|
||||||
// We expect one downloader for the removal, and one for when the download was re-added.
|
// We expect one downloader for the removal, and one for when the download was re-added.
|
||||||
@ -617,28 +617,18 @@ public class DownloadManagerTest {
|
|||||||
public void addDownloadWithStopReason_whilstRemoving_addsStoppedDownload() throws Throwable {
|
public void addDownloadWithStopReason_whilstRemoving_addsStoppedDownload() throws Throwable {
|
||||||
postDownloadRequest(ID1);
|
postDownloadRequest(ID1);
|
||||||
getDownloaderAt(0).finish();
|
getDownloaderAt(0).finish();
|
||||||
|
assertCompleted(ID1);
|
||||||
|
|
||||||
postRemoveRequest(ID1);
|
postRemoveRequest(ID1);
|
||||||
FakeDownloader downloadRemover = getDownloaderAt(1);
|
FakeDownloader downloadRemover = getDownloaderAt(1);
|
||||||
downloadRemover.assertRemoveStarted();
|
downloadRemover.assertRemoveStarted();
|
||||||
|
|
||||||
// Re-add the download with a stop reason.
|
// Re-add the download with a stop reason.
|
||||||
ConditionVariable downloadManagerIdleCondition = new ConditionVariable();
|
|
||||||
runOnMainThread(
|
runOnMainThread(
|
||||||
() -> {
|
() -> downloadManager.addDownload(createDownloadRequest(ID1), /* stopReason= */ 1234));
|
||||||
downloadManager.addListener(
|
|
||||||
new Listener() {
|
|
||||||
@Override
|
|
||||||
public void onIdle(DownloadManager downloadManager) {
|
|
||||||
downloadManagerIdleCondition.open();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
downloadManager.addDownload(createDownloadRequest(ID1), /* stopReason= */ 1234);
|
|
||||||
});
|
|
||||||
|
|
||||||
downloadRemover.finish();
|
downloadRemover.finish();
|
||||||
|
downloadManagerListener.blockUntilIdle();
|
||||||
assertThat(downloadManagerIdleCondition.block(TIMEOUT_MS)).isTrue();
|
|
||||||
|
|
||||||
assertDownloadIndexSize(1);
|
assertDownloadIndexSize(1);
|
||||||
// We expect one downloader for the initial download, and one for the removal. A downloader
|
// We expect one downloader for the initial download, and one for the removal. A downloader
|
||||||
|
Loading…
x
Reference in New Issue
Block a user