Loading packages/SystemUI/multivalentTests/src/com/android/systemui/actioncorner/domain/interactor/ActionCornerInteractorTest.kt +44 −15 Original line number Diff line number Diff line Loading @@ -35,6 +35,9 @@ import com.android.systemui.actioncorner.data.model.ActionCornerRegion.BOTTOM_RI import com.android.systemui.actioncorner.data.model.ActionCornerState.ActiveActionCorner import com.android.systemui.actioncorner.data.repository.ActionCornerSettingRepository import com.android.systemui.actioncorner.data.repository.FakeActionCornerRepository import com.android.systemui.keyguard.domain.interactor.windowManagerLockscreenVisibilityInteractor import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.kosmos.runTest Loading @@ -42,6 +45,9 @@ import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.lifecycle.activateIn import com.android.systemui.scene.data.repository.Idle import com.android.systemui.scene.data.repository.setTransition import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shared.system.actioncorner.ActionCornerConstants.HOME import com.android.systemui.shared.system.actioncorner.ActionCornerConstants.OVERVIEW import com.android.systemui.statusbar.CommandQueue Loading Loading @@ -76,6 +82,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { launcherProxyService, actionCornerSettingRepository, fakeUserSetupRepository, windowManagerLockscreenVisibilityInteractor, commandQueue, ) } Loading @@ -88,7 +95,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { @Test fun bottomLeftCornerActivated_overviewActionConfigured_notifyLauncherOfOverviewAction() = kosmos.runTest { unlockScreenAndRunTest { settingsRepository.setInt( ACTION_CORNER_BOTTOM_LEFT_ACTION, ACTION_CORNER_ACTION_OVERVIEW, Loading @@ -99,7 +106,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { @Test fun bottomRightCornerActivated_homeActionConfigured_notifyLauncherOfHomeAction() = kosmos.runTest { unlockScreenAndRunTest { settingsRepository.setInt(ACTION_CORNER_BOTTOM_RIGHT_ACTION, ACTION_CORNER_ACTION_HOME) actionCornerRepository.addState(ActiveActionCorner(BOTTOM_RIGHT, DEFAULT_DISPLAY)) verify(launcherProxyService).onActionCornerActivated(HOME, DEFAULT_DISPLAY) Loading @@ -107,7 +114,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { @Test fun topLeftCornerActivated_notificationsActionConfigured_toggleNotificationShade() = kosmos.runTest { unlockScreenAndRunTest { settingsRepository.setInt( ACTION_CORNER_TOP_LEFT_ACTION, ACTION_CORNER_ACTION_NOTIFICATIONS, Loading @@ -121,8 +128,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { } @Test fun topRightCornerActivated_qsActionConfigured_toggleQsPanel() = kosmos.runTest { fun topRightCornerActivated_qsActionConfigured_toggleQsPanel() = unlockScreenAndRunTest { settingsRepository.setInt( ACTION_CORNER_TOP_RIGHT_ACTION, ACTION_CORNER_ACTION_QUICK_SETTINGS, Loading @@ -137,7 +143,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { @Test fun userNotSetUp_overviewActionConfigured_actionCornerActivated_actionNotTriggered() = kosmos.runTest { unlockScreenAndRunTest { settingsRepository.setInt( ACTION_CORNER_BOTTOM_LEFT_ACTION, ACTION_CORNER_ACTION_OVERVIEW, Loading @@ -146,4 +152,27 @@ class ActionCornerInteractorTest : SysuiTestCase() { actionCornerRepository.addState(ActiveActionCorner(BOTTOM_LEFT, DEFAULT_DISPLAY)) verify(launcherProxyService, never()).onActionCornerActivated(OVERVIEW, DEFAULT_DISPLAY) } @Test fun lockscreenVisible_overviewActionConfigured_actionCornerActivated_actionNotTriggered() = kosmos.runTest { // We are in lockscreen by default settingsRepository.setInt( ACTION_CORNER_BOTTOM_LEFT_ACTION, ACTION_CORNER_ACTION_OVERVIEW, ) actionCornerRepository.addState(ActiveActionCorner(BOTTOM_LEFT, DEFAULT_DISPLAY)) verify(launcherProxyService, never()).onActionCornerActivated(OVERVIEW, DEFAULT_DISPLAY) } private fun unlockScreenAndRunTest(testBody: suspend Kosmos.() -> Unit) = kosmos.runTest { setTransition( sceneTransition = Idle(Scenes.Gone), stateTransition = TransitionStep(from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE), ) testBody() } } packages/SystemUI/src/com/android/systemui/actioncorner/domain/interactor/ActionCornerInteractor.kt +12 −2 Original line number Diff line number Diff line Loading @@ -32,12 +32,15 @@ import com.android.systemui.actioncorner.data.model.ActionType.QUICK_SETTINGS import com.android.systemui.actioncorner.data.repository.ActionCornerRepository import com.android.systemui.actioncorner.data.repository.ActionCornerSettingRepository import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.domain.interactor.WindowManagerLockscreenVisibilityInteractor import com.android.systemui.lifecycle.ExclusiveActivatable import com.android.systemui.shared.system.actioncorner.ActionCornerConstants import com.android.systemui.statusbar.CommandQueue import com.android.systemui.statusbar.policy.data.repository.UserSetupRepository import javax.inject.Inject import kotlinx.coroutines.awaitCancellation import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.filterIsInstance import kotlinx.coroutines.flow.flatMapLatest Loading @@ -50,13 +53,20 @@ constructor( private val launcherProxyService: LauncherProxyService, private val actionCornerSettingRepository: ActionCornerSettingRepository, private val userSetupRepository: UserSetupRepository, private val lockscreenVisibilityInteractor: WindowManagerLockscreenVisibilityInteractor, private val commandQueue: CommandQueue, ) : ExclusiveActivatable() { override suspend fun onActivated(): Nothing { userSetupRepository.isUserSetUp .flatMapLatest { if (it) { .combine(lockscreenVisibilityInteractor.lockscreenVisibility) { isUserSetUp, isLockscreenVisible -> isUserSetUp && !isLockscreenVisible } .distinctUntilChanged() .flatMapLatest { shouldMonitorActionCorner -> if (shouldMonitorActionCorner) { repository.actionCornerState.filterIsInstance<ActiveActionCorner>() } else { emptyFlow() Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/actioncorner/domain/interactor/ActionCornerInteractorTest.kt +44 −15 Original line number Diff line number Diff line Loading @@ -35,6 +35,9 @@ import com.android.systemui.actioncorner.data.model.ActionCornerRegion.BOTTOM_RI import com.android.systemui.actioncorner.data.model.ActionCornerState.ActiveActionCorner import com.android.systemui.actioncorner.data.repository.ActionCornerSettingRepository import com.android.systemui.actioncorner.data.repository.FakeActionCornerRepository import com.android.systemui.keyguard.domain.interactor.windowManagerLockscreenVisibilityInteractor import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.kosmos.runTest Loading @@ -42,6 +45,9 @@ import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.lifecycle.activateIn import com.android.systemui.scene.data.repository.Idle import com.android.systemui.scene.data.repository.setTransition import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shared.system.actioncorner.ActionCornerConstants.HOME import com.android.systemui.shared.system.actioncorner.ActionCornerConstants.OVERVIEW import com.android.systemui.statusbar.CommandQueue Loading Loading @@ -76,6 +82,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { launcherProxyService, actionCornerSettingRepository, fakeUserSetupRepository, windowManagerLockscreenVisibilityInteractor, commandQueue, ) } Loading @@ -88,7 +95,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { @Test fun bottomLeftCornerActivated_overviewActionConfigured_notifyLauncherOfOverviewAction() = kosmos.runTest { unlockScreenAndRunTest { settingsRepository.setInt( ACTION_CORNER_BOTTOM_LEFT_ACTION, ACTION_CORNER_ACTION_OVERVIEW, Loading @@ -99,7 +106,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { @Test fun bottomRightCornerActivated_homeActionConfigured_notifyLauncherOfHomeAction() = kosmos.runTest { unlockScreenAndRunTest { settingsRepository.setInt(ACTION_CORNER_BOTTOM_RIGHT_ACTION, ACTION_CORNER_ACTION_HOME) actionCornerRepository.addState(ActiveActionCorner(BOTTOM_RIGHT, DEFAULT_DISPLAY)) verify(launcherProxyService).onActionCornerActivated(HOME, DEFAULT_DISPLAY) Loading @@ -107,7 +114,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { @Test fun topLeftCornerActivated_notificationsActionConfigured_toggleNotificationShade() = kosmos.runTest { unlockScreenAndRunTest { settingsRepository.setInt( ACTION_CORNER_TOP_LEFT_ACTION, ACTION_CORNER_ACTION_NOTIFICATIONS, Loading @@ -121,8 +128,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { } @Test fun topRightCornerActivated_qsActionConfigured_toggleQsPanel() = kosmos.runTest { fun topRightCornerActivated_qsActionConfigured_toggleQsPanel() = unlockScreenAndRunTest { settingsRepository.setInt( ACTION_CORNER_TOP_RIGHT_ACTION, ACTION_CORNER_ACTION_QUICK_SETTINGS, Loading @@ -137,7 +143,7 @@ class ActionCornerInteractorTest : SysuiTestCase() { @Test fun userNotSetUp_overviewActionConfigured_actionCornerActivated_actionNotTriggered() = kosmos.runTest { unlockScreenAndRunTest { settingsRepository.setInt( ACTION_CORNER_BOTTOM_LEFT_ACTION, ACTION_CORNER_ACTION_OVERVIEW, Loading @@ -146,4 +152,27 @@ class ActionCornerInteractorTest : SysuiTestCase() { actionCornerRepository.addState(ActiveActionCorner(BOTTOM_LEFT, DEFAULT_DISPLAY)) verify(launcherProxyService, never()).onActionCornerActivated(OVERVIEW, DEFAULT_DISPLAY) } @Test fun lockscreenVisible_overviewActionConfigured_actionCornerActivated_actionNotTriggered() = kosmos.runTest { // We are in lockscreen by default settingsRepository.setInt( ACTION_CORNER_BOTTOM_LEFT_ACTION, ACTION_CORNER_ACTION_OVERVIEW, ) actionCornerRepository.addState(ActiveActionCorner(BOTTOM_LEFT, DEFAULT_DISPLAY)) verify(launcherProxyService, never()).onActionCornerActivated(OVERVIEW, DEFAULT_DISPLAY) } private fun unlockScreenAndRunTest(testBody: suspend Kosmos.() -> Unit) = kosmos.runTest { setTransition( sceneTransition = Idle(Scenes.Gone), stateTransition = TransitionStep(from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE), ) testBody() } }
packages/SystemUI/src/com/android/systemui/actioncorner/domain/interactor/ActionCornerInteractor.kt +12 −2 Original line number Diff line number Diff line Loading @@ -32,12 +32,15 @@ import com.android.systemui.actioncorner.data.model.ActionType.QUICK_SETTINGS import com.android.systemui.actioncorner.data.repository.ActionCornerRepository import com.android.systemui.actioncorner.data.repository.ActionCornerSettingRepository import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.domain.interactor.WindowManagerLockscreenVisibilityInteractor import com.android.systemui.lifecycle.ExclusiveActivatable import com.android.systemui.shared.system.actioncorner.ActionCornerConstants import com.android.systemui.statusbar.CommandQueue import com.android.systemui.statusbar.policy.data.repository.UserSetupRepository import javax.inject.Inject import kotlinx.coroutines.awaitCancellation import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.filterIsInstance import kotlinx.coroutines.flow.flatMapLatest Loading @@ -50,13 +53,20 @@ constructor( private val launcherProxyService: LauncherProxyService, private val actionCornerSettingRepository: ActionCornerSettingRepository, private val userSetupRepository: UserSetupRepository, private val lockscreenVisibilityInteractor: WindowManagerLockscreenVisibilityInteractor, private val commandQueue: CommandQueue, ) : ExclusiveActivatable() { override suspend fun onActivated(): Nothing { userSetupRepository.isUserSetUp .flatMapLatest { if (it) { .combine(lockscreenVisibilityInteractor.lockscreenVisibility) { isUserSetUp, isLockscreenVisible -> isUserSetUp && !isLockscreenVisible } .distinctUntilChanged() .flatMapLatest { shouldMonitorActionCorner -> if (shouldMonitorActionCorner) { repository.actionCornerState.filterIsInstance<ActiveActionCorner>() } else { emptyFlow() Loading