diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2023-09-06 13:26:03 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2023-09-06 13:26:03 +0200 |
| commit | 9786122e86daed287c6e9f9f233301e8d4524789 (patch) | |
| tree | 5d006aba49fc142576be13ef8398f604d6d782fe /android/lib | |
| parent | 02715c2eb2b011393f4c7ada34d8f70014eb0524 (diff) | |
| parent | 20fe581131a84660a4b1ed57159ad86240fa6dd8 (diff) | |
| download | mullvadvpn-9786122e86daed287c6e9f9f233301e8d4524789.tar.xz mullvadvpn-9786122e86daed287c6e9f9f233301e8d4524789.zip | |
Merge branch 'replace-testcoroutinedispatcher-droid-279'
Diffstat (limited to 'android/lib')
| -rw-r--r-- | android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt b/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt index 2488aab66e..d04983be26 100644 --- a/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt +++ b/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt @@ -1,23 +1,27 @@ package net.mullvad.mullvadvpn.lib.common.test import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.test.TestCoroutineDispatcher +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.TestDispatcher +import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import org.junit.rules.TestWatcher import org.junit.runner.Description -class TestCoroutineRule(val testDispatcher: TestCoroutineDispatcher = TestCoroutineDispatcher()) : +@OptIn(ExperimentalCoroutinesApi::class) +class TestCoroutineRule(val testDispatcher: TestDispatcher = UnconfinedTestDispatcher()) : TestWatcher() { - override fun starting(description: Description?) { + override fun starting(description: Description) { super.starting(description) Dispatchers.setMain(testDispatcher) } - override fun finished(description: Description?) { + override fun finished(description: Description) { super.finished(description) Dispatchers.resetMain() - testDispatcher.cleanupTestCoroutines() + // Replacement for cleanupTestCoroutines() + testDispatcher.scheduler.runCurrent() } } |
