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