Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt +32 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.communal.domain.interactor.communalSettingsInteractor import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED import com.android.systemui.flags.fakeFeatureFlagsClassic Loading Loading @@ -73,6 +74,7 @@ class CommunalDreamStartableTest : SysuiTestCase() { keyguardInteractor = kosmos.keyguardInteractor, keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor, dreamManager = dreamManager, communalSceneInteractor = kosmos.communalSceneInteractor, bgScope = kosmos.applicationCoroutineScope, ) .apply { start() } Loading Loading @@ -158,6 +160,36 @@ class CommunalDreamStartableTest : SysuiTestCase() { } } @Test fun shouldNotStartDreamWhenLaunchingWidget() = testScope.runTest { keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) kosmos.communalSceneInteractor.setIsLaunchingWidget(true) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) runCurrent() transition(from = KeyguardState.DREAMING, to = KeyguardState.GLANCEABLE_HUB) verify(dreamManager, never()).startDream() } @Test fun shouldNotStartDreamWhenOccluded() = testScope.runTest { keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) keyguardRepository.setKeyguardOccluded(true) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) runCurrent() transition(from = KeyguardState.DREAMING, to = KeyguardState.GLANCEABLE_HUB) verify(dreamManager, never()).startDream() } private suspend fun TestScope.transition(from: KeyguardState, to: KeyguardState) { kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = from, Loading packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt +4 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.DreamManager import com.android.systemui.CoreStartable import com.android.systemui.Flags.glanceableHubAllowKeyguardWhenDreaming import com.android.systemui.Flags.restartDreamOnUnocclude import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background Loading Loading @@ -55,6 +56,7 @@ constructor( private val keyguardInteractor: KeyguardInteractor, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, private val dreamManager: DreamManager, private val communalSceneInteractor: CommunalSceneInteractor, @Background private val bgScope: CoroutineScope, ) : CoreStartable { /** Flow that emits when the dream should be started underneath the glanceable hub. */ Loading @@ -66,6 +68,8 @@ constructor( not(keyguardInteractor.isDreaming), // TODO(b/362830856): Remove this workaround. keyguardInteractor.isKeyguardShowing, not(communalSceneInteractor.isLaunchingWidget), not(keyguardInteractor.isKeyguardOccluded), ) .filter { it } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt +32 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.communal.domain.interactor.communalSettingsInteractor import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED import com.android.systemui.flags.fakeFeatureFlagsClassic Loading Loading @@ -73,6 +74,7 @@ class CommunalDreamStartableTest : SysuiTestCase() { keyguardInteractor = kosmos.keyguardInteractor, keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor, dreamManager = dreamManager, communalSceneInteractor = kosmos.communalSceneInteractor, bgScope = kosmos.applicationCoroutineScope, ) .apply { start() } Loading Loading @@ -158,6 +160,36 @@ class CommunalDreamStartableTest : SysuiTestCase() { } } @Test fun shouldNotStartDreamWhenLaunchingWidget() = testScope.runTest { keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) kosmos.communalSceneInteractor.setIsLaunchingWidget(true) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) runCurrent() transition(from = KeyguardState.DREAMING, to = KeyguardState.GLANCEABLE_HUB) verify(dreamManager, never()).startDream() } @Test fun shouldNotStartDreamWhenOccluded() = testScope.runTest { keyguardRepository.setKeyguardShowing(true) keyguardRepository.setDreaming(false) powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) keyguardRepository.setKeyguardOccluded(true) whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true) runCurrent() transition(from = KeyguardState.DREAMING, to = KeyguardState.GLANCEABLE_HUB) verify(dreamManager, never()).startDream() } private suspend fun TestScope.transition(from: KeyguardState, to: KeyguardState) { kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = from, Loading
packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt +4 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.DreamManager import com.android.systemui.CoreStartable import com.android.systemui.Flags.glanceableHubAllowKeyguardWhenDreaming import com.android.systemui.Flags.restartDreamOnUnocclude import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background Loading Loading @@ -55,6 +56,7 @@ constructor( private val keyguardInteractor: KeyguardInteractor, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, private val dreamManager: DreamManager, private val communalSceneInteractor: CommunalSceneInteractor, @Background private val bgScope: CoroutineScope, ) : CoreStartable { /** Flow that emits when the dream should be started underneath the glanceable hub. */ Loading @@ -66,6 +68,8 @@ constructor( not(keyguardInteractor.isDreaming), // TODO(b/362830856): Remove this workaround. keyguardInteractor.isKeyguardShowing, not(communalSceneInteractor.isLaunchingWidget), not(keyguardInteractor.isKeyguardOccluded), ) .filter { it } Loading