tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 2bdceec98eae4d5c11c4f376590bfd3b9541da44
parent 8b1c49542ae15990283f8d8ceebb32c5cb8bb7d5
Author: Jonathan Almeida <jonalmeida942@gmail.com>
Date:   Wed,  1 Oct 2025 23:14:23 +0000

Bug 1982155 - Don't use IO dispatcher in Downloads tests r=tthibaud,mcarare,android-reviewers

Other dispatchers are not synchronised to finish their work during the
test run which cause the intermittent failure.

We could either use `CoroutineScope(testsDispatchers)` or
`backgroundScope` from the `TestScope` which gives us nicer test failure
handling with the built-in `ReportingSupervisorJob`.

Differential Revision: https://phabricator.services.mozilla.com/D266696

Diffstat:
Mmobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/AbstractFetchDownloadServiceTest.kt | 15+++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/AbstractFetchDownloadServiceTest.kt b/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/AbstractFetchDownloadServiceTest.kt @@ -20,7 +20,6 @@ import androidx.core.content.getSystemService import androidx.core.net.toUri import androidx.test.ext.junit.runners.AndroidJUnit4 import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -1437,7 +1436,7 @@ class AbstractFetchDownloadServiceTest { state = download, foregroundServiceId = Random.nextInt(), status = DOWNLOADING, - job = CoroutineScope(IO).launch { + job = backgroundScope.launch { @Suppress("ControlFlowWithEmptyBody") while (true) { } }, @@ -1484,7 +1483,7 @@ class AbstractFetchDownloadServiceTest { state = inProgressDownload, foregroundServiceId = Random.nextInt(), status = DOWNLOADING, - job = CoroutineScope(IO).launch { + job = backgroundScope.launch { @Suppress("ControlFlowWithEmptyBody") while (true) { } }, @@ -1500,7 +1499,7 @@ class AbstractFetchDownloadServiceTest { state = pausedDownload, foregroundServiceId = Random.nextInt(), status = PAUSED, - job = CoroutineScope(IO).launch { + job = backgroundScope.launch { @Suppress("ControlFlowWithEmptyBody") while (true) { } }, @@ -1515,7 +1514,7 @@ class AbstractFetchDownloadServiceTest { state = initiatedDownload, foregroundServiceId = Random.nextInt(), status = INITIATED, - job = CoroutineScope(IO).launch { + job = backgroundScope.launch { @Suppress("ControlFlowWithEmptyBody") while (true) { } }, @@ -1530,7 +1529,7 @@ class AbstractFetchDownloadServiceTest { state = failedDownload, foregroundServiceId = Random.nextInt(), status = FAILED, - job = CoroutineScope(IO).launch { + job = backgroundScope.launch { @Suppress("ControlFlowWithEmptyBody") while (true) { } }, @@ -1565,7 +1564,7 @@ class AbstractFetchDownloadServiceTest { state = completedDownload, foregroundServiceId = Random.nextInt(), status = COMPLETED, - job = CoroutineScope(IO).launch { + job = backgroundScope.launch { @Suppress("ControlFlowWithEmptyBody") while (true) { } }, @@ -1581,7 +1580,7 @@ class AbstractFetchDownloadServiceTest { state = cancelledDownload, foregroundServiceId = Random.nextInt(), status = CANCELLED, - job = CoroutineScope(IO).launch { + job = backgroundScope.launch { @Suppress("ControlFlowWithEmptyBody") while (true) { } },