Loading packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeHeaderViewModelTest.kt +63 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.systemui.plugins.activityStarter import com.android.systemui.privacy.PrivacyApplication import com.android.systemui.privacy.PrivacyItem import com.android.systemui.privacy.PrivacyType import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes Loading Loading @@ -77,9 +78,26 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test fun onClockClicked_launchesClock() = fun onClockClicked_enableDesktopFeatureSetFalse_launchesClock() = testScope.runTest { overrideResource(R.bool.config_enableDesktopFeatureSet, false) val activityStarter = kosmos.activityStarter underTest.onClockClicked() verify(activityStarter) .postStartActivityDismissingKeyguard( argThat(IntentMatcherAction(AlarmClock.ACTION_SHOW_ALARMS)), anyInt(), ) } @Test fun onClockClicked_enableDesktopFeatureSetTrueAndSingleShade_launchesClock() = testScope.runTest { overrideResource(R.bool.config_enableDesktopFeatureSet, true) val activityStarter = kosmos.activityStarter underTest.onClockClicked() verify(activityStarter) Loading @@ -89,6 +107,50 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { ) } @Test fun onClockClicked_enableDesktopFeatureSetTrueAndDualShade_openNotifShade() = testScope.runTest { overrideResource(R.bool.config_enableDesktopFeatureSet, true) setupDualShadeState(scene = Scenes.Gone) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) underTest.onClockClicked() assertThat(currentScene).isEqualTo(Scenes.Gone) assertThat(currentOverlays).contains(Overlays.NotificationsShade) assertThat(currentOverlays).doesNotContain(Overlays.QuickSettingsShade) } @Test fun onClockClicked_enableDesktopFeatureSetTrueOnNotifShade_closesShade() = testScope.runTest { overrideResource(R.bool.config_enableDesktopFeatureSet, true) setupDualShadeState(scene = Scenes.Gone, overlay = Overlays.NotificationsShade) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) underTest.onClockClicked() assertThat(currentScene).isEqualTo(Scenes.Gone) assertThat(currentOverlays).isEmpty() } @Test fun onClockClicked_enableDesktopFeatureSetTrueOnQSShade_openNotifShade() = testScope.runTest { overrideResource(R.bool.config_enableDesktopFeatureSet, true) setupDualShadeState(scene = Scenes.Gone, overlay = Overlays.QuickSettingsShade) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) underTest.onClockClicked() assertThat(currentScene).isEqualTo(Scenes.Gone) assertThat(currentOverlays).contains(Overlays.NotificationsShade) assertThat(currentOverlays).doesNotContain(Overlays.QuickSettingsShade) } @Test fun onShadeCarrierGroupClicked_launchesNetworkSettings() = testScope.runTest { Loading packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeHeaderViewModel.kt +26 −4 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ import kotlinx.coroutines.flow.mapLatest class ShadeHeaderViewModel @AssistedInject constructor( @ShadeDisplayAware context: Context, @ShadeDisplayAware private val context: Context, private val activityStarter: ActivityStarter, private val sceneInteractor: SceneInteractor, private val shadeInteractor: ShadeInteractor, Loading Loading @@ -207,22 +207,44 @@ constructor( /** Notifies that the clock was clicked. */ fun onClockClicked() { if (shadeModeInteractor.isDualShade && isDesktopFeatureSetEnabled()) { toggleNotificationShade( loggingReason = "ShadeHeaderViewModel.onClockChipClicked", launchClockActivityOnCollapse = false, ) } else { clockInteractor.launchClockActivity() } } /** Notifies that the notification icons container was clicked. */ fun onNotificationIconChipClicked() { if (!shadeModeInteractor.isDualShade) { return } val loggingReason = "ShadeHeaderViewModel.onNotificationIconChipClicked" toggleNotificationShade( loggingReason = "ShadeHeaderViewModel.onNotificationIconChipClicked", launchClockActivityOnCollapse = !isDesktopFeatureSetEnabled(), ) } private fun isDesktopFeatureSetEnabled(): Boolean { return context.resources.getBoolean(R.bool.config_enableDesktopFeatureSet) } private fun toggleNotificationShade( loggingReason: String, launchClockActivityOnCollapse: Boolean, ) { val currentOverlays = sceneInteractor.currentOverlays.value if (Overlays.NotificationsShade in currentOverlays) { shadeInteractor.collapseNotificationsShade( loggingReason = loggingReason, transitionKey = SlightlyFasterShadeCollapse, ) onClockClicked() if (launchClockActivityOnCollapse) { clockInteractor.launchClockActivity() } } else { shadeInteractor.expandNotificationsShade(loggingReason) } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeHeaderViewModelTest.kt +63 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.systemui.plugins.activityStarter import com.android.systemui.privacy.PrivacyApplication import com.android.systemui.privacy.PrivacyItem import com.android.systemui.privacy.PrivacyType import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes Loading Loading @@ -77,9 +78,26 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test fun onClockClicked_launchesClock() = fun onClockClicked_enableDesktopFeatureSetFalse_launchesClock() = testScope.runTest { overrideResource(R.bool.config_enableDesktopFeatureSet, false) val activityStarter = kosmos.activityStarter underTest.onClockClicked() verify(activityStarter) .postStartActivityDismissingKeyguard( argThat(IntentMatcherAction(AlarmClock.ACTION_SHOW_ALARMS)), anyInt(), ) } @Test fun onClockClicked_enableDesktopFeatureSetTrueAndSingleShade_launchesClock() = testScope.runTest { overrideResource(R.bool.config_enableDesktopFeatureSet, true) val activityStarter = kosmos.activityStarter underTest.onClockClicked() verify(activityStarter) Loading @@ -89,6 +107,50 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { ) } @Test fun onClockClicked_enableDesktopFeatureSetTrueAndDualShade_openNotifShade() = testScope.runTest { overrideResource(R.bool.config_enableDesktopFeatureSet, true) setupDualShadeState(scene = Scenes.Gone) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) underTest.onClockClicked() assertThat(currentScene).isEqualTo(Scenes.Gone) assertThat(currentOverlays).contains(Overlays.NotificationsShade) assertThat(currentOverlays).doesNotContain(Overlays.QuickSettingsShade) } @Test fun onClockClicked_enableDesktopFeatureSetTrueOnNotifShade_closesShade() = testScope.runTest { overrideResource(R.bool.config_enableDesktopFeatureSet, true) setupDualShadeState(scene = Scenes.Gone, overlay = Overlays.NotificationsShade) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) underTest.onClockClicked() assertThat(currentScene).isEqualTo(Scenes.Gone) assertThat(currentOverlays).isEmpty() } @Test fun onClockClicked_enableDesktopFeatureSetTrueOnQSShade_openNotifShade() = testScope.runTest { overrideResource(R.bool.config_enableDesktopFeatureSet, true) setupDualShadeState(scene = Scenes.Gone, overlay = Overlays.QuickSettingsShade) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) underTest.onClockClicked() assertThat(currentScene).isEqualTo(Scenes.Gone) assertThat(currentOverlays).contains(Overlays.NotificationsShade) assertThat(currentOverlays).doesNotContain(Overlays.QuickSettingsShade) } @Test fun onShadeCarrierGroupClicked_launchesNetworkSettings() = testScope.runTest { Loading
packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeHeaderViewModel.kt +26 −4 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ import kotlinx.coroutines.flow.mapLatest class ShadeHeaderViewModel @AssistedInject constructor( @ShadeDisplayAware context: Context, @ShadeDisplayAware private val context: Context, private val activityStarter: ActivityStarter, private val sceneInteractor: SceneInteractor, private val shadeInteractor: ShadeInteractor, Loading Loading @@ -207,22 +207,44 @@ constructor( /** Notifies that the clock was clicked. */ fun onClockClicked() { if (shadeModeInteractor.isDualShade && isDesktopFeatureSetEnabled()) { toggleNotificationShade( loggingReason = "ShadeHeaderViewModel.onClockChipClicked", launchClockActivityOnCollapse = false, ) } else { clockInteractor.launchClockActivity() } } /** Notifies that the notification icons container was clicked. */ fun onNotificationIconChipClicked() { if (!shadeModeInteractor.isDualShade) { return } val loggingReason = "ShadeHeaderViewModel.onNotificationIconChipClicked" toggleNotificationShade( loggingReason = "ShadeHeaderViewModel.onNotificationIconChipClicked", launchClockActivityOnCollapse = !isDesktopFeatureSetEnabled(), ) } private fun isDesktopFeatureSetEnabled(): Boolean { return context.resources.getBoolean(R.bool.config_enableDesktopFeatureSet) } private fun toggleNotificationShade( loggingReason: String, launchClockActivityOnCollapse: Boolean, ) { val currentOverlays = sceneInteractor.currentOverlays.value if (Overlays.NotificationsShade in currentOverlays) { shadeInteractor.collapseNotificationsShade( loggingReason = loggingReason, transitionKey = SlightlyFasterShadeCollapse, ) onClockClicked() if (launchClockActivityOnCollapse) { clockInteractor.launchClockActivity() } } else { shadeInteractor.expandNotificationsShade(loggingReason) } Loading