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

Commit 0c1e40f3 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Migrate bubbles test to kosmos (3/n)

Test: it's all tests
Bug: 395857098
Flag: EXEMPT test refactor
Change-Id: I63f4f1831e82a005eff29c09271e9aebfab3500b
parent f6ab114d
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ class ColorizedFgsCoordinatorTest : SysuiTestCase() {
                collectLastValue(promotedNotificationsInteractor.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|screenRecord|0")
                .containsExactly(screenRecordEntry.key)
                .inOrder()

            // THEN the entry is in the fgs section
@@ -233,7 +233,7 @@ class ColorizedFgsCoordinatorTest : SysuiTestCase() {
                collectLastValue(promotedNotificationsInteractor.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|screenRecord|0")
                .containsExactly(screenRecordEntry.key)
                .inOrder()

            // THEN the entry is NOT in the fgs section
@@ -262,7 +262,7 @@ class ColorizedFgsCoordinatorTest : SysuiTestCase() {
                collectLastValue(promotedNotificationsInteractor.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|screenRecord|0")
                .containsExactly(screenRecordEntry.key)
                .inOrder()

            // THEN the entry is NOT in the fgs section
@@ -322,8 +322,8 @@ class ColorizedFgsCoordinatorTest : SysuiTestCase() {
            // THEN the order of the notification keys should be the call then the RON
            assertThat(orderedChipNotificationKeys)
                .containsExactly(
                    "0|com.android.systemui.tests|0|call|0",
                    "0|com.android.systemui.tests|0|ron|0",
                    callEntry.key,
                    ronEntry.key,
                )

            // VERIFY that the comparator puts the call before the ron
+17 −20
Original line number Diff line number Diff line
@@ -85,8 +85,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            // THEN the call shouldn't be in the list
            assertThat(orderedChipNotificationKeys).containsExactly(
                "0|com.android.systemui.tests|0|ron|0")
            assertThat(orderedChipNotificationKeys).containsExactly(ronEntry.key)
        }

    @Test
@@ -107,8 +106,8 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
            // THEN the order of the notification keys should be the call then the RON
            assertThat(orderedChipNotificationKeys)
                .containsExactly(
                    "0|com.android.systemui.tests|0|call|0",
                    "0|com.android.systemui.tests|0|ron|0",
                    callEntry.key,
                    ronEntry.key,
                )
                .inOrder()
        }
@@ -163,7 +162,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|record|0")
                .containsExactly(screenRecordEntry.key)
                .inOrder()
        }

@@ -186,7 +185,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|record|0")
                .containsExactly(screenRecordEntry.key)
                .inOrder()
        }

@@ -209,7 +208,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|record|0")
                .containsExactly(screenRecordEntry.key)
                .inOrder()
        }

@@ -258,7 +257,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|recordFgs|0")
                .containsExactly(fgsEntry.key)
                .inOrder()
        }

@@ -285,7 +284,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|recordOngoing|0")
                .containsExactly(ongoingEntry.key)
                .inOrder()
        }

@@ -321,7 +320,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|recordBoth|0")
                .containsExactly(ongoingAndFgsEntry.key)
                .inOrder()
        }

@@ -385,7 +384,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|proj|0")
                .containsExactly(mediaProjEntry.key)
                .inOrder()
        }

@@ -409,7 +408,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|proj|0")
                .containsExactly(mediaProjEntry.key)
                .inOrder()
        }

@@ -433,7 +432,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|proj|0")
                .containsExactly(mediaProjEntry.key)
                .inOrder()
        }

@@ -484,7 +483,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|projFgs|0")
                .containsExactly(fgsEntry.key)
                .inOrder()
        }

@@ -512,7 +511,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|projOngoing|0")
                .containsExactly(ongoingEntry.key)
                .inOrder()
        }

@@ -549,7 +548,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.orderedChipNotificationKeys)

            assertThat(orderedChipNotificationKeys)
                .containsExactly("0|com.android.systemui.tests|0|projBoth|0")
                .containsExactly(ongoingAndFgsEntry.key)
                .inOrder()
        }

@@ -667,8 +666,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.aodPromotedNotification)

            // THEN the ron is first because the call has no content
            assertThat(topPromotedNotificationContent?.key)
                .isEqualTo("0|com.android.systemui.tests|0|ron|0")
            assertThat(topPromotedNotificationContent?.key).isEqualTo(ronEntry.key)
        }

    @Test
@@ -687,8 +685,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() {
                collectLastValue(underTest.aodPromotedNotification)

            // THEN the call is the top notification
            assertThat(topPromotedNotificationContent?.key)
                .isEqualTo("0|com.android.systemui.tests|0|call|0")
            assertThat(topPromotedNotificationContent?.key).isEqualTo(callEntry.key)
        }

    @Test
