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

Commit 8a9a1f99 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix suppressing dot from BubbleMetadata suppress dot"

parents 44b7505d b25f9065
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -297,7 +297,9 @@ class Bubble {
     * Whether the bubble for this notification should show a dot indicating updated content.
     */
    boolean showDot() {
        return mShowBubbleUpdateDot && !mEntry.shouldSuppressNotificationDot();
        return mShowBubbleUpdateDot
                && !mEntry.shouldSuppressNotificationDot()
                && !shouldSuppressNotification();
    }

    /**
@@ -305,6 +307,7 @@ class Bubble {
     */
    boolean showFlyout() {
        return !mSuppressFlyout && !mEntry.shouldSuppressPeek()
                && !shouldSuppressNotification()
                && !mEntry.shouldSuppressNotificationList();
    }

+25 −11
Original line number Diff line number Diff line
@@ -479,7 +479,7 @@ public class BubbleControllerTest extends SysuiTestCase {
    }

    @Test
    public void testAutoExpand_FailsNotForeground() {
    public void testAutoExpand_fails_noFlag() {
        assertFalse(mBubbleController.isStackExpanded());
        setMetadataFlags(mRow.getEntry(),
                Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, false /* enableFlag */);
@@ -498,7 +498,7 @@ public class BubbleControllerTest extends SysuiTestCase {
    }

    @Test
    public void testAutoExpand_SucceedsForeground() {
    public void testAutoExpand_succeeds_withFlag() {
        setMetadataFlags(mRow.getEntry(),
                Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, true /* enableFlag */);

@@ -516,38 +516,52 @@ public class BubbleControllerTest extends SysuiTestCase {
    }

    @Test
    public void testSuppressNotif_FailsNotForeground() {
    public void testSuppressNotif_onInitialNotif() {
        setMetadataFlags(mRow.getEntry(),
                Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, false /* enableFlag */);
                Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, true /* enableFlag */);

        // Add the suppress notif bubble
        mEntryListener.onPendingEntryAdded(mRow.getEntry());
        mBubbleController.updateBubble(mRow.getEntry());

        // Should not be suppressed because we weren't forground
        assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(
        // Notif should be suppressed because we were foreground
        assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(
                mRow.getEntry().getKey()));
        // Dot + flyout is hidden because notif is suppressed
        assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showDot());
        assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showFlyout());

        // # of bubbles should change
        verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */);
    }

    @Test
    public void testSuppressNotif_SucceedsForeground() {
    public void testSuppressNotif_onUpdateNotif() {
        mBubbleController.updateBubble(mRow.getEntry());

        // Should not be suppressed
        assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(
                mRow.getEntry().getKey()));
        // Should show dot
        assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showDot());

        // Update to suppress notif
        setMetadataFlags(mRow.getEntry(),
                Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, true /* enableFlag */);

        // Add the suppress notif bubble
        mEntryListener.onPendingEntryAdded(mRow.getEntry());
        mBubbleController.updateBubble(mRow.getEntry());

        // Notif should be suppressed because we were foreground
        // Notif should be suppressed
        assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(
                mRow.getEntry().getKey()));
        // Dot + flyout is hidden because notif is suppressed
        assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showDot());
        assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showFlyout());

        // # of bubbles should change
        verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */);
    }


    @Test
    public void testExpandStackAndSelectBubble_removedFirst() {
        final String key = mRow.getEntry().getKey();
+17 −30
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.systemui.bubbles.BubbleData.TimeSource;
import com.android.systemui.statusbar.NotificationEntryBuilder;
import com.android.systemui.statusbar.NotificationTestHelper;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;

import com.google.common.collect.ImmutableList;

@@ -119,7 +120,9 @@ public class BubbleDataTest extends SysuiTestCase {
                .setVisuallyInterruptive(true)
                .build();

        ExpandableNotificationRow row = mNotificationTestHelper.createBubble();
        mEntryDismissed = createBubbleEntry(1, "dismissed", "package.d");
        mEntryDismissed.setRow(row);

        mBubbleA1 = new Bubble(mContext, mEntryA1);
        mBubbleA2 = new Bubble(mContext, mEntryA2);
@@ -192,9 +195,8 @@ public class BubbleDataTest extends SysuiTestCase {
        mBubbleData.setListener(mListener);

        // Test
        mBubbleData.notificationEntryUpdated(mEntryInterruptive, /* suppressFlyout */
                false, /* showInShade */
                true);
        mBubbleData.notificationEntryUpdated(mEntryInterruptive,
                false /* suppressFlyout */, true  /* showInShade */);

        // Verify
        verifyUpdateReceived();
@@ -208,12 +210,12 @@ public class BubbleDataTest extends SysuiTestCase {
        mBubbleData.setListener(mListener);

        // Test
        mBubbleData.notificationEntryUpdated(mEntryC1, /* suppressFlyout */ false, /* showInShade */
                true);
        mBubbleData.notificationEntryUpdated(mEntryC1, false /* suppressFlyout */,
                true /* showInShade */);
        verifyUpdateReceived();

        mBubbleData.notificationEntryUpdated(mEntryC1, /* suppressFlyout */ false, /* showInShade */
                true);
        mBubbleData.notificationEntryUpdated(mEntryC1, false /* suppressFlyout */,
                true /* showInShade */);
        verifyUpdateReceived();

        // Verify
@@ -225,16 +227,18 @@ public class BubbleDataTest extends SysuiTestCase {
    public void sameUpdate_NotInShade_showFlyout() {
        // Setup
        mBubbleData.setListener(mListener);
        setMetadataFlags(mEntryDismissed,
                Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, /* enableFlag */ true);

        // Test
        mBubbleData.notificationEntryUpdated(mEntryDismissed, /* suppressFlyout */ false,
                /* showInShade */ false);
        mBubbleData.notificationEntryUpdated(mEntryDismissed, false /* suppressFlyout */,
                false /* showInShade */);
        verifyUpdateReceived();

        mBubbleData.notificationEntryUpdated(mEntryDismissed, /* suppressFlyout */
                false, /* showInShade */ false);
        // Make it look like user swiped away row
        mEntryDismissed.getRow().dismiss(false /* refocusOnDismiss */);
        assertThat(mBubbleData.getBubbleWithKey(mEntryDismissed.getKey()).showInShade()).isFalse();

        mBubbleData.notificationEntryUpdated(mEntryDismissed, false /* suppressFlyout */,
                false /* showInShade */);
        verifyUpdateReceived();

        // Verify
@@ -935,23 +939,6 @@ public class BubbleDataTest extends SysuiTestCase {
        }
    }

    /**
     * Sets the bubble metadata flags for this entry. These flags are normally set by
     * NotificationManagerService when the notification is sent, however, these tests do not
     * go through that path so we set them explicitly when testing.
     */
    private void setMetadataFlags(NotificationEntry entry, int flag, boolean enableFlag) {
        Notification.BubbleMetadata bubbleMetadata =
                entry.getSbn().getNotification().getBubbleMetadata();
        int flags = bubbleMetadata.getFlags();
        if (enableFlag) {
            flags |= flag;
        } else {
            flags &= ~flag;
        }
        bubbleMetadata.setFlags(flags);
    }

    /**
     * No ExpandableNotificationRow is required to test BubbleData. This setup is all that is
     * required for BubbleData functionality and verification. NotificationTestHelper is used only