Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49f12c11 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge "Replace StatusBarNotifChips with PromotedNotificationUi" into main

parents fbf2c331 9f23c3ab
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -28,9 +28,9 @@ import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.notification.data.model.activeNotificationModel
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentBuilder
import com.android.systemui.testKosmos
import com.android.systemui.util.time.fakeSystemClock
@@ -41,7 +41,7 @@ import org.mockito.kotlin.mock

@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableFlags(StatusBarNotifChips.FLAG_NAME)
@EnableFlags(PromotedNotificationUi.FLAG_NAME)
class SingleNotificationChipInteractorTest : SysuiTestCase() {
    private val kosmos = testKosmos().useUnconfinedTestDispatcher()
    val factory = kosmos.singleNotificationChipInteractorFactory
+19 −19
Original line number Diff line number Diff line
@@ -29,13 +29,13 @@ import com.android.systemui.kosmos.collectValues
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.notification.data.model.activeNotificationModel
import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationsStore
import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository
import com.android.systemui.statusbar.notification.data.repository.addNotif
import com.android.systemui.statusbar.notification.data.repository.removeNotif
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentBuilder
import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel
import com.android.systemui.statusbar.notification.shared.CallType
@@ -55,7 +55,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        Kosmos.Fixture { statusBarNotificationChipsInteractor.also { it.start() } }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME)
    @DisableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_flagOff_noNotifs() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -74,7 +74,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_noNotifs_empty() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -85,7 +85,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME)
    fun allNotificationChips_notifMissingStatusBarChipIconView_cdFlagOff_empty() =
        kosmos.runTest {
@@ -105,7 +105,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME, StatusBarConnectedDisplays.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME, StatusBarConnectedDisplays.FLAG_NAME)
    fun allNotificationChips_notifMissingStatusBarChipIconView_cdFlagOn_notEmpty() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -124,7 +124,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_onePromotedNotif_statusBarIconViewMatches() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -146,7 +146,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_onlyForPromotedNotifs() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -181,7 +181,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_appVisibilityInfoCorrect() =
        kosmos.runTest {
            activityManagerRepository.fake.startingIsAppVisibleValue = false
@@ -215,7 +215,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {

    /** Regression test for b/388521980. */
    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_callNotifIsAlsoPromoted_callNotifExcluded() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -245,7 +245,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_notifUpdatesGoThrough() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -295,7 +295,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_promotedNotifDisappearsThenReappears() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -337,7 +337,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_sortedByFirstAppearanceTime() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -413,7 +413,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_lastAppVisibleTimeMaintainedAcrossNotifAddsAndRemoves() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -468,7 +468,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_sortedByLastAppVisibleTime() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -524,7 +524,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_newNotificationTakesPriorityOverLastAppVisible() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -580,7 +580,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_fullSort() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -695,7 +695,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun allNotificationChips_notifChangesKey() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.allNotificationChips)
@@ -733,7 +733,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun onPromotedNotificationChipTapped_emitsKeys() =
        kosmos.runTest {
            val latest by collectValues(underTest.promotedNotificationChipTapEvent)
@@ -750,7 +750,7 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    @EnableFlags(PromotedNotificationUi.FLAG_NAME)
    fun onPromotedNotificationChipTapped_sameKeyTwice_emitsTwice() =
        kosmos.runTest {
            val latest by collectValues(underTest.promotedNotificationChipTapEvent)
+2 −2
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.chips.call.ui.viewmodel.CallChipViewModelTest.Companion.createStatusBarIconViewOrNull
import com.android.systemui.statusbar.chips.notification.domain.interactor.statusBarNotificationChipsInteractor
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.chips.ui.model.ColorsModel
import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
@@ -46,6 +45,7 @@ import com.android.systemui.statusbar.notification.data.repository.ActiveNotific
import com.android.systemui.statusbar.notification.data.repository.UnconfinedFakeHeadsUpRowRepository
import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository
import com.android.systemui.statusbar.notification.headsup.PinnedStatus
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentBuilder
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.When
@@ -66,7 +66,7 @@ import org.mockito.kotlin.mock

@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableFlags(StatusBarNotifChips.FLAG_NAME)
@EnableFlags(PromotedNotificationUi.FLAG_NAME)
class NotifChipsViewModelTest : SysuiTestCase() {
    private val kosmos =
        testKosmos().useUnconfinedTestDispatcher().apply {
+3 −3
Original line number Diff line number Diff line
@@ -44,12 +44,12 @@ import com.android.systemui.screenrecord.data.repository.screenRecordRepository
import com.android.systemui.statusbar.chips.call.ui.viewmodel.CallChipViewModel
import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE
import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.chips.screenrecord.ui.viewmodel.ScreenRecordChipViewModel
import com.android.systemui.statusbar.chips.sharetoapp.ui.viewmodel.ShareToAppChipViewModel
import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.statusbar.phone.mockSystemUIDialogFactory
import com.android.systemui.statusbar.phone.ongoingcall.StatusBarChipsModernization
@@ -71,10 +71,10 @@ import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever

/** Tests for [OngoingActivityChipsViewModel] when the [StatusBarNotifChips] flag is disabled. */
/** Tests for [OngoingActivityChipsViewModel] when the [PromotedNotificationUi] flag is disabled. */
@SmallTest
@RunWith(AndroidJUnit4::class)
@DisableFlags(StatusBarNotifChips.FLAG_NAME)
@DisableFlags(PromotedNotificationUi.FLAG_NAME)
class OngoingActivityChipsViewModelTest : SysuiTestCase() {
    private val kosmos = testKosmos().useUnconfinedTestDispatcher()
    private val systemClock = kosmos.fakeSystemClock
+3 −3
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ import com.android.systemui.statusbar.chips.call.ui.viewmodel.CallChipViewModelT
import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE
import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection
import com.android.systemui.statusbar.chips.notification.domain.interactor.statusBarNotificationChipsInteractor
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.chips.notification.ui.viewmodel.NotifChipsViewModelTest.Companion.assertIsNotifChip
import com.android.systemui.statusbar.chips.screenrecord.ui.viewmodel.ScreenRecordChipViewModel
import com.android.systemui.statusbar.chips.ui.model.MultipleOngoingActivityChipsModel
@@ -64,6 +63,7 @@ import com.android.systemui.statusbar.notification.data.repository.activeNotific
import com.android.systemui.statusbar.notification.data.repository.addNotif
import com.android.systemui.statusbar.notification.data.repository.addNotifs
import com.android.systemui.statusbar.notification.data.repository.removeNotif
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentBuilder
import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel
import com.android.systemui.statusbar.phone.SystemUIDialog
@@ -85,10 +85,10 @@ import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever

// TODO(b/273205603): add tests for Active chips with hidden=true once actually used.
/** Tests for [OngoingActivityChipsViewModel] when the [StatusBarNotifChips] flag is enabled. */
/** Tests for [OngoingActivityChipsViewModel] when the [PromotedNotificationUi] flag is enabled. */
@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableFlags(StatusBarNotifChips.FLAG_NAME)
@EnableFlags(PromotedNotificationUi.FLAG_NAME)
class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() {
    private val kosmos = testKosmos().useUnconfinedTestDispatcher()
    private val systemClock = kosmos.fakeSystemClock
Loading