+0 −172
Original line number Diff line number Diff line
@@ -346,47 +346,6 @@ public class NotificationTestHelper {
        return generateRow(createNotification(), PKG, UID, USER_HANDLE, extraInflationFlags);
    }

    /**
     * Returns an {@link GroupEntry} group with the given number of child
     * notifications.
     */
    public GroupEntry createGroupEntry(int numChildren,
            @Nullable List<NotificationEntry> additionalChildren) {
        Notification summary = new Notification.Builder(mContext, "")
                .setSmallIcon(R.drawable.ic_person)
                .setGroupSummary(true)
                .setGroup(GROUP_KEY)
                .build();

        NotificationEntry summaryEntry = new NotificationEntryBuilder()
                .setPkg(PKG)
                .setOpPkg(PKG)
                .setId(mId++)
                .setUid(UID)
                .setInitialPid(2000)
                .setNotification(summary)
                .setUser(USER_HANDLE)
                .setParent(GroupEntry.ROOT_ENTRY)
                .build();
        GroupEntryBuilder groupEntry = new GroupEntryBuilder()
                .setSummary(summaryEntry);

        for (int i = 0; i < numChildren; i++) {
            NotificationEntry child = new NotificationEntryBuilder()
                    .setParent(GroupEntry.ROOT_ENTRY)
                    .setNotification(new Notification.Builder(mContext, "")
                            .setSmallIcon(R.drawable.ic_person)
                            .setGroup(GROUP_KEY)
                            .build())
                    .build();
            groupEntry.addChild(child);
        }
        for (NotificationEntry entry : additionalChildren) {
            groupEntry.addChild(entry);
        }
        return groupEntry.build();
    }

    /**
     * Returns an {@link ExpandableNotificationRow} group with the given number of child
     * notifications.
@@ -413,23 +372,6 @@ public class NotificationTestHelper {
        return createRow(PKG, UID, USER_HANDLE, false /* isGroupSummary */, groupkey);
    }

    /**
     * Returns an {@link ExpandableNotificationRow} that should be shown as a bubble.
     */
    public ExpandableNotificationRow createBubble()
            throws Exception {
        Notification n = createNotification(false /* isGroupSummary */,
                null /* groupKey */,
                makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */));
        n.flags |= FLAG_BUBBLE;
        ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE,
                mDefaultInflationFlags, IMPORTANCE_HIGH);
        modifyRanking(row.getEntry())
                .setCanBubble(true)
                .build();
        return row;
    }

    /**
     * Returns an {@link ExpandableNotificationRow} that shows as a sticky FSI HUN.
     */
@@ -443,120 +385,6 @@ public class NotificationTestHelper {
                mDefaultInflationFlags, IMPORTANCE_HIGH);
    }


    /**
     * Returns an {@link ExpandableNotificationRow} that should be shown as a bubble.
     */
    public ExpandableNotificationRow createShortcutBubble(String shortcutId)
            throws Exception {
        Notification n = createNotification(false /* isGroupSummary */,
                null /* groupKey */, makeShortcutBubbleMetadata(shortcutId));
        n.flags |= FLAG_BUBBLE;
        ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE,
                mDefaultInflationFlags, IMPORTANCE_HIGH);
        modifyRanking(row.getEntry())
                .setCanBubble(true)
                .build();
        return row;
    }

    /**
     * Returns an {@link NotificationEntry} that should be shown as a bubble and is part
     * of a group of notifications.
     */
    public NotificationEntry createBubbleEntryInGroup() throws Exception {
        Notification n = createNotification(false /* isGroupSummary */,
                GROUP_KEY /* groupKey */,
                makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */));
        n.flags |= FLAG_BUBBLE;
        NotificationEntry entry = generateEntry(n, PKG, UID, USER_HANDLE,
                mDefaultInflationFlags, IMPORTANCE_HIGH);
        modifyRanking(entry)
                .setCanBubble(true)
                .build();
        return entry;
    }

    /**
     * Returns an {@link ExpandableNotificationRow} that should be shown as a bubble and is part
     * of a group of notifications.
     */
    public ExpandableNotificationRow createBubbleInGroup()
            throws Exception {
        Notification n = createNotification(false /* isGroupSummary */,
                GROUP_KEY /* groupKey */,
                makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */));
        n.flags |= FLAG_BUBBLE;
        ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE,
                mDefaultInflationFlags, IMPORTANCE_HIGH);
        modifyRanking(row.getEntry())
                .setCanBubble(true)
                .build();
        return row;
    }

    /**
     * Returns an {@link NotificationEntry} that should be shown as a bubble.
     *
     * @param deleteIntent the intent to assign to {@link BubbleMetadata#deleteIntent}
     */
    public NotificationEntry createBubble(@Nullable PendingIntent deleteIntent) {
        return createBubble(makeBubbleMetadata(deleteIntent, false /* autoExpand */), USER_HANDLE);
    }

    /**
     * Returns an {@link NotificationEntry} that should be shown as a bubble.
     *
     * @param handle the user to associate with this bubble.
     */
    public NotificationEntry createBubble(UserHandle handle) {
        return createBubble(makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */),
                handle);
    }

    /**
     * Returns an {@link NotificationEntry} that should be shown as a auto-expanded bubble.
     */
    public NotificationEntry createAutoExpandedBubble() {
        return createBubble(makeBubbleMetadata(null /* deleteIntent */, true /* autoExpand */),
                USER_HANDLE);
    }

    /**
     * Returns an {@link NotificationEntry} that should be shown as a bubble.
     *
     * @param userHandle the user to associate with this notification.
     */
    private NotificationEntry createBubble(BubbleMetadata metadata, UserHandle userHandle) {
        Notification n = createNotification(false /* isGroupSummary */, null /* groupKey */,
                metadata);
        n.flags |= FLAG_BUBBLE;

        final NotificationChannel channel =
                new NotificationChannel(
                        n.getChannelId(),
                        n.getChannelId(),
                        IMPORTANCE_HIGH);
        channel.setBlockable(true);

        NotificationEntry entry = new NotificationEntryBuilder()
                .setPkg(PKG)
                .setOpPkg(PKG)
                .setId(mId++)
                .setUid(UID)
                .setInitialPid(2000)
                .setNotification(n)
                .setUser(userHandle)
                .setPostTime(System.currentTimeMillis())
                .setChannel(channel)
                .build();

        modifyRanking(entry)
                .setCanBubble(true)
                .build();
        return entry;
    }

    /**
     * Creates a notification row with the given details.
     *
+40 −44

File changed.

Preview size limit exceeded, changes collapsed.

+435 −313

File changed.

Preview size limit exceeded, changes collapsed.

Loading