Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModelTest.kt +49 −2 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,8 @@ import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.collectLastValue Loading Loading @@ -68,12 +70,12 @@ import platform.test.runner.parameterized.Parameters class LockscreenUserActionsViewModelTest : SysuiTestCase() { class LockscreenUserActionsViewModelTest : SysuiTestCase() { companion object { companion object { private const val parameterCount = 5 private const val parameterCount = 6 @Parameters( @Parameters( name = name = "canSwipeToEnter={0}, downWithTwoPointers={1}, downFromEdge={2}," + "canSwipeToEnter={0}, downWithTwoPointers={1}, downFromEdge={2}," + " isSingleShade={3}, isShadeTouchable={4}" " isSingleShade={3}, isShadeTouchable={4}, isCommunalAvailable={5}" ) ) @JvmStatic @JvmStatic fun combinations() = buildList { fun combinations() = buildList { Loading @@ -85,6 +87,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { /* downFromEdge= */ combination and 4 != 0, /* downFromEdge= */ combination and 4 != 0, /* isSingleShade= */ combination and 8 != 0, /* isSingleShade= */ combination and 8 != 0, /* isShadeTouchable= */ combination and 16 != 0, /* isShadeTouchable= */ combination and 16 != 0, /* isCommunalAvailable= */ combination and 32 != 0, ) ) .also { check(it.size == parameterCount) } .also { check(it.size == parameterCount) } ) ) Loading Loading @@ -143,6 +146,17 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { else -> Overlays.Bouncer else -> Overlays.Bouncer } } } } private fun expectedStartDestination( isCommunalAvailable: Boolean, isShadeTouchable: Boolean, ): SceneKey? { return when { !isShadeTouchable -> null isCommunalAvailable -> Scenes.Communal else -> null } } } } private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val kosmos = testKosmos().useUnconfinedTestDispatcher() Loading @@ -152,6 +166,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { @JvmField @Parameter(2) var downFromEdge: Boolean = false @JvmField @Parameter(2) var downFromEdge: Boolean = false @JvmField @Parameter(3) var isNarrowScreen: Boolean = true @JvmField @Parameter(3) var isNarrowScreen: Boolean = true @JvmField @Parameter(4) var isShadeTouchable: Boolean = false @JvmField @Parameter(4) var isShadeTouchable: Boolean = false @JvmField @Parameter(5) var isCommunalAvailable: Boolean = false private val underTest by lazy { kosmos.lockscreenUserActionsViewModel } private val underTest by lazy { kosmos.lockscreenUserActionsViewModel } Loading @@ -175,6 +190,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { ) ) sceneInteractor.changeScene(Scenes.Lockscreen, "reason") sceneInteractor.changeScene(Scenes.Lockscreen, "reason") shadeRepository.setShadeLayoutWide(!isNarrowScreen) shadeRepository.setShadeLayoutWide(!isNarrowScreen) kosmos.setCommunalAvailable(isCommunalAvailable) fakePowerRepository.updateWakefulness( fakePowerRepository.updateWakefulness( rawState = if (isShadeTouchable) WakefulnessState.AWAKE else WakefulnessState.ASLEEP rawState = if (isShadeTouchable) WakefulnessState.AWAKE else WakefulnessState.ASLEEP ) ) Loading Loading @@ -227,6 +243,21 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { isShadeTouchable = isShadeTouchable, isShadeTouchable = isShadeTouchable, ) ) ) ) val startScene by collectLastValue( (userActions?.get(Swipe.Start) as? ChangeScene)?.toScene?.let { scene -> sceneInteractor.resolveSceneFamily(scene) } ?: flowOf(null) ) assertThat(startScene) .isEqualTo( expectedStartDestination( isCommunalAvailable = isCommunalAvailable, isShadeTouchable = isShadeTouchable, ) ) } } @Test @Test Loading @@ -243,6 +274,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { } } ) ) sceneInteractor.changeScene(Scenes.Lockscreen, "reason") sceneInteractor.changeScene(Scenes.Lockscreen, "reason") kosmos.setCommunalAvailable(isCommunalAvailable) fakePowerRepository.updateWakefulness( fakePowerRepository.updateWakefulness( rawState = if (isShadeTouchable) WakefulnessState.AWAKE else WakefulnessState.ASLEEP rawState = if (isShadeTouchable) WakefulnessState.AWAKE else WakefulnessState.ASLEEP ) ) Loading Loading @@ -299,5 +331,20 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { isShadeTouchable = isShadeTouchable, isShadeTouchable = isShadeTouchable, ) ) ) ) val startScene by collectLastValue( (userActions?.get(Swipe.Start) as? ChangeScene)?.toScene?.let { scene -> sceneInteractor.resolveSceneFamily(scene) } ?: flowOf(null) ) assertThat(startScene) .isEqualTo( expectedStartDestination( isCommunalAvailable = isCommunalAvailable, isShadeTouchable = isShadeTouchable, ) ) } } } } packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModel.kt +11 −3 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.viewmodel import com.android.compose.animation.scene.Swipe import com.android.compose.animation.scene.Swipe import com.android.compose.animation.scene.UserAction import com.android.compose.animation.scene.UserAction import com.android.compose.animation.scene.UserActionResult import com.android.compose.animation.scene.UserActionResult import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.Scenes Loading @@ -42,6 +43,7 @@ class LockscreenUserActionsViewModel @AssistedInject @AssistedInject constructor( constructor( private val deviceEntryInteractor: DeviceEntryInteractor, private val deviceEntryInteractor: DeviceEntryInteractor, private val communalInteractor: CommunalInteractor, private val shadeInteractor: ShadeInteractor, private val shadeInteractor: ShadeInteractor, private val shadeModeInteractor: ShadeModeInteractor, private val shadeModeInteractor: ShadeModeInteractor, ) : UserActionsViewModel() { ) : UserActionsViewModel() { Loading @@ -53,10 +55,16 @@ constructor( return@flatMapLatest flowOf(emptyMap()) return@flatMapLatest flowOf(emptyMap()) } } combine(deviceEntryInteractor.isUnlocked, shadeModeInteractor.shadeMode) { combine( isDeviceUnlocked, deviceEntryInteractor.isUnlocked, shadeMode -> communalInteractor.isCommunalAvailable, shadeModeInteractor.shadeMode, ) { isDeviceUnlocked, isCommunalAvailable, shadeMode -> buildList { buildList { if (isCommunalAvailable) { add(Swipe.Start to Scenes.Communal) } if (isDeviceUnlocked) { if (isDeviceUnlocked) { add(Swipe.Up to Scenes.Gone) add(Swipe.Up to Scenes.Gone) } else { } else { Loading packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModelKosmos.kt +2 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.keyguard.ui.viewmodel package com.android.systemui.keyguard.ui.viewmodel import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.kosmos.Kosmos.Fixture Loading @@ -25,6 +26,7 @@ import com.android.systemui.shade.domain.interactor.shadeModeInteractor val Kosmos.lockscreenUserActionsViewModel by Fixture { val Kosmos.lockscreenUserActionsViewModel by Fixture { LockscreenUserActionsViewModel( LockscreenUserActionsViewModel( deviceEntryInteractor = deviceEntryInteractor, deviceEntryInteractor = deviceEntryInteractor, communalInteractor = communalInteractor, shadeInteractor = shadeInteractor, shadeInteractor = shadeInteractor, shadeModeInteractor = shadeModeInteractor, shadeModeInteractor = shadeModeInteractor, ) ) Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModelTest.kt +49 −2 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,8 @@ import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.collectLastValue Loading Loading @@ -68,12 +70,12 @@ import platform.test.runner.parameterized.Parameters class LockscreenUserActionsViewModelTest : SysuiTestCase() { class LockscreenUserActionsViewModelTest : SysuiTestCase() { companion object { companion object { private const val parameterCount = 5 private const val parameterCount = 6 @Parameters( @Parameters( name = name = "canSwipeToEnter={0}, downWithTwoPointers={1}, downFromEdge={2}," + "canSwipeToEnter={0}, downWithTwoPointers={1}, downFromEdge={2}," + " isSingleShade={3}, isShadeTouchable={4}" " isSingleShade={3}, isShadeTouchable={4}, isCommunalAvailable={5}" ) ) @JvmStatic @JvmStatic fun combinations() = buildList { fun combinations() = buildList { Loading @@ -85,6 +87,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { /* downFromEdge= */ combination and 4 != 0, /* downFromEdge= */ combination and 4 != 0, /* isSingleShade= */ combination and 8 != 0, /* isSingleShade= */ combination and 8 != 0, /* isShadeTouchable= */ combination and 16 != 0, /* isShadeTouchable= */ combination and 16 != 0, /* isCommunalAvailable= */ combination and 32 != 0, ) ) .also { check(it.size == parameterCount) } .also { check(it.size == parameterCount) } ) ) Loading Loading @@ -143,6 +146,17 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { else -> Overlays.Bouncer else -> Overlays.Bouncer } } } } private fun expectedStartDestination( isCommunalAvailable: Boolean, isShadeTouchable: Boolean, ): SceneKey? { return when { !isShadeTouchable -> null isCommunalAvailable -> Scenes.Communal else -> null } } } } private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val kosmos = testKosmos().useUnconfinedTestDispatcher() Loading @@ -152,6 +166,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { @JvmField @Parameter(2) var downFromEdge: Boolean = false @JvmField @Parameter(2) var downFromEdge: Boolean = false @JvmField @Parameter(3) var isNarrowScreen: Boolean = true @JvmField @Parameter(3) var isNarrowScreen: Boolean = true @JvmField @Parameter(4) var isShadeTouchable: Boolean = false @JvmField @Parameter(4) var isShadeTouchable: Boolean = false @JvmField @Parameter(5) var isCommunalAvailable: Boolean = false private val underTest by lazy { kosmos.lockscreenUserActionsViewModel } private val underTest by lazy { kosmos.lockscreenUserActionsViewModel } Loading @@ -175,6 +190,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { ) ) sceneInteractor.changeScene(Scenes.Lockscreen, "reason") sceneInteractor.changeScene(Scenes.Lockscreen, "reason") shadeRepository.setShadeLayoutWide(!isNarrowScreen) shadeRepository.setShadeLayoutWide(!isNarrowScreen) kosmos.setCommunalAvailable(isCommunalAvailable) fakePowerRepository.updateWakefulness( fakePowerRepository.updateWakefulness( rawState = if (isShadeTouchable) WakefulnessState.AWAKE else WakefulnessState.ASLEEP rawState = if (isShadeTouchable) WakefulnessState.AWAKE else WakefulnessState.ASLEEP ) ) Loading Loading @@ -227,6 +243,21 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { isShadeTouchable = isShadeTouchable, isShadeTouchable = isShadeTouchable, ) ) ) ) val startScene by collectLastValue( (userActions?.get(Swipe.Start) as? ChangeScene)?.toScene?.let { scene -> sceneInteractor.resolveSceneFamily(scene) } ?: flowOf(null) ) assertThat(startScene) .isEqualTo( expectedStartDestination( isCommunalAvailable = isCommunalAvailable, isShadeTouchable = isShadeTouchable, ) ) } } @Test @Test Loading @@ -243,6 +274,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { } } ) ) sceneInteractor.changeScene(Scenes.Lockscreen, "reason") sceneInteractor.changeScene(Scenes.Lockscreen, "reason") kosmos.setCommunalAvailable(isCommunalAvailable) fakePowerRepository.updateWakefulness( fakePowerRepository.updateWakefulness( rawState = if (isShadeTouchable) WakefulnessState.AWAKE else WakefulnessState.ASLEEP rawState = if (isShadeTouchable) WakefulnessState.AWAKE else WakefulnessState.ASLEEP ) ) Loading Loading @@ -299,5 +331,20 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { isShadeTouchable = isShadeTouchable, isShadeTouchable = isShadeTouchable, ) ) ) ) val startScene by collectLastValue( (userActions?.get(Swipe.Start) as? ChangeScene)?.toScene?.let { scene -> sceneInteractor.resolveSceneFamily(scene) } ?: flowOf(null) ) assertThat(startScene) .isEqualTo( expectedStartDestination( isCommunalAvailable = isCommunalAvailable, isShadeTouchable = isShadeTouchable, ) ) } } } }
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModel.kt +11 −3 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.viewmodel import com.android.compose.animation.scene.Swipe import com.android.compose.animation.scene.Swipe import com.android.compose.animation.scene.UserAction import com.android.compose.animation.scene.UserAction import com.android.compose.animation.scene.UserActionResult import com.android.compose.animation.scene.UserActionResult import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.Scenes Loading @@ -42,6 +43,7 @@ class LockscreenUserActionsViewModel @AssistedInject @AssistedInject constructor( constructor( private val deviceEntryInteractor: DeviceEntryInteractor, private val deviceEntryInteractor: DeviceEntryInteractor, private val communalInteractor: CommunalInteractor, private val shadeInteractor: ShadeInteractor, private val shadeInteractor: ShadeInteractor, private val shadeModeInteractor: ShadeModeInteractor, private val shadeModeInteractor: ShadeModeInteractor, ) : UserActionsViewModel() { ) : UserActionsViewModel() { Loading @@ -53,10 +55,16 @@ constructor( return@flatMapLatest flowOf(emptyMap()) return@flatMapLatest flowOf(emptyMap()) } } combine(deviceEntryInteractor.isUnlocked, shadeModeInteractor.shadeMode) { combine( isDeviceUnlocked, deviceEntryInteractor.isUnlocked, shadeMode -> communalInteractor.isCommunalAvailable, shadeModeInteractor.shadeMode, ) { isDeviceUnlocked, isCommunalAvailable, shadeMode -> buildList { buildList { if (isCommunalAvailable) { add(Swipe.Start to Scenes.Communal) } if (isDeviceUnlocked) { if (isDeviceUnlocked) { add(Swipe.Up to Scenes.Gone) add(Swipe.Up to Scenes.Gone) } else { } else { Loading
packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModelKosmos.kt +2 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.keyguard.ui.viewmodel package com.android.systemui.keyguard.ui.viewmodel import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.kosmos.Kosmos.Fixture Loading @@ -25,6 +26,7 @@ import com.android.systemui.shade.domain.interactor.shadeModeInteractor val Kosmos.lockscreenUserActionsViewModel by Fixture { val Kosmos.lockscreenUserActionsViewModel by Fixture { LockscreenUserActionsViewModel( LockscreenUserActionsViewModel( deviceEntryInteractor = deviceEntryInteractor, deviceEntryInteractor = deviceEntryInteractor, communalInteractor = communalInteractor, shadeInteractor = shadeInteractor, shadeInteractor = shadeInteractor, shadeModeInteractor = shadeModeInteractor, shadeModeInteractor = shadeModeInteractor, ) ) Loading