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

Commit 0ba6543e authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB][Notif] Keep main status bar visible if notif chip was tapped.

Typically, when a HUN is shown, the status bar updates to show just the
HUN icon and app name, and hides everything else (status bar chips and
clock are hidden).

However, when a user taps a status bar notification chip, we show that
notifications's HUN but we want the status bar behavior to be different:
We should keep the status bar chip and clock *visible* and *not* show
the HUN icon or app name.

This CL makes that change by:
1) Have HeadsUpCoordinator pass the requested PinnedStatus to
   HeadsUpManager
2) Have HeadsUpAppearanceController use the PinnedStatus to adjust
   behavior (used if status_bar_root_modernization flag is off)
3) Have HomeStatusBarViewModel also use the PinnedStatus to adjust
   behavior (used if status_bar_root_modernization flag is on)

Bug: 364653005
Flag: com.android.systemui.status_bar_notification_chips

Test: Trigger normal HUN on homescreen -> verify HUN app icon and app
name shows in status bar and nothing else
Test: Trigger normal HUN on lockscreen with bypass -> verify HUN app
icon and app name shows in status bar
Test: Trigger status bar notification chip then tap it -> verify status
bar shows clock and notification chip without text in the chip, verify
app name is *not* shown
Test: With status_bar_root_modernization_flag on, verify the same

Test: atest HeadsUpManagerTest HeadsUpCoordinatorTest
HeadsUpAppearanceControllerTest

Change-Id: Ia7710db69b44635d84648ea0d7c3e903a1686a2d
parent 003da44f
Loading
Loading
Loading
Loading
+61 −1
Original line number Diff line number Diff line
@@ -22,8 +22,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.testScope
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.chips.notification.domain.interactor.statusBarNotificationChipsInteractor
@@ -32,12 +35,16 @@ import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
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.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.shared.model.PromotedNotificationContentModel
import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel
import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlin.test.Test
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.runner.RunWith
@@ -47,7 +54,12 @@ import org.mockito.kotlin.mock
@RunWith(AndroidJUnit4::class)
@EnableFlags(StatusBarNotifChips.FLAG_NAME)
class NotifChipsViewModelTest : SysuiTestCase() {
    private val kosmos = testKosmos().useUnconfinedTestDispatcher()
    private val kosmos =
        testKosmos().useUnconfinedTestDispatcher().apply {
            // Don't be in lockscreen so that HUNs are allowed
            fakeKeyguardTransitionRepository =
                FakeKeyguardTransitionRepository(initInLockscreen = false, testScope = testScope)
        }
    private val activeNotificationListRepository = kosmos.activeNotificationListRepository

    private val underTest by lazy { kosmos.notifChipsViewModel }
@@ -198,6 +210,54 @@ class NotifChipsViewModelTest : SysuiTestCase() {
            assertIsNotifKey(latest!![1], secondKey)
        }

