diff options
| author | 2022-11-01 21:23:53 +0000 | |
|---|---|---|
| committer | 2022-11-01 21:23:53 +0000 | |
| commit | 02e98cc540c827bd97fea8a3d6bf1fcc1a12e801 (patch) | |
| tree | acde7f8ddf8aa474039f8254b2b61c20846d800c | |
| parent | 40cf3c80234f63af7ffa508fd55ca967d7412918 (diff) | |
| parent | 1e18a3f6403262794d483ef35878f032f464365c (diff) | |
Merge "Update usage of deprecated coroutines methods" into tm-qpr-dev am: 1e18a3f640
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20223091
Change-Id: I029895b4e9ff24c667521c522ed75977391fa136
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
3 files changed, 22 insertions, 2 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/broadcast/BroadcastDispatcherTest.kt b/packages/SystemUI/tests/src/com/android/systemui/broadcast/BroadcastDispatcherTest.kt index 25bc91f413de..eb6e5174d078 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/broadcast/BroadcastDispatcherTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/broadcast/BroadcastDispatcherTest.kt @@ -40,6 +40,7 @@ import java.util.concurrent.Executor import junit.framework.Assert.assertSame import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch +import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runBlockingTest import org.junit.Before import org.junit.Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt index 760bb9bec559..081a2181cfe5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt @@ -47,7 +47,11 @@ import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.launch -import kotlinx.coroutines.test.runBlockingTest +import kotlinx.coroutines.test.TestCoroutineScheduler +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -59,6 +63,7 @@ import org.mockito.Mockito.`when` as whenever @RunWithLooper class FooterActionsViewModelTest : SysuiTestCase() { private lateinit var utils: FooterActionsTestUtils + private val testDispatcher = UnconfinedTestDispatcher(TestCoroutineScheduler()) @Before fun setUp() { @@ -130,6 +135,7 @@ class FooterActionsViewModelTest : SysuiTestCase() { showPowerButton = false, footerActionsInteractor = utils.footerActionsInteractor( + bgDispatcher = testDispatcher, userSwitcherRepository = utils.userSwitcherRepository( userTracker = userTracker, @@ -137,6 +143,7 @@ class FooterActionsViewModelTest : SysuiTestCase() { userManager = userManager, userInfoController = userInfoController, userSwitcherController = userSwitcherControllerWrapper.controller, + bgDispatcher = testDispatcher, ), ) ) @@ -217,9 +224,11 @@ class FooterActionsViewModelTest : SysuiTestCase() { footerActionsInteractor = utils.footerActionsInteractor( qsSecurityFooterUtils = qsSecurityFooterUtils, + bgDispatcher = testDispatcher, securityRepository = utils.securityRepository( securityController = securityController, + bgDispatcher = testDispatcher, ), ), ) @@ -288,9 +297,14 @@ class FooterActionsViewModelTest : SysuiTestCase() { footerActionsInteractor = utils.footerActionsInteractor( qsSecurityFooterUtils = qsSecurityFooterUtils, - securityRepository = utils.securityRepository(securityController), + securityRepository = + utils.securityRepository( + securityController, + bgDispatcher = testDispatcher, + ), foregroundServicesRepository = utils.foregroundServicesRepository(fgsManagerController), + bgDispatcher = testDispatcher, ), ) @@ -376,6 +390,7 @@ class FooterActionsViewModelTest : SysuiTestCase() { utils.footerActionsInteractor( qsSecurityFooterUtils = qsSecurityFooterUtils, broadcastDispatcher = broadcastDispatcher, + bgDispatcher = testDispatcher, ), ) @@ -400,4 +415,7 @@ class FooterActionsViewModelTest : SysuiTestCase() { underTest.onVisibilityChangeRequested(visible = true) assertThat(underTest.isVisible.value).isTrue() } + + private fun runBlockingTest(block: suspend TestScope.() -> Unit) = + runTest(testDispatcher) { block() } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorRefactoredTest.kt b/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorRefactoredTest.kt index 97571b23be56..f682e31c0547 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorRefactoredTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorRefactoredTest.kt @@ -44,6 +44,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.advanceUntilIdle import org.junit.Before import org.junit.Test import org.junit.runner.RunWith |