Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
| 19 | import static org.junit.Assert.assertFalse; |
| 20 | import static org.junit.Assert.assertTrue; |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 21 | import static org.mockito.Mockito.doReturn; |
Selim Cinek | c3fec68 | 2019-06-06 18:11:07 -0700 | [diff] [blame] | 22 | import static org.mockito.Mockito.mock; |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 23 | import static org.mockito.Mockito.spy; |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 24 | import static org.mockito.Mockito.times; |
| 25 | import static org.mockito.Mockito.verify; |
| 26 | import static org.mockito.Mockito.when; |
| 27 | |
| 28 | import android.app.Notification; |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 29 | import android.service.notification.StatusBarNotification; |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 30 | import android.testing.AndroidTestingRunner; |
| 31 | import android.testing.TestableLooper; |
| 32 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 33 | import androidx.test.filters.SmallTest; |
| 34 | |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 35 | import com.android.systemui.SysuiTestCase; |
Selim Cinek | c3fec68 | 2019-06-06 18:11:07 -0700 | [diff] [blame] | 36 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Gus Prevas | d65c2db | 2018-12-18 17:13:38 -0500 | [diff] [blame] | 37 | import com.android.systemui.statusbar.notification.NotificationEntryListener; |
Ned Burns | 3d6b396 | 2018-12-07 21:26:00 -0500 | [diff] [blame] | 38 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 39 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 40 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
| 41 | |
| 42 | import org.junit.Before; |
| 43 | import org.junit.Rule; |
| 44 | import org.junit.Test; |
| 45 | import org.junit.runner.RunWith; |
Ned Burns | 3d6b396 | 2018-12-07 21:26:00 -0500 | [diff] [blame] | 46 | import org.mockito.ArgumentCaptor; |
| 47 | import org.mockito.Captor; |
| 48 | import org.mockito.Mock; |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 49 | import org.mockito.junit.MockitoJUnit; |
| 50 | import org.mockito.junit.MockitoRule; |
| 51 | |
| 52 | import java.util.HashMap; |
| 53 | |
| 54 | @SmallTest |
| 55 | @RunWith(AndroidTestingRunner.class) |
| 56 | @TestableLooper.RunWithLooper |
| 57 | public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { |
Ned Burns | 3d6b396 | 2018-12-07 21:26:00 -0500 | [diff] [blame] | 58 | @Rule public MockitoRule rule = MockitoJUnit.rule(); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 59 | |
| 60 | private NotificationGroupAlertTransferHelper mGroupAlertTransferHelper; |
| 61 | private NotificationGroupManager mGroupManager; |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 62 | private HeadsUpManager mHeadsUpManager; |
Ned Burns | 3d6b396 | 2018-12-07 21:26:00 -0500 | [diff] [blame] | 63 | @Mock private NotificationEntryManager mNotificationEntryManager; |
Gus Prevas | d65c2db | 2018-12-18 17:13:38 -0500 | [diff] [blame] | 64 | @Captor |
| 65 | private ArgumentCaptor<NotificationEntryListener> mListenerCaptor; |
| 66 | private NotificationEntryListener mNotificationEntryListener; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 67 | private final HashMap<String, NotificationEntry> mPendingEntries = new HashMap<>(); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 68 | private final NotificationGroupTestHelper mGroupTestHelper = |
| 69 | new NotificationGroupTestHelper(mContext); |
| 70 | |
| 71 | |
| 72 | @Before |
| 73 | public void setup() { |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 74 | mHeadsUpManager = new HeadsUpManager(mContext) {}; |
| 75 | |
Ned Burns | 3d6b396 | 2018-12-07 21:26:00 -0500 | [diff] [blame] | 76 | when(mNotificationEntryManager.getPendingNotificationsIterator()) |
| 77 | .thenReturn(mPendingEntries.values()); |
| 78 | |
Selim Cinek | c3fec68 | 2019-06-06 18:11:07 -0700 | [diff] [blame] | 79 | mGroupManager = new NotificationGroupManager(mock(StatusBarStateController.class)); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 80 | mDependency.injectTestDependency(NotificationGroupManager.class, mGroupManager); |
| 81 | mGroupManager.setHeadsUpManager(mHeadsUpManager); |
| 82 | |
| 83 | mGroupAlertTransferHelper = new NotificationGroupAlertTransferHelper(); |
| 84 | mGroupAlertTransferHelper.setHeadsUpManager(mHeadsUpManager); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 85 | |
Ned Burns | 3d6b396 | 2018-12-07 21:26:00 -0500 | [diff] [blame] | 86 | mGroupAlertTransferHelper.bind(mNotificationEntryManager, mGroupManager); |
Gus Prevas | d65c2db | 2018-12-18 17:13:38 -0500 | [diff] [blame] | 87 | verify(mNotificationEntryManager).addNotificationEntryListener(mListenerCaptor.capture()); |
| 88 | mNotificationEntryListener = mListenerCaptor.getValue(); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 89 | mHeadsUpManager.addListener(mGroupAlertTransferHelper); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | @Test |
| 93 | public void testSuppressedSummaryHeadsUpTransfersToChild() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 94 | NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 95 | mHeadsUpManager.showNotification(summaryEntry); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 96 | NotificationEntry childEntry = mGroupTestHelper.createChildNotification(); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 97 | |
| 98 | // Summary will be suppressed because there is only one child. |
| 99 | mGroupManager.onEntryAdded(summaryEntry); |
| 100 | mGroupManager.onEntryAdded(childEntry); |
| 101 | |
| 102 | // A suppressed summary should transfer its alert state to the child. |
| 103 | assertFalse(mHeadsUpManager.isAlerting(summaryEntry.key)); |
| 104 | assertTrue(mHeadsUpManager.isAlerting(childEntry.key)); |
| 105 | } |
| 106 | |
| 107 | @Test |
| 108 | public void testSuppressedSummaryHeadsUpTransfersToChildButBackAgain() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 109 | NotificationEntry summaryEntry = |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 110 | mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 111 | NotificationEntry childEntry = |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 112 | mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 113 | NotificationEntry childEntry2 = |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 114 | mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); |
| 115 | mHeadsUpManager.showNotification(summaryEntry); |
| 116 | // Trigger a transfer of alert state from summary to child. |
| 117 | mGroupManager.onEntryAdded(summaryEntry); |
| 118 | mGroupManager.onEntryAdded(childEntry); |
| 119 | |
| 120 | // Add second child notification so that summary is no longer suppressed. |
| 121 | mPendingEntries.put(childEntry2.key, childEntry2); |
Gus Prevas | d65c2db | 2018-12-18 17:13:38 -0500 | [diff] [blame] | 122 | mNotificationEntryListener.onPendingEntryAdded(childEntry2); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 123 | mGroupManager.onEntryAdded(childEntry2); |
| 124 | |
| 125 | // The alert state should transfer back to the summary as there is now more than one |
| 126 | // child and the summary should no longer be suppressed. |
| 127 | assertTrue(mHeadsUpManager.isAlerting(summaryEntry.key)); |
| 128 | assertFalse(mHeadsUpManager.isAlerting(childEntry.key)); |
| 129 | } |
| 130 | |
| 131 | @Test |
| 132 | public void testSuppressedSummaryHeadsUpDoesntTransferBackOnDozingChanged() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 133 | NotificationEntry summaryEntry = |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 134 | mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 135 | NotificationEntry childEntry = |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 136 | mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 137 | NotificationEntry childEntry2 = |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 138 | mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); |
| 139 | mHeadsUpManager.showNotification(summaryEntry); |
| 140 | // Trigger a transfer of alert state from summary to child. |
| 141 | mGroupManager.onEntryAdded(summaryEntry); |
| 142 | mGroupManager.onEntryAdded(childEntry); |
| 143 | |
| 144 | // Set dozing to true. |
| 145 | mGroupAlertTransferHelper.onDozingChanged(true); |
| 146 | |
| 147 | // Add second child notification so that summary is no longer suppressed. |
| 148 | mPendingEntries.put(childEntry2.key, childEntry2); |
Gus Prevas | d65c2db | 2018-12-18 17:13:38 -0500 | [diff] [blame] | 149 | mNotificationEntryListener.onPendingEntryAdded(childEntry2); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 150 | mGroupManager.onEntryAdded(childEntry2); |
| 151 | |
| 152 | // Dozing changed so no reason to re-alert summary. |
| 153 | assertFalse(mHeadsUpManager.isAlerting(summaryEntry.key)); |
| 154 | } |
| 155 | |
| 156 | @Test |
| 157 | public void testSuppressedSummaryHeadsUpTransferDoesNotAlertChildIfUninflated() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 158 | NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 159 | mHeadsUpManager.showNotification(summaryEntry); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 160 | NotificationEntry childEntry = mGroupTestHelper.createChildNotification(); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 161 | when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) |
| 162 | .thenReturn(false); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 163 | |
| 164 | mGroupManager.onEntryAdded(summaryEntry); |
| 165 | mGroupManager.onEntryAdded(childEntry); |
| 166 | |
| 167 | // Alert is immediately removed from summary, but we do not show child yet either as its |
| 168 | // content is not inflated. |
| 169 | assertFalse(mHeadsUpManager.isAlerting(summaryEntry.key)); |
| 170 | assertFalse(mHeadsUpManager.isAlerting(childEntry.key)); |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 171 | assertTrue(mGroupAlertTransferHelper.isAlertTransferPending(childEntry)); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | @Test |
| 175 | public void testSuppressedSummaryHeadsUpTransferAlertsChildOnInflation() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 176 | NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 177 | mHeadsUpManager.showNotification(summaryEntry); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 178 | NotificationEntry childEntry = mGroupTestHelper.createChildNotification(); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 179 | when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) |
| 180 | .thenReturn(false); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 181 | |
| 182 | mGroupManager.onEntryAdded(summaryEntry); |
| 183 | mGroupManager.onEntryAdded(childEntry); |
| 184 | |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 185 | when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) |
| 186 | .thenReturn(true); |
Gus Prevas | d65c2db | 2018-12-18 17:13:38 -0500 | [diff] [blame] | 187 | mNotificationEntryListener.onEntryReinflated(childEntry); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 188 | |
| 189 | // Alert is immediately removed from summary, and we show child as its content is inflated. |
| 190 | assertFalse(mHeadsUpManager.isAlerting(summaryEntry.key)); |
| 191 | assertTrue(mHeadsUpManager.isAlerting(childEntry.key)); |
| 192 | } |
| 193 | |
| 194 | @Test |
| 195 | public void testSuppressedSummaryHeadsUpTransferBackAbortsChildInflation() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 196 | NotificationEntry summaryEntry = |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 197 | mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 198 | NotificationEntry childEntry = |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 199 | mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 200 | when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) |
| 201 | .thenReturn(false); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 202 | NotificationEntry childEntry2 = |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 203 | mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); |
| 204 | mHeadsUpManager.showNotification(summaryEntry); |
| 205 | // Trigger a transfer of alert state from summary to child. |
| 206 | mGroupManager.onEntryAdded(summaryEntry); |
| 207 | mGroupManager.onEntryAdded(childEntry); |
| 208 | |
| 209 | // Add second child notification so that summary is no longer suppressed. |
| 210 | mPendingEntries.put(childEntry2.key, childEntry2); |
Gus Prevas | d65c2db | 2018-12-18 17:13:38 -0500 | [diff] [blame] | 211 | mNotificationEntryListener.onPendingEntryAdded(childEntry2); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 212 | mGroupManager.onEntryAdded(childEntry2); |
| 213 | |
| 214 | // Child entry finishes its inflation. |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 215 | when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) |
| 216 | .thenReturn(true); |
Gus Prevas | d65c2db | 2018-12-18 17:13:38 -0500 | [diff] [blame] | 217 | mNotificationEntryListener.onEntryReinflated(childEntry); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 218 | |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 219 | verify(childEntry.getRow(), times(1)).freeContentViewWhenSafe(mHeadsUpManager |
| 220 | .getContentFlag()); |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 221 | assertFalse(mHeadsUpManager.isAlerting(childEntry.key)); |
| 222 | } |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 223 | |
| 224 | @Test |
| 225 | public void testCleanUpPendingAlertInfo() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 226 | NotificationEntry summaryEntry = |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 227 | mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 228 | NotificationEntry childEntry = |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 229 | mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 230 | when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) |
| 231 | .thenReturn(false); |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 232 | mHeadsUpManager.showNotification(summaryEntry); |
| 233 | // Trigger a transfer of alert state from summary to child. |
| 234 | mGroupManager.onEntryAdded(summaryEntry); |
| 235 | mGroupManager.onEntryAdded(childEntry); |
| 236 | |
Ned Burns | ef2ef6c | 2019-01-02 16:48:08 -0500 | [diff] [blame] | 237 | mNotificationEntryListener.onEntryRemoved(childEntry, null, false); |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 238 | |
| 239 | assertFalse(mGroupAlertTransferHelper.isAlertTransferPending(childEntry)); |
| 240 | } |
| 241 | |
| 242 | @Test |
| 243 | public void testUpdateGroupChangeDoesNotTransfer() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 244 | NotificationEntry summaryEntry = |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 245 | mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 246 | NotificationEntry childEntry = |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 247 | mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 248 | when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) |
| 249 | .thenReturn(false); |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 250 | mHeadsUpManager.showNotification(summaryEntry); |
| 251 | // Trigger a transfer of alert state from summary to child. |
| 252 | mGroupManager.onEntryAdded(summaryEntry); |
| 253 | mGroupManager.onEntryAdded(childEntry); |
| 254 | |
| 255 | // Notify that entry changed groups. |
| 256 | StatusBarNotification oldNotification = childEntry.notification; |
| 257 | StatusBarNotification newSbn = spy(childEntry.notification.clone()); |
| 258 | doReturn("other_group").when(newSbn).getGroupKey(); |
| 259 | childEntry.notification = newSbn; |
| 260 | mGroupManager.onEntryUpdated(childEntry, oldNotification); |
| 261 | |
| 262 | assertFalse(mGroupAlertTransferHelper.isAlertTransferPending(childEntry)); |
| 263 | } |
| 264 | |
| 265 | @Test |
| 266 | public void testUpdateChildToSummaryDoesNotTransfer() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 267 | NotificationEntry summaryEntry = |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 268 | mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 269 | NotificationEntry childEntry = |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 270 | mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 271 | when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) |
| 272 | .thenReturn(false); |
Kevin | 4b8bbda | 2018-11-19 14:36:31 -0800 | [diff] [blame] | 273 | mHeadsUpManager.showNotification(summaryEntry); |
| 274 | // Trigger a transfer of alert state from summary to child. |
| 275 | mGroupManager.onEntryAdded(summaryEntry); |
| 276 | mGroupManager.onEntryAdded(childEntry); |
| 277 | |
| 278 | // Update that child to a summary. |
| 279 | StatusBarNotification oldNotification = childEntry.notification; |
| 280 | childEntry.notification = mGroupTestHelper.createSummaryNotification( |
| 281 | Notification.GROUP_ALERT_SUMMARY).notification; |
| 282 | mGroupManager.onEntryUpdated(childEntry, oldNotification); |
| 283 | |
| 284 | assertFalse(mGroupAlertTransferHelper.isAlertTransferPending(childEntry)); |
| 285 | } |
Kevin | 01a53cb | 2018-11-09 18:19:54 -0800 | [diff] [blame] | 286 | } |