    @Test
    fun chips_noHeadsUp_showsTime() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chips)
            setNotifs(
                listOf(
                    activeNotificationModel(
                        key = "notif",
                        statusBarChipIcon = mock<StatusBarIconView>(),
                        promotedContent = PromotedNotificationContentModel.Builder("notif").build(),
                    )
                )
            )

            // WHEN there's no HUN
            kosmos.headsUpNotificationRepository.setNotifications(emptyList())

            // THEN the chip shows the time
            assertThat(latest!![0])
                .isInstanceOf(OngoingActivityChipModel.Shown.ShortTimeDelta::class.java)
        }

    @Test
    fun chips_hasHeadsUpByUser_onlyShowsIcon() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chips)
            setNotifs(
                listOf(
                    activeNotificationModel(
                        key = "notif",
                        statusBarChipIcon = mock<StatusBarIconView>(),
                        promotedContent = PromotedNotificationContentModel.Builder("notif").build(),
                    )
                )
            )

            // WHEN there's a HUN pinned by a user
            kosmos.headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "notif",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedByUser),
                )
            )

            assertThat(latest!![0])
                .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java)
        }

    @Test
    fun chips_clickingChipNotifiesInteractor() =
        kosmos.runTest {
+74 −75
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ import com.android.systemui.statusbar.notification.interruption.NotificationInte
import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderWrapper.DecisionImpl
import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderWrapper.FullScreenIntentDecisionImpl
import com.android.systemui.statusbar.notification.interruption.VisualInterruptionDecisionProvider
import com.android.systemui.statusbar.notification.row.NotifBindPipeline.BindCallback
import com.android.systemui.statusbar.phone.NotificationGroupTestHelper
import com.android.systemui.testKosmos
import com.android.systemui.util.concurrency.FakeExecutor
@@ -76,6 +75,7 @@ import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when` as whenever
import org.mockito.MockitoAnnotations
import org.mockito.kotlin.argumentCaptor

@SmallTest
@RunWith(AndroidJUnit4::class)
@@ -315,7 +315,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

        // WHEN the notification is added but not yet binding
        collectionListener.onEntryAdded(entry)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(entry), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(entry), any(), any())

        // THEN only promote mEntry
        assertTrue(notifPromoter.shouldPromoteToTopLevel(entry))
@@ -330,7 +330,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        collectionListener.onEntryAdded(entry)
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(entry))
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))
        verify(headsUpViewBinder).bindHeadsUpView(eq(entry), any())
        verify(headsUpViewBinder).bindHeadsUpView(eq(entry), eq(false), any())

        // THEN only promote mEntry
        assertTrue(notifPromoter.shouldPromoteToTopLevel(entry))
@@ -382,11 +382,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        collectionListener.onEntryAdded(entry)
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(entry))
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))
        verify(headsUpManager, never()).showNotification(entry)
        withArgCaptor<BindCallback> {
                verify(headsUpViewBinder).bindHeadsUpView(eq(entry), capture())
            }
            .onBindFinished(entry)

        finishBind(entry)

        // THEN we tell the HeadsUpManager to show the notification
        verify(headsUpManager).showNotification(entry)
@@ -401,8 +398,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))

        // THEN we never bind the heads up view or tell HeadsUpManager to show the notification
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(entry), any())
        verify(headsUpManager, never()).showNotification(entry)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(entry), any(), any())
        verify(headsUpManager, never()).showNotification(eq(entry), any())
    }

    @Test
@@ -435,8 +432,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))

        // THEN the notification is never bound or shown
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpManager, never()).showNotification(any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        verify(headsUpManager, never()).showNotification(any(), any())
    }

    @Test
@@ -471,7 +468,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
            beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))

            finishBind(entry)
            verify(headsUpManager).showNotification(entry)
            verify(headsUpManager).showNotification(entry, isPinnedByUser = true)
        }

    @Test
@@ -485,8 +482,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
            executor.runAllReady()
            beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))

            verify(headsUpViewBinder, never()).bindHeadsUpView(eq(entry), any())
            verify(headsUpManager, never()).showNotification(entry)
            verify(headsUpViewBinder, never()).bindHeadsUpView(eq(entry), any(), any())
            verify(headsUpManager, never()).showNotification(eq(entry), any())
        }

    @Test
@@ -509,7 +506,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

            // THEN it's still shown as heads up
            finishBind(entry)
            verify(headsUpManager).showNotification(entry)
            verify(headsUpManager).showNotification(entry, isPinnedByUser = true)
        }

    @Test
@@ -525,8 +522,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
            beforeTransformGroupsListener.onBeforeTransformGroups(listOf(promotedEntry))
            beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(promotedEntry))

            verify(headsUpViewBinder, never()).bindHeadsUpView(eq(promotedEntry), any())
            verify(headsUpManager, never()).showNotification(promotedEntry)
            verify(headsUpViewBinder, never()).bindHeadsUpView(eq(promotedEntry), any(), any())
            verify(headsUpManager, never()).showNotification(eq(promotedEntry), any())

            // Then a new notification comes in that should be heads up
            setShouldHeadsUp(entry, false)
@@ -544,10 +541,10 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

            // THEN the promoted entry is shown as a HUN, *not* the new entry
            finishBind(promotedEntry)
            verify(headsUpManager).showNotification(promotedEntry)
            verify(headsUpManager).showNotification(promotedEntry, isPinnedByUser = true)

            verify(headsUpViewBinder, never()).bindHeadsUpView(eq(entry), any())
            verify(headsUpManager, never()).showNotification(entry)
            verify(headsUpViewBinder, never()).bindHeadsUpView(eq(entry), any(), any())
            verify(headsUpManager, never()).showNotification(eq(entry), any())
        }

    @Test
@@ -558,10 +555,10 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        collectionListener.onEntryAdded(groupSummary)
        collectionListener.onEntryAdded(groupSibling1)
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(groupSibling1))
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(groupSibling1))

        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any(), any())
        finishBind(groupSibling1)

        verify(headsUpManager, never()).showNotification(groupSummary)
@@ -580,10 +577,10 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        collectionListener.onEntryAdded(groupSummary)
        collectionListener.onEntryAdded(groupChild1)
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(groupChild1))
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(groupChild1))

        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any(), any())
        finishBind(groupChild1)

        verify(headsUpManager, never()).showNotification(groupSummary)
@@ -603,12 +600,12 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        collectionListener.onEntryAdded(groupSibling2)
        val entryList = listOf(groupSibling1, groupSibling2)
        beforeTransformGroupsListener.onBeforeTransformGroups(entryList)
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(entryList)

        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any(), any())
        finishBind(groupSibling1)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any(), any())

        // THEN we tell the HeadsUpManager to show the notification
        verify(headsUpManager, never()).showNotification(groupSummary)
@@ -629,12 +626,12 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        collectionListener.onEntryAdded(groupChild2)
        val entryList = listOf(groupChild1, groupChild2)
        beforeTransformGroupsListener.onBeforeTransformGroups(entryList)
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(entryList)

        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any(), any())
        finishBind(groupChild1)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupChild2), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupChild2), any(), any())

        // THEN we tell the HeadsUpManager to show the notification
        verify(headsUpManager, never()).showNotification(groupSummary)
@@ -661,7 +658,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
                .setChildren(listOf(groupSibling1, groupPriority, groupSibling2))
                .build()
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(beforeTransformGroup))
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())

        val afterTransformGroup =
            GroupEntryBuilder()
@@ -672,10 +669,10 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
            listOf(groupPriority, afterTransformGroup)
        )

        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any(), any())
        finishBind(groupPriority)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling1), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling1), any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any(), any())

        // THEN we tell the HeadsUpManager to show the notification
        verify(headsUpManager, never()).showNotification(groupSummary)
@@ -702,7 +699,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
                .setChildren(listOf(groupSibling1, groupPriority, groupSibling2))
                .build()
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(beforeTransformGroup))
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())

        val afterTransformGroup =
            GroupEntryBuilder()
@@ -713,10 +710,10 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
            listOf(groupPriority, afterTransformGroup)
        )

        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any(), any())
        finishBind(groupPriority)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling1), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling1), any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any(), any())

        verify(headsUpManager, never()).showNotification(groupSummary)
        verify(headsUpManager).showNotification(groupPriority)
@@ -740,7 +737,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
                .setChildren(listOf(groupSibling1, groupPriority, groupSibling2))
                .build()
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(beforeTransformGroup))
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())

        val afterTransformGroup =
            GroupEntryBuilder()
@@ -751,10 +748,10 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
            listOf(groupPriority, afterTransformGroup)
        )

        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any(), any())
        finishBind(groupPriority)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling1), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling1), any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any(), any())

        verify(headsUpManager, never()).showNotification(groupSummary)
        verify(headsUpManager).showNotification(groupPriority)
@@ -779,7 +776,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
                .setChildren(listOf(groupSibling1, groupPriority, groupSibling2))
                .build()
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(beforeTransformGroup))
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())

        val afterTransformGroup =
            GroupEntryBuilder()
@@ -791,9 +788,9 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        )

        finishBind(groupSummary)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupPriority), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling1), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupPriority), any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling1), any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any(), any())

        verify(headsUpManager).showNotification(groupSummary)
        verify(headsUpManager, never()).showNotification(groupPriority)
@@ -816,12 +813,12 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
                .setChildren(listOf(groupSibling1, groupSibling2))
                .build()
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(groupEntry))
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(groupEntry))

        finishBind(groupSummary)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling1), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling1), any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSibling2), any(), any())

        verify(headsUpManager).showNotification(groupSummary)
        verify(headsUpManager, never()).showNotification(groupSibling1)
@@ -842,12 +839,12 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
                .setChildren(listOf(groupChild1, groupChild2))
                .build()
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(groupEntry))
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(groupEntry))

        finishBind(groupSummary)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupChild1), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupChild2), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupChild1), any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupChild2), any(), any())

        verify(headsUpManager).showNotification(groupSummary)
        verify(headsUpManager, never()).showNotification(groupChild1)
@@ -871,12 +868,12 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
                .setChildren(listOf(groupChild1, groupChild2))
                .build()
        beforeTransformGroupsListener.onBeforeTransformGroups(listOf(groupEntry))
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(groupEntry))

        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any(), any())
        finishBind(groupChild1)
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupChild2), any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupChild2), any(), any())

        verify(headsUpManager, never()).showNotification(groupSummary)
        verify(headsUpManager).showNotification(groupChild1)
@@ -900,7 +897,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

        // THEN the notification is shown
        finishBind(entry)
        verify(headsUpManager).showNotification(entry)
        verify(headsUpManager).showNotification(entry, isPinnedByUser = false)
    }

    @Test
@@ -917,8 +914,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))

        // THEN the notification is never bound or shown
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpManager, never()).showNotification(any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        verify(headsUpManager, never()).showNotification(any(), any())
    }

    @Test
@@ -938,7 +935,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

        // THEN the notification is shown
        finishBind(entry)
        verify(headsUpManager).showNotification(entry)
        verify(headsUpManager).showNotification(entry, isPinnedByUser = false)
    }

    @Test
@@ -958,8 +955,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))

        // THEN the notification is never bound or shown
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpManager, never()).showNotification(any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        verify(headsUpManager, never()).showNotification(any(), any())
    }

    @Test
@@ -1022,8 +1019,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

        // THEN it should full screen and log but it should NOT HUN
        verify(launchFullScreenIntentProvider).launchFullScreenIntent(entry)
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpManager, never()).showNotification(any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        verify(headsUpManager, never()).showNotification(any(), any())
        verifyLoggedFullScreenIntentDecision(
            entry,
            FullScreenIntentDecision.FSI_DEVICE_NOT_INTERACTIVE,
@@ -1063,8 +1060,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

        // THEN it should still not yet full screen or HUN
        verify(launchFullScreenIntentProvider, never()).launchFullScreenIntent(any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpManager, never()).showNotification(any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        verify(headsUpManager, never()).showNotification(any(), any())

        // Same decision as before; is not logged
        verifyNoFullScreenIntentDecisionLogged()
@@ -1080,8 +1077,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

        // THEN it should full screen and log but it should NOT HUN
        verify(launchFullScreenIntentProvider).launchFullScreenIntent(entry)
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpManager, never()).showNotification(any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        verify(headsUpManager, never()).showNotification(any(), any())
        verifyLoggedFullScreenIntentDecision(
            entry,
            FullScreenIntentDecision.FSI_DEVICE_NOT_INTERACTIVE,
@@ -1107,8 +1104,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

        // THEN it should NOT full screen or HUN
        verify(launchFullScreenIntentProvider, never()).launchFullScreenIntent(any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any())
        verify(headsUpManager, never()).showNotification(any())
        verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any(), any())
        verify(headsUpManager, never()).showNotification(any(), any())

        // NOW the DND logic changes and FSI and HUN are available
        clearInvocations(launchFullScreenIntentProvider)
@@ -1121,7 +1118,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
        // VERIFY that the FSI didn't happen, but that we do HUN
        verify(launchFullScreenIntentProvider, never()).launchFullScreenIntent(any())
        finishBind(entry)
        verify(headsUpManager).showNotification(entry)
        verify(headsUpManager).showNotification(entry, isPinnedByUser = false)
    }

    @Test
@@ -1206,10 +1203,12 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
    }

    private fun finishBind(entry: NotificationEntry) {
        verify(headsUpManager, never()).showNotification(entry)
        withArgCaptor<BindCallback> {
                verify(headsUpViewBinder).bindHeadsUpView(eq(entry), capture())
        verify(headsUpManager, never()).showNotification(eq(entry), any())
        val isPinnedByUserCaptor = argumentCaptor<Boolean>()
        withArgCaptor<HeadsUpViewBinder.HeadsUpBindCallback> {
                verify(headsUpViewBinder)
                    .bindHeadsUpView(eq(entry), isPinnedByUserCaptor.capture(), capture())
            }
            .onBindFinished(entry)
            .onHeadsUpBindFinished(entry, isPinnedByUserCaptor.firstValue)
    }
}
Loading