tor-browser

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

commit d1c0d07f49513b52e23584e10bad0c45ed15e42a
parent 76cf7054a37f049031a30b0e78c2315f1c26cd64
Author: mcarare <48995920+mcarare@users.noreply.github.com>
Date:   Wed, 15 Oct 2025 16:15:42 +0000

Bug 1993721 - Remove MainCoroutineRule from ViewTest. r=android-reviewers,giorga

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

Diffstat:
Mmobile/android/android-components/components/support/ktx/src/test/java/mozilla/components/support/ktx/android/view/ViewTest.kt | 12+++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/mobile/android/android-components/components/support/ktx/src/test/java/mozilla/components/support/ktx/android/view/ViewTest.kt b/mobile/android/android-components/components/support/ktx/src/test/java/mozilla/components/support/ktx/android/view/ViewTest.kt @@ -17,16 +17,15 @@ import android.widget.TextView import androidx.test.ext.junit.runners.AndroidJUnit4 import kotlinx.coroutines.isActive import kotlinx.coroutines.launch +import kotlinx.coroutines.test.runTest import mozilla.components.support.base.android.Padding import mozilla.components.support.test.any import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext -import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNotNull import org.junit.Assert.assertTrue -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.doAnswer @@ -44,9 +43,6 @@ import java.util.concurrent.TimeUnit @RunWith(AndroidJUnit4::class) class ViewTest { - @get:Rule - val coroutinesTestRule = MainCoroutineRule() - @Test fun `showKeyboard should request focus`() { val view = EditText(testContext) @@ -141,7 +137,7 @@ class ViewTest { } @Test - fun `can dispatch coroutines to view scope`() { + fun `can dispatch coroutines to view scope`() = runTest { val activity = Robolectric.buildActivity(Activity::class.java).create().get() val view = View(testContext) activity.windowManager.addView(view, WindowManager.LayoutParams(100, 100)) @@ -149,15 +145,13 @@ class ViewTest { assertTrue(view.isAttachedToWindow) - val latch = CountDownLatch(1) var coroutineExecuted = false view.toScope().launch { coroutineExecuted = true - latch.countDown() } - latch.await(10, TimeUnit.SECONDS) + shadowOf(getMainLooper()).idle() assertTrue(coroutineExecuted) }