Loading packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeBackActionInteractorImplTest.kt +30 −31 Original line number Diff line number Diff line Loading @@ -24,23 +24,23 @@ import com.android.compose.animation.scene.SceneKey import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.keyguard.data.repository.deviceEntryFingerprintAuthRepository import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticationStatus import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.backgroundScope import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.domain.resolver.homeSceneFamilyResolver import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shared.recents.utilities.Utilities import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Assume import org.junit.Assume.assumeFalse import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -49,82 +49,81 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @EnableSceneContainer class ShadeBackActionInteractorImplTest : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val sceneInteractor by lazy { kosmos.sceneInteractor } val shadeInteractor by lazy { kosmos.shadeInteractor } val fakeAuthenticationRepository by lazy { kosmos.fakeAuthenticationRepository } val deviceEntryFingerprintAuthRepository by lazy { kosmos.deviceEntryFingerprintAuthRepository } private val kosmos = testKosmos().useUnconfinedTestDispatcher() lateinit var underTest: ShadeBackActionInteractor @Before fun ignoreSplitShadeAndSetup() { Assume.assumeFalse(Utilities.isLargeScreen(kosmos.applicationContext)) assumeFalse(Utilities.isLargeScreen(kosmos.applicationContext)) underTest = kosmos.shadeBackActionInteractor } @Test fun animateCollapseQs_notOnQs() = testScope.runTest { kosmos.runTest { enableSingleShade() val actual by collectLastValue(sceneInteractor.currentScene) setScene(Scenes.Shade) underTest.animateCollapseQs(true) runCurrent() assertThat(actual).isEqualTo(Scenes.Shade) } @Test fun animateCollapseQs_fullyCollapse_entered() = testScope.runTest { kosmos.runTest { enableSingleShade() // Ensure that HomeSceneFamilyResolver is running kosmos.homeSceneFamilyResolver.resolvedScene.launchIn(backgroundScope) homeSceneFamilyResolver.resolvedScene.launchIn(kosmos.backgroundScope) val actual by collectLastValue(sceneInteractor.currentScene) enterDevice() setScene(Scenes.QuickSettings) underTest.animateCollapseQs(true) runCurrent() assertThat(actual).isEqualTo(Scenes.Gone) } @Test fun animateCollapseQs_fullyCollapse_locked() = testScope.runTest { kosmos.runTest { enableSingleShade() val actual by collectLastValue(sceneInteractor.currentScene) setScene(Scenes.QuickSettings) underTest.animateCollapseQs(true) runCurrent() assertThat(actual).isEqualTo(Scenes.Lockscreen) } @Test fun animateCollapseQs_notFullyCollapse() = testScope.runTest { kosmos.runTest { enableSingleShade() val actual by collectLastValue(sceneInteractor.currentScene) setScene(Scenes.QuickSettings) underTest.animateCollapseQs(false) runCurrent() assertThat(actual).isEqualTo(Scenes.Shade) } private fun TestScope.enterDevice() { private fun Kosmos.enterDevice() { // configure device unlocked state fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin) runCurrent() deviceEntryFingerprintAuthRepository.setAuthenticationStatus( SuccessFingerprintAuthenticationStatus(0, true) ) runCurrent() setScene(Scenes.Gone) } private fun TestScope.setScene(key: SceneKey) { private fun Kosmos.setScene(key: SceneKey) { val actual by collectLastValue(sceneInteractor.currentScene) sceneInteractor.changeScene(key, "test") sceneInteractor.setTransitionState( MutableStateFlow<ObservableTransitionState>(ObservableTransitionState.Idle(key)) ) runCurrent() sceneInteractor.setTransitionState(flowOf(ObservableTransitionState.Idle(key))) assertThat(actual).isEqualTo(key) } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeBackActionInteractorImplTest.kt +30 −31 Original line number Diff line number Diff line Loading @@ -24,23 +24,23 @@ import com.android.compose.animation.scene.SceneKey import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.keyguard.data.repository.deviceEntryFingerprintAuthRepository import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticationStatus import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.backgroundScope import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.domain.resolver.homeSceneFamilyResolver import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shared.recents.utilities.Utilities import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Assume import org.junit.Assume.assumeFalse import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -49,82 +49,81 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @EnableSceneContainer class ShadeBackActionInteractorImplTest : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val sceneInteractor by lazy { kosmos.sceneInteractor } val shadeInteractor by lazy { kosmos.shadeInteractor } val fakeAuthenticationRepository by lazy { kosmos.fakeAuthenticationRepository } val deviceEntryFingerprintAuthRepository by lazy { kosmos.deviceEntryFingerprintAuthRepository } private val kosmos = testKosmos().useUnconfinedTestDispatcher() lateinit var underTest: ShadeBackActionInteractor @Before fun ignoreSplitShadeAndSetup() { Assume.assumeFalse(Utilities.isLargeScreen(kosmos.applicationContext)) assumeFalse(Utilities.isLargeScreen(kosmos.applicationContext)) underTest = kosmos.shadeBackActionInteractor } @Test fun animateCollapseQs_notOnQs() = testScope.runTest { kosmos.runTest { enableSingleShade() val actual by collectLastValue(sceneInteractor.currentScene) setScene(Scenes.Shade) underTest.animateCollapseQs(true) runCurrent() assertThat(actual).isEqualTo(Scenes.Shade) } @Test fun animateCollapseQs_fullyCollapse_entered() = testScope.runTest { kosmos.runTest { enableSingleShade() // Ensure that HomeSceneFamilyResolver is running kosmos.homeSceneFamilyResolver.resolvedScene.launchIn(backgroundScope) homeSceneFamilyResolver.resolvedScene.launchIn(kosmos.backgroundScope) val actual by collectLastValue(sceneInteractor.currentScene) enterDevice() setScene(Scenes.QuickSettings) underTest.animateCollapseQs(true) runCurrent() assertThat(actual).isEqualTo(Scenes.Gone) } @Test fun animateCollapseQs_fullyCollapse_locked() = testScope.runTest { kosmos.runTest { enableSingleShade() val actual by collectLastValue(sceneInteractor.currentScene) setScene(Scenes.QuickSettings) underTest.animateCollapseQs(true) runCurrent() assertThat(actual).isEqualTo(Scenes.Lockscreen) } @Test fun animateCollapseQs_notFullyCollapse() = testScope.runTest { kosmos.runTest { enableSingleShade() val actual by collectLastValue(sceneInteractor.currentScene) setScene(Scenes.QuickSettings) underTest.animateCollapseQs(false) runCurrent() assertThat(actual).isEqualTo(Scenes.Shade) } private fun TestScope.enterDevice() { private fun Kosmos.enterDevice() { // configure device unlocked state fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin) runCurrent() deviceEntryFingerprintAuthRepository.setAuthenticationStatus( SuccessFingerprintAuthenticationStatus(0, true) ) runCurrent() setScene(Scenes.Gone) } private fun TestScope.setScene(key: SceneKey) { private fun Kosmos.setScene(key: SceneKey) { val actual by collectLastValue(sceneInteractor.currentScene) sceneInteractor.changeScene(key, "test") sceneInteractor.setTransitionState( MutableStateFlow<ObservableTransitionState>(ObservableTransitionState.Idle(key)) ) runCurrent() sceneInteractor.setTransitionState(flowOf(ObservableTransitionState.Idle(key))) assertThat(actual).isEqualTo(key) } }