commit 90871b0071ba0beb8acf9cacf5260b50b7834536
parent 210c997d4d847f064c6b17509a37c2d2a7023609
Author: mcarare <48995920+mcarare@users.noreply.github.com>
Date: Thu, 8 Jan 2026 10:39:34 +0000
Bug 2008004 - Replace MainCoroutineRule with StandardTestDispatcher in ProfilerServiceTest. r=android-reviewers,giorga
Differential Revision: https://phabricator.services.mozilla.com/D278248
Diffstat:
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/perf/ProfilerServiceTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/perf/ProfilerServiceTest.kt
@@ -22,7 +22,6 @@ import kotlinx.coroutines.test.runTest
import mozilla.components.browser.engine.gecko.profiler.Profiler
import mozilla.components.concept.engine.Engine
import mozilla.components.support.base.android.NotificationsDelegate
-import mozilla.components.support.test.rule.MainCoroutineRule
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@@ -31,7 +30,6 @@ import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
-import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.components.Core
@@ -49,9 +47,7 @@ import org.robolectric.shadows.ShadowService
@Config(application = FenixRobolectricTestApplication::class, sdk = [Build.VERSION_CODES.TIRAMISU])
class ProfilerServiceTest {
- @get:Rule
- val coroutineRule = MainCoroutineRule(StandardTestDispatcher())
-
+ private val testDispatcher = StandardTestDispatcher()
private lateinit var context: Context
private lateinit var notificationManager: NotificationManager
private lateinit var shadowNotificationManager: ShadowNotificationManager
@@ -160,7 +156,7 @@ class ProfilerServiceTest {
}
@Test
- fun `GIVEN profiler service is running WHEN receiving inactive broadcast THEN the service stops`() = runTest(coroutineRule.testDispatcher) {
+ fun `GIVEN profiler service is running WHEN receiving inactive broadcast THEN the service stops`() = runTest(testDispatcher) {
serviceController = Robolectric.buildService(ProfilerService::class.java)
serviceController.create()
service = serviceController.get()