Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +46 −0 Original line number Diff line number Diff line Loading @@ -16,10 +16,12 @@ package com.android.systemui.statusbar.chips.notification.ui.viewmodel import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.view.View import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository Loading Loading @@ -71,6 +73,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_noNotifs_empty() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -81,6 +84,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_notifMissingStatusBarChipIconView_empty() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -99,6 +103,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_onePromotedNotif_statusBarIconViewMatches() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -122,6 +127,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_onePromotedNotif_connectedDisplaysFlagEnabled_statusBarIconMatches() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -145,6 +151,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_onePromotedNotif_colorMatches() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -175,6 +182,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_onlyForPromotedNotifs() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -208,6 +216,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_connectedDisplaysFlagEnabled_onlyForPromotedNotifs() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -242,6 +251,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_hasShortCriticalText_usesTextInsteadOfTime() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -272,6 +282,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_noTime_isIconOnly() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -294,6 +305,36 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @EnableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_basicTime_hiddenIfAutomaticallyPromoted() = kosmos.runTest { val latest by collectLastValue(underTest.chips) val promotedContentBuilder = PromotedNotificationContentModel.Builder("notif").apply { this.time = PromotedNotificationContentModel.When( time = 6543L, mode = PromotedNotificationContentModel.When.Mode.BasicTime, ) } setNotifs( listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), promotedContent = promotedContentBuilder.build(), ) ) ) assertThat(latest).hasSize(1) assertThat(latest!![0]) .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_basicTime_isShortTimeDelta() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -322,6 +363,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_countUpTime_isTimer() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -349,6 +391,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_countDownTime_isTimer() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -376,6 +419,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_noHeadsUp_showsTime() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -407,6 +451,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_hasHeadsUpByUser_onlyShowsIcon() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -442,6 +487,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_clickingChipNotifiesInteractor() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.chips.notification.ui.viewmodel import android.view.View import com.android.systemui.Flags import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.statusbar.chips.notification.domain.interactor.StatusBarNotificationChipsInteractor Loading Loading @@ -99,6 +100,17 @@ constructor( ) } if (Flags.promoteNotificationsAutomatically()) { // When we're promoting notifications automatically, the `when` time set on the // notification will likely just be set to the current time, which would cause the chip // to always show "now". We don't want early testers to get that experience since it's // not what will happen at launch, so just don't show any time. // TODO(b/364653005): Only ignore the `when` time if the notification was // *automatically* promoted (as opposed to being legitimately promoted by the // criteria). We'll need to track that status somehow. return OngoingActivityChipModel.Shown.IconOnly(icon, colors, onClickListener) } if (this.promotedContent.time == null) { return OngoingActivityChipModel.Shown.IconOnly(icon, colors, onClickListener) } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +46 −0 Original line number Diff line number Diff line Loading @@ -16,10 +16,12 @@ package com.android.systemui.statusbar.chips.notification.ui.viewmodel import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.view.View import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository Loading Loading @@ -71,6 +73,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_noNotifs_empty() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -81,6 +84,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_notifMissingStatusBarChipIconView_empty() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -99,6 +103,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_onePromotedNotif_statusBarIconViewMatches() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -122,6 +127,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_onePromotedNotif_connectedDisplaysFlagEnabled_statusBarIconMatches() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -145,6 +151,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_onePromotedNotif_colorMatches() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -175,6 +182,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_onlyForPromotedNotifs() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -208,6 +216,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { @Test @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME) @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_connectedDisplaysFlagEnabled_onlyForPromotedNotifs() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -242,6 +251,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_hasShortCriticalText_usesTextInsteadOfTime() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -272,6 +282,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_noTime_isIconOnly() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -294,6 +305,36 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @EnableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_basicTime_hiddenIfAutomaticallyPromoted() = kosmos.runTest { val latest by collectLastValue(underTest.chips) val promotedContentBuilder = PromotedNotificationContentModel.Builder("notif").apply { this.time = PromotedNotificationContentModel.When( time = 6543L, mode = PromotedNotificationContentModel.When.Mode.BasicTime, ) } setNotifs( listOf( activeNotificationModel( key = "notif", statusBarChipIcon = mock<StatusBarIconView>(), promotedContent = promotedContentBuilder.build(), ) ) ) assertThat(latest).hasSize(1) assertThat(latest!![0]) .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_basicTime_isShortTimeDelta() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -322,6 +363,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_countUpTime_isTimer() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -349,6 +391,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_countDownTime_isTimer() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -376,6 +419,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_noHeadsUp_showsTime() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -407,6 +451,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_hasHeadsUpByUser_onlyShowsIcon() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading Loading @@ -442,6 +487,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_clickingChipNotifiesInteractor() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading
packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.chips.notification.ui.viewmodel import android.view.View import com.android.systemui.Flags import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.statusbar.chips.notification.domain.interactor.StatusBarNotificationChipsInteractor Loading Loading @@ -99,6 +100,17 @@ constructor( ) } if (Flags.promoteNotificationsAutomatically()) { // When we're promoting notifications automatically, the `when` time set on the // notification will likely just be set to the current time, which would cause the chip // to always show "now". We don't want early testers to get that experience since it's // not what will happen at launch, so just don't show any time. // TODO(b/364653005): Only ignore the `when` time if the notification was // *automatically* promoted (as opposed to being legitimately promoted by the // criteria). We'll need to track that status somehow. return OngoingActivityChipModel.Shown.IconOnly(icon, colors, onClickListener) } if (this.promotedContent.time == null) { return OngoingActivityChipModel.Shown.IconOnly(icon, colors, onClickListener) } Loading