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

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

Merge "[Notifs] Replace `isPinned` boolean with a 3-option enum instead." into main

parents e989e21c 452a1f26
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -2861,9 +2861,7 @@ class SceneContainerStartableTest : SysuiTestCase() {
        )

    private fun fakeHeadsUpRowRepository(key: String, isPinned: Boolean) =
        FakeHeadsUpRowRepository(key = key, elementKey = Any()).apply {
            this.isPinned.value = isPinned
        }
        FakeHeadsUpRowRepository(key = key, elementKey = Any(), isPinned = isPinned)

    private fun setFingerprintSensorType(fingerprintSensorType: FingerprintSensorType) {
        kosmos.fingerprintPropertyRepository.setProperties(
+4 −4
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.app.Notification
import android.app.NotificationManager.IMPORTANCE_DEFAULT
import android.app.NotificationManager.IMPORTANCE_LOW
import android.platform.test.annotations.EnableFlags
import android.provider.Settings
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
@@ -43,6 +42,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.No
import com.android.systemui.statusbar.notification.data.repository.FakeHeadsUpRowRepository
import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository
import com.android.systemui.statusbar.notification.domain.interactor.lockScreenNotificationMinimalismSetting
import com.android.systemui.statusbar.notification.headsup.PinnedStatus
import com.android.systemui.statusbar.notification.shared.NotificationMinimalism
import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository
import com.android.systemui.testKosmos
@@ -394,7 +394,7 @@ class LockScreenMinimalismCoordinatorTest : SysuiTestCase() {
            assertThatTopUnseenKey().isEqualTo(solo1.key)

            // TEST: even being pinned doesn't take effect immediately
            hunRepo1.isPinned.value = true
            hunRepo1.pinnedStatus.value = PinnedStatus.PinnedBySystem
            testScheduler.advanceTimeBy(0.5.seconds)
            onBeforeTransformGroupsListener.onBeforeTransformGroups(listEntryList)
            assertThatTopUnseenKey().isEqualTo(solo1.key)
@@ -406,8 +406,8 @@ class LockScreenMinimalismCoordinatorTest : SysuiTestCase() {

            // TEST: repeat; being heads up and pinned for 1 second triggers seen
            kosmos.headsUpNotificationRepository.orderedHeadsUpRows.value = listOf(hunRepo2)
            hunRepo1.isPinned.value = false
            hunRepo2.isPinned.value = true
            hunRepo1.pinnedStatus.value = PinnedStatus.NotPinned
            hunRepo2.pinnedStatus.value = PinnedStatus.PinnedBySystem
            testScheduler.advanceTimeBy(1.seconds)
            onBeforeTransformGroupsListener.onBeforeTransformGroups(listEntryList)
            assertThatTopUnseenKey().isEqualTo(null)
+35 −14
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.systemui.kosmos.testScope
import com.android.systemui.shade.shadeTestUtil
import com.android.systemui.statusbar.notification.data.repository.FakeHeadsUpRowRepository
import com.android.systemui.statusbar.notification.data.repository.notificationsKeyguardViewStateRepository
import com.android.systemui.statusbar.notification.headsup.PinnedStatus
import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository
import com.android.systemui.statusbar.notification.stack.domain.interactor.headsUpNotificationInteractor
import com.android.systemui.testKosmos
@@ -102,7 +103,7 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
        }

    @Test
    fun hasPinnedRows_rowGetsPinned_true() =
    fun hasPinnedRows_rowGetsPinnedNormally_true() =
        testScope.runTest {
            val hasPinnedRows by collectLastValue(underTest.hasPinnedRows)
            // GIVEN no rows are pinned
@@ -115,8 +116,30 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            headsUpRepository.setNotifications(rows)
            runCurrent()

            // WHEN a row gets pinned
            rows[0].isPinned.value = true
            // WHEN a row gets pinned normally
            rows[0].pinnedStatus.value = PinnedStatus.PinnedBySystem
            runCurrent()

            // THEN hasPinnedRows updates to true
            assertThat(hasPinnedRows).isTrue()
        }

    @Test
    fun hasPinnedRows_rowGetsPinnedByUser_true() =
        testScope.runTest {
            val hasPinnedRows by collectLastValue(underTest.hasPinnedRows)
            // GIVEN no rows are pinned
            val rows =
                arrayListOf(
                    fakeHeadsUpRowRepository("key 0"),
                    fakeHeadsUpRowRepository("key 1"),
                    fakeHeadsUpRowRepository("key 2"),
                )
            headsUpRepository.setNotifications(rows)
            runCurrent()

            // WHEN a row gets pinned due to a chip tap
            rows[0].pinnedStatus.value = PinnedStatus.PinnedByUser
            runCurrent()

            // THEN hasPinnedRows updates to true
@@ -138,7 +161,7 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            runCurrent()

            // THEN that row gets unpinned
            rows[0].isPinned.value = false
            rows[0].pinnedStatus.value = PinnedStatus.NotPinned
            runCurrent()

            // THEN hasPinnedRows updates to false
@@ -246,7 +269,7 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            runCurrent()

            // WHEN all rows gets pinned
            rows[2].isPinned.value = true
            rows[2].pinnedStatus.value = PinnedStatus.PinnedBySystem
            runCurrent()

            // THEN no rows are filtered
@@ -271,7 +294,7 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            assertThat(activeHeadsUpRows).containsExactly(rows[0], rows[1], rows[2])

            // WHEN all rows gets pinned
            rows[2].isPinned.value = true
            rows[2].pinnedStatus.value = PinnedStatus.PinnedBySystem
            runCurrent()

            // THEN no change
@@ -329,7 +352,7 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            runCurrent()

            // WHEN a row gets unpinned
            rows[0].isPinned.value = false
            rows[0].pinnedStatus.value = PinnedStatus.NotPinned
            runCurrent()

            // THEN the unpinned row is filtered
@@ -351,7 +374,7 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            runCurrent()

            // WHEN a row gets unpinned
            rows[0].isPinned.value = false
            rows[0].pinnedStatus.value = PinnedStatus.NotPinned
            runCurrent()

            // THEN all rows are still present
@@ -372,15 +395,15 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            headsUpRepository.setNotifications(rows)
            runCurrent()

            rows[0].isPinned.value = true
            rows[0].pinnedStatus.value = PinnedStatus.PinnedBySystem
            runCurrent()
            assertThat(pinnedHeadsUpRows).containsExactly(rows[0])

            rows[0].isPinned.value = false
            rows[0].pinnedStatus.value = PinnedStatus.NotPinned
            runCurrent()
            assertThat(pinnedHeadsUpRows).isEmpty()

            rows[0].isPinned.value = true
            rows[0].pinnedStatus.value = PinnedStatus.PinnedBySystem
            runCurrent()
            assertThat(pinnedHeadsUpRows).containsExactly(rows[0])
        }
@@ -485,7 +508,5 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
        }

    private fun fakeHeadsUpRowRepository(key: String, isPinned: Boolean = false) =
        FakeHeadsUpRowRepository(key = key, elementKey = Any()).apply {
            this.isPinned.value = isPinned
        }
        FakeHeadsUpRowRepository(key = key, isPinned = isPinned)
}
+3 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;

import kotlinx.coroutines.flow.StateFlowKt;
import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
import platform.test.runner.parameterized.Parameters;

@@ -318,6 +319,8 @@ public class HeadsUpManagerImplTest extends SysuiTestCase {
                mContext);
        final HeadsUpManagerImpl.HeadsUpEntry headsUpEntry = mock(
                HeadsUpManagerImpl.HeadsUpEntry.class);
        when(headsUpEntry.getPinnedStatus())
                .thenReturn(StateFlowKt.MutableStateFlow(PinnedStatus.NotPinned));
        headsUpEntry.mEntry = notifEntry;

        hum.onEntryRemoved(headsUpEntry, "test");
+2 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.statusbar.notification.headsup.PinnedStatus;
import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger;
import com.android.systemui.statusbar.notification.headsup.HeadsUpManager;

@@ -91,7 +92,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase {
        ExpandableNotificationRowDragController controller = createSpyController();
        mRow.setDragController(controller);
        mRow.setHeadsUp(true);
        mRow.setPinned(true);
        mRow.setPinnedStatus(PinnedStatus.PinnedBySystem);

        mRow.doLongClickCallback(0, 0);
        mRow.doDragCallback(0, 0);
Loading