Merge "Update usage of deprecated coroutines methods" into stage-aosp-master
This commit is contained in:
@@ -40,6 +40,7 @@ import java.util.concurrent.Executor
|
|||||||
import junit.framework.Assert.assertSame
|
import junit.framework.Assert.assertSame
|
||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.test.advanceUntilIdle
|
||||||
import kotlinx.coroutines.test.runBlockingTest
|
import kotlinx.coroutines.test.runBlockingTest
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|||||||
@@ -47,7 +47,11 @@ import com.google.common.truth.Truth.assertThat
|
|||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
import kotlinx.coroutines.flow.flowOf
|
import kotlinx.coroutines.flow.flowOf
|
||||||
import kotlinx.coroutines.launch
|
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.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
@@ -59,6 +63,7 @@ import org.mockito.Mockito.`when` as whenever
|
|||||||
@RunWithLooper
|
@RunWithLooper
|
||||||
class FooterActionsViewModelTest : SysuiTestCase() {
|
class FooterActionsViewModelTest : SysuiTestCase() {
|
||||||
private lateinit var utils: FooterActionsTestUtils
|
private lateinit var utils: FooterActionsTestUtils
|
||||||
|
private val testDispatcher = UnconfinedTestDispatcher(TestCoroutineScheduler())
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
@@ -130,6 +135,7 @@ class FooterActionsViewModelTest : SysuiTestCase() {
|
|||||||
showPowerButton = false,
|
showPowerButton = false,
|
||||||
footerActionsInteractor =
|
footerActionsInteractor =
|
||||||
utils.footerActionsInteractor(
|
utils.footerActionsInteractor(
|
||||||
|
bgDispatcher = testDispatcher,
|
||||||
userSwitcherRepository =
|
userSwitcherRepository =
|
||||||
utils.userSwitcherRepository(
|
utils.userSwitcherRepository(
|
||||||
userTracker = userTracker,
|
userTracker = userTracker,
|
||||||
@@ -137,6 +143,7 @@ class FooterActionsViewModelTest : SysuiTestCase() {
|
|||||||
userManager = userManager,
|
userManager = userManager,
|
||||||
userInfoController = userInfoController,
|
userInfoController = userInfoController,
|
||||||
userSwitcherController = userSwitcherControllerWrapper.controller,
|
userSwitcherController = userSwitcherControllerWrapper.controller,
|
||||||
|
bgDispatcher = testDispatcher,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -227,9 +234,11 @@ class FooterActionsViewModelTest : SysuiTestCase() {
|
|||||||
footerActionsInteractor =
|
footerActionsInteractor =
|
||||||
utils.footerActionsInteractor(
|
utils.footerActionsInteractor(
|
||||||
qsSecurityFooterUtils = qsSecurityFooterUtils,
|
qsSecurityFooterUtils = qsSecurityFooterUtils,
|
||||||
|
bgDispatcher = testDispatcher,
|
||||||
securityRepository =
|
securityRepository =
|
||||||
utils.securityRepository(
|
utils.securityRepository(
|
||||||
securityController = securityController,
|
securityController = securityController,
|
||||||
|
bgDispatcher = testDispatcher,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -298,9 +307,14 @@ class FooterActionsViewModelTest : SysuiTestCase() {
|
|||||||
footerActionsInteractor =
|
footerActionsInteractor =
|
||||||
utils.footerActionsInteractor(
|
utils.footerActionsInteractor(
|
||||||
qsSecurityFooterUtils = qsSecurityFooterUtils,
|
qsSecurityFooterUtils = qsSecurityFooterUtils,
|
||||||
securityRepository = utils.securityRepository(securityController),
|
securityRepository =
|
||||||
|
utils.securityRepository(
|
||||||
|
securityController,
|
||||||
|
bgDispatcher = testDispatcher,
|
||||||
|
),
|
||||||
foregroundServicesRepository =
|
foregroundServicesRepository =
|
||||||
utils.foregroundServicesRepository(fgsManagerController),
|
utils.foregroundServicesRepository(fgsManagerController),
|
||||||
|
bgDispatcher = testDispatcher,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -386,6 +400,7 @@ class FooterActionsViewModelTest : SysuiTestCase() {
|
|||||||
utils.footerActionsInteractor(
|
utils.footerActionsInteractor(
|
||||||
qsSecurityFooterUtils = qsSecurityFooterUtils,
|
qsSecurityFooterUtils = qsSecurityFooterUtils,
|
||||||
broadcastDispatcher = broadcastDispatcher,
|
broadcastDispatcher = broadcastDispatcher,
|
||||||
|
bgDispatcher = testDispatcher,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -410,4 +425,7 @@ class FooterActionsViewModelTest : SysuiTestCase() {
|
|||||||
underTest.onVisibilityChangeRequested(visible = true)
|
underTest.onVisibilityChangeRequested(visible = true)
|
||||||
assertThat(underTest.isVisible.value).isTrue()
|
assertThat(underTest.isVisible.value).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun runBlockingTest(block: suspend TestScope.() -> Unit) =
|
||||||
|
runTest(testDispatcher) { block() }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user