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

Commit 2fc03028 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge changes I7de89c98,Ie84f0824,I2a244c27 into main

* changes:
  [SB] Remove "phone" from call chip content description.
  [SB][Notif] Only hide `when` in chip if notif was automatically promoted
  [SB][Notif] Hide the second chip if it doesn't fit.
parents ee1835d1 045245cb
Loading
Loading
Loading
Loading
+32 −1
Original line number Diff line number Diff line
@@ -306,12 +306,13 @@ class NotifChipsViewModelTest : SysuiTestCase() {

    @Test
    @EnableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY)
    fun chips_basicTime_hiddenIfAutomaticallyPromoted() =
    fun chips_basicTime_timeHiddenIfAutomaticallyPromoted() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chips)

            val promotedContentBuilder =
                PromotedNotificationContentModel.Builder("notif").apply {
                    this.wasPromotedAutomatically = true
                    this.time =
                        PromotedNotificationContentModel.When(
                            time = 6543L,
@@ -333,6 +334,36 @@ class NotifChipsViewModelTest : SysuiTestCase() {
                .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java)
        }

    @Test
    @EnableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY)
    fun chips_basicTime_timeShownIfNotAutomaticallyPromoted() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chips)

            val promotedContentBuilder =
                PromotedNotificationContentModel.Builder("notif").apply {
                    this.wasPromotedAutomatically = false
                    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.ShortTimeDelta::class.java)
        }

    @Test
    @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY)
    fun chips_basicTime_isShortTimeDelta() =
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ class ChipBackgroundContainerTest : SysuiTestCase() {
        allowTestableLooperAsMainThread()
        TestableLooper.get(this).runWithLooper {
            val chipView =
                LayoutInflater.from(context).inflate(R.layout.ongoing_activity_chip, null)
                LayoutInflater.from(context).inflate(R.layout.ongoing_activity_chip_primary, null)
            underTest = chipView.requireViewById(R.id.ongoing_activity_chip_background)
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ class ChipChronometerTest : SysuiTestCase() {
        allowTestableLooperAsMainThread()
        TestableLooper.get(this).runWithLooper {
            val chipView =
                LayoutInflater.from(mContext).inflate(R.layout.ongoing_activity_chip, null)
                LayoutInflater.from(mContext).inflate(R.layout.ongoing_activity_chip_primary, null)
            textView = chipView.findViewById(R.id.ongoing_activity_chip_time)!!
            measureTextView()
            calculateDoesNotFixText()
@@ -161,7 +161,7 @@ class ChipChronometerTest : SysuiTestCase() {
    private fun measureTextView() {
        textView.measure(
            View.MeasureSpec.makeMeasureSpec(TEXT_VIEW_MAX_WIDTH, View.MeasureSpec.AT_MOST),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
        )
    }

+21 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder
import com.android.systemui.statusbar.notification.promoted.AutomaticPromotionCoordinator.Companion.EXTRA_WAS_AUTOMATICALLY_PROMOTED
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.Style
import com.android.systemui.testKosmos
@@ -108,6 +109,26 @@ class PromotedNotificationContentExtractorImplTest : SysuiTestCase() {
        assertThat(content?.text).isEqualTo(TEST_CONTENT_TEXT)
    }

    @Test
    @EnableFlags(PromotedNotificationUi.FLAG_NAME, StatusBarNotifChips.FLAG_NAME)
    fun extractContent_wasPromotedAutomatically_false() {
        val entry = createEntry { extras.putBoolean(EXTRA_WAS_AUTOMATICALLY_PROMOTED, false) }

        val content = extractContent(entry)

        assertThat(content!!.wasPromotedAutomatically).isFalse()
    }

    @Test
    @EnableFlags(PromotedNotificationUi.FLAG_NAME, StatusBarNotifChips.FLAG_NAME)
    fun extractContent_wasPromotedAutomatically_true() {
        val entry = createEntry { extras.putBoolean(EXTRA_WAS_AUTOMATICALLY_PROMOTED, true) }

        val content = extractContent(entry)

        assertThat(content!!.wasPromotedAutomatically).isTrue()
    }

    @Test
    @EnableFlags(PromotedNotificationUi.FLAG_NAME, StatusBarNotifChips.FLAG_NAME)
    @DisableFlags(android.app.Flags.FLAG_API_RICH_ONGOING)
+3 −2
Original line number Diff line number Diff line
@@ -114,7 +114,8 @@ class OngoingCallControllerViaListenerTest : SysuiTestCase() {
    fun setUp() {
        allowTestableLooperAsMainThread()
        TestableLooper.get(this).runWithLooper {
            chipView = LayoutInflater.from(mContext).inflate(R.layout.ongoing_activity_chip, null)
            chipView =
                LayoutInflater.from(mContext).inflate(R.layout.ongoing_activity_chip_primary, null)
        }

        MockitoAnnotations.initMocks(this)
@@ -498,7 +499,7 @@ class OngoingCallControllerViaListenerTest : SysuiTestCase() {
        lateinit var newChipView: View
        TestableLooper.get(this).runWithLooper {
            newChipView =
                LayoutInflater.from(mContext).inflate(R.layout.ongoing_activity_chip, null)
                LayoutInflater.from(mContext).inflate(R.layout.ongoing_activity_chip_primary, null)
        }

        // Change the chip view associated with the controller.
Loading