tor-browser

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

commit 5ce958ab6a3b371f66fb42045a6445bbca78f38c
parent f629f2a2ca3e25bce6abb2b42fae35998e46ef48
Author: mcarare <48995920+mcarare@users.noreply.github.com>
Date:   Thu,  8 Jan 2026 14:36:39 +0000

Bug 2009150 - Update PlacesHistoryStorageWorkerTest to use standard kotlinx-coroutines-test runTest. r=android-reviewers,giorga

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

Diffstat:
Mmobile/android/android-components/components/browser/storage-sync/src/test/java/mozilla/components/browser/storage/sync/PlacesHistoryStorageWorkerTest.kt | 15+++++----------
1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/mobile/android/android-components/components/browser/storage-sync/src/test/java/mozilla/components/browser/storage/sync/PlacesHistoryStorageWorkerTest.kt b/mobile/android/android-components/components/browser/storage-sync/src/test/java/mozilla/components/browser/storage/sync/PlacesHistoryStorageWorkerTest.kt @@ -8,13 +8,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.work.ListenableWorker.Result import androidx.work.testing.TestListenableWorkerBuilder import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.test.runTest import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext -import mozilla.components.support.test.rule.MainCoroutineRule -import mozilla.components.support.test.rule.runTestOnMain import org.junit.After import org.junit.Assert.assertEquals -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.verify @@ -24,9 +22,6 @@ import kotlin.reflect.KVisibility @RunWith(AndroidJUnit4::class) class PlacesHistoryStorageWorkerTest { - @get:Rule - val mainCoroutineRule = MainCoroutineRule() - @After fun tearDown() { GlobalPlacesDependencyProvider.placesStorage = null @@ -34,7 +29,7 @@ class PlacesHistoryStorageWorkerTest { @Test fun `PlacesHistoryStorage's runMaintenance is called when worker's startWork is called`() = - runTestOnMain { + runTest { val placesStorage = mock<PlacesStorage>() GlobalPlacesDependencyProvider.initialize(placesStorage) val worker = @@ -46,7 +41,7 @@ class PlacesHistoryStorageWorkerTest { @Test fun `PlacesHistoryStorage's runMaintenance operation is successful, successful result returned by the worker`() = - runTestOnMain { + runTest { val placesStorage = mock<PlacesStorage>() GlobalPlacesDependencyProvider.initialize(placesStorage) val worker = @@ -58,7 +53,7 @@ class PlacesHistoryStorageWorkerTest { @Test fun `PlacesHistoryStorage's runMaintenance is called, exception is thrown and failure result is returned`() = - runTestOnMain { + runTest { val placesStorage = mock<PlacesStorage>() `when`(placesStorage.runMaintenance(PlacesHistoryStorageWorker.DB_SIZE_LIMIT_IN_BYTES.toUInt())) .thenThrow(CancellationException()) @@ -72,7 +67,7 @@ class PlacesHistoryStorageWorkerTest { @Test fun `PlacesHistoryStorage's runMaintenance is called, exception is thrown and active write operations are cancelled`() = - runTestOnMain { + runTest { val placesStorage = mock<PlacesStorage>() `when`(placesStorage.runMaintenance(PlacesHistoryStorageWorker.DB_SIZE_LIMIT_IN_BYTES.toUInt())) .thenThrow(CancellationException())