Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | |
Mady Mellor | c2ff011 | 2019-03-28 14:18:06 -0700 | [diff] [blame] | 19 | import static android.service.notification.NotificationListenerService.REASON_CLICK; |
| 20 | |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 21 | import static org.mockito.AdditionalAnswers.answerVoid; |
| 22 | import static org.mockito.ArgumentMatchers.any; |
| 23 | import static org.mockito.ArgumentMatchers.anyBoolean; |
| 24 | import static org.mockito.ArgumentMatchers.anyInt; |
| 25 | import static org.mockito.ArgumentMatchers.eq; |
| 26 | import static org.mockito.Mockito.atLeastOnce; |
| 27 | import static org.mockito.Mockito.doAnswer; |
| 28 | import static org.mockito.Mockito.mock; |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 29 | import static org.mockito.Mockito.never; |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 30 | import static org.mockito.Mockito.verify; |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 31 | import static org.mockito.Mockito.verifyNoMoreInteractions; |
| 32 | import static org.mockito.Mockito.verifyZeroInteractions; |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 33 | import static org.mockito.Mockito.when; |
| 34 | |
| 35 | import android.app.KeyguardManager; |
| 36 | import android.app.Notification; |
| 37 | import android.app.PendingIntent; |
| 38 | import android.content.Context; |
| 39 | import android.content.Intent; |
| 40 | import android.os.Handler; |
| 41 | import android.os.RemoteException; |
| 42 | import android.os.UserHandle; |
| 43 | import android.service.dreams.IDreamManager; |
| 44 | import android.service.notification.StatusBarNotification; |
| 45 | import android.testing.AndroidTestingRunner; |
| 46 | import android.testing.TestableLooper; |
| 47 | |
| 48 | import androidx.test.filters.SmallTest; |
| 49 | |
| 50 | import com.android.internal.logging.MetricsLogger; |
| 51 | import com.android.internal.statusbar.IStatusBarService; |
| 52 | import com.android.internal.statusbar.NotificationVisibility; |
| 53 | import com.android.internal.widget.LockPatternUtils; |
| 54 | import com.android.systemui.ActivityIntentHelper; |
| 55 | import com.android.systemui.SysuiTestCase; |
| 56 | import com.android.systemui.assist.AssistManager; |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 57 | import com.android.systemui.bubbles.BubbleController; |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 58 | import com.android.systemui.plugins.ActivityStarter; |
| 59 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
| 60 | import com.android.systemui.statusbar.CommandQueue; |
| 61 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
| 62 | import com.android.systemui.statusbar.NotificationPresenter; |
| 63 | import com.android.systemui.statusbar.NotificationRemoteInputManager; |
| 64 | import com.android.systemui.statusbar.NotificationTestHelper; |
| 65 | import com.android.systemui.statusbar.RemoteInputController; |
| 66 | import com.android.systemui.statusbar.StatusBarState; |
Dave Mankoff | 4c73e65 | 2019-11-14 17:39:08 -0500 | [diff] [blame] | 67 | import com.android.systemui.statusbar.SuperStatusBarViewFactory; |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 68 | import com.android.systemui.statusbar.notification.ActivityLaunchAnimator; |
| 69 | import com.android.systemui.statusbar.notification.NotificationActivityStarter; |
| 70 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
| 71 | import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider; |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 72 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
| 73 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 74 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Dave Mankoff | c7cf9fc | 2019-12-19 15:43:20 -0500 | [diff] [blame] | 75 | import com.android.systemui.util.concurrency.FakeExecutor; |
| 76 | import com.android.systemui.util.time.FakeSystemClock; |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 77 | |
| 78 | import org.junit.Before; |
| 79 | import org.junit.Test; |
| 80 | import org.junit.runner.RunWith; |
| 81 | import org.mockito.Mock; |
| 82 | import org.mockito.MockitoAnnotations; |
| 83 | import org.mockito.stubbing.Answer; |
| 84 | |
| 85 | import java.util.ArrayList; |
| 86 | |
| 87 | @SmallTest |
| 88 | @RunWith(AndroidTestingRunner.class) |
| 89 | @TestableLooper.RunWithLooper(setAsMainLooper = true) |
| 90 | public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { |
| 91 | |
| 92 | @Mock |
| 93 | private AssistManager mAssistManager; |
| 94 | @Mock |
| 95 | private NotificationEntryManager mEntryManager; |
| 96 | @Mock |
| 97 | private ActivityStarter mActivityStarter; |
| 98 | @Mock |
| 99 | private IStatusBarService mStatusBarService; |
| 100 | @Mock |
| 101 | private StatusBarStateController mStatusBarStateController; |
| 102 | @Mock |
Heemin Seog | 98df697 | 2019-12-05 13:01:38 -0800 | [diff] [blame] | 103 | private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; |
| 104 | @Mock |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 105 | private NotificationRemoteInputManager mRemoteInputManager; |
| 106 | @Mock |
| 107 | private RemoteInputController mRemoteInputController; |
| 108 | @Mock |
Heemin Seog | bd9bcbf | 2019-12-04 17:07:32 -0800 | [diff] [blame] | 109 | private StatusBar mStatusBar; |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 110 | @Mock |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 111 | private KeyguardStateController mKeyguardStateController; |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 112 | @Mock |
| 113 | private Handler mHandler; |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 114 | @Mock |
| 115 | private BubbleController mBubbleController; |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 116 | @Mock |
| 117 | private ShadeControllerImpl mShadeController; |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 118 | |
| 119 | @Mock |
| 120 | private ActivityIntentHelper mActivityIntentHelper; |
| 121 | @Mock |
| 122 | private PendingIntent mContentIntent; |
| 123 | @Mock |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 124 | private Intent mContentIntentInner; |
| 125 | @Mock |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 126 | private NotificationActivityStarter mNotificationActivityStarter; |
Dave Mankoff | 4c73e65 | 2019-11-14 17:39:08 -0500 | [diff] [blame] | 127 | @Mock |
| 128 | private SuperStatusBarViewFactory mSuperStatusBarViewFactory; |
| 129 | @Mock |
| 130 | private NotificationPanelView mNotificationPanelView; |
Dave Mankoff | c7cf9fc | 2019-12-19 15:43:20 -0500 | [diff] [blame] | 131 | private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock()); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 132 | |
| 133 | private NotificationTestHelper mNotificationTestHelper; |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 134 | private ExpandableNotificationRow mNotificationRow; |
| 135 | private ExpandableNotificationRow mBubbleNotificationRow; |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 136 | |
| 137 | private final Answer<Void> mCallOnDismiss = answerVoid( |
| 138 | (ActivityStarter.OnDismissAction dismissAction, Runnable cancel, |
| 139 | Boolean afterKeyguardGone) -> dismissAction.onDismiss()); |
| 140 | private ArrayList<NotificationEntry> mActiveNotifications; |
| 141 | |
| 142 | @Before |
| 143 | public void setUp() throws Exception { |
| 144 | MockitoAnnotations.initMocks(this); |
| 145 | when(mRemoteInputManager.getController()).thenReturn(mRemoteInputController); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 146 | |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 147 | when(mContentIntent.isActivity()).thenReturn(true); |
| 148 | when(mContentIntent.getCreatorUserHandle()).thenReturn(UserHandle.of(1)); |
| 149 | when(mContentIntent.getIntent()).thenReturn(mContentIntentInner); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 150 | |
Lucas Dupin | d236ee3 | 2019-10-08 15:33:59 -0700 | [diff] [blame] | 151 | mNotificationTestHelper = new NotificationTestHelper(mContext, mDependency); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 152 | |
| 153 | // Create standard notification with contentIntent |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 154 | mNotificationRow = mNotificationTestHelper.createRow(); |
Ned Burns | 1c2b85a4 | 2019-11-14 15:37:03 -0500 | [diff] [blame] | 155 | StatusBarNotification sbn = mNotificationRow.getEntry().getSbn(); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 156 | sbn.getNotification().contentIntent = mContentIntent; |
| 157 | sbn.getNotification().flags |= Notification.FLAG_AUTO_CANCEL; |
| 158 | |
| 159 | // Create bubble notification row with contentIntent |
| 160 | mBubbleNotificationRow = mNotificationTestHelper.createBubble(); |
Ned Burns | 1c2b85a4 | 2019-11-14 15:37:03 -0500 | [diff] [blame] | 161 | StatusBarNotification bubbleSbn = mBubbleNotificationRow.getEntry().getSbn(); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 162 | bubbleSbn.getNotification().contentIntent = mContentIntent; |
| 163 | bubbleSbn.getNotification().flags |= Notification.FLAG_AUTO_CANCEL; |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 164 | |
| 165 | mActiveNotifications = new ArrayList<>(); |
| 166 | mActiveNotifications.add(mNotificationRow.getEntry()); |
| 167 | mActiveNotifications.add(mBubbleNotificationRow.getEntry()); |
Evan Laird | 181de62 | 2019-10-24 09:53:02 -0400 | [diff] [blame] | 168 | when(mEntryManager.getVisibleNotifications()).thenReturn(mActiveNotifications); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 169 | when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); |
Dave Mankoff | 4c73e65 | 2019-11-14 17:39:08 -0500 | [diff] [blame] | 170 | when(mSuperStatusBarViewFactory.getNotificationPanelView()) |
| 171 | .thenReturn(mNotificationPanelView); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 172 | |
Dave Mankoff | 4c73e65 | 2019-11-14 17:39:08 -0500 | [diff] [blame] | 173 | mNotificationActivityStarter = (new StatusBarNotificationActivityStarter.Builder( |
| 174 | getContext(), mock(CommandQueue.class), () -> mAssistManager, |
| 175 | mEntryManager, mock(HeadsUpManagerPhone.class), |
| 176 | mActivityStarter, mStatusBarService, |
Heemin Seog | 98df697 | 2019-12-05 13:01:38 -0800 | [diff] [blame] | 177 | mock(StatusBarStateController.class), mStatusBarKeyguardViewManager, |
| 178 | mock(KeyguardManager.class), |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 179 | mock(IDreamManager.class), mRemoteInputManager, |
| 180 | mock(StatusBarRemoteInputCallback.class), mock(NotificationGroupManager.class), |
Dave Mankoff | 4c73e65 | 2019-11-14 17:39:08 -0500 | [diff] [blame] | 181 | mock(NotificationLockscreenUserManager.class), |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 182 | mKeyguardStateController, |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 183 | mock(NotificationInterruptionStateProvider.class), mock(MetricsLogger.class), |
Dave Mankoff | c7cf9fc | 2019-12-19 15:43:20 -0500 | [diff] [blame] | 184 | mock(LockPatternUtils.class), mHandler, mHandler, mUiBgExecutor, |
| 185 | mActivityIntentHelper, mBubbleController, mShadeController, |
| 186 | mSuperStatusBarViewFactory)) |
Heemin Seog | bd9bcbf | 2019-12-04 17:07:32 -0800 | [diff] [blame] | 187 | .setStatusBar(mStatusBar) |
Dave Mankoff | 4c73e65 | 2019-11-14 17:39:08 -0500 | [diff] [blame] | 188 | .setNotificationPresenter(mock(NotificationPresenter.class)) |
| 189 | .setActivityLaunchAnimator(mock(ActivityLaunchAnimator.class)) |
| 190 | .build(); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 191 | |
| 192 | // set up dismissKeyguardThenExecute to synchronously invoke the OnDismissAction arg |
| 193 | doAnswer(mCallOnDismiss).when(mActivityStarter).dismissKeyguardThenExecute( |
| 194 | any(ActivityStarter.OnDismissAction.class), any(), anyBoolean()); |
| 195 | |
| 196 | // set up addAfterKeyguardGoneRunnable to synchronously invoke the Runnable arg |
| 197 | doAnswer(answerVoid(Runnable::run)) |
Heemin Seog | 98df697 | 2019-12-05 13:01:38 -0800 | [diff] [blame] | 198 | .when(mStatusBarKeyguardViewManager) |
| 199 | .addAfterKeyguardGoneRunnable(any(Runnable.class)); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 200 | |
| 201 | // set up addPostCollapseAction to synchronously invoke the Runnable arg |
| 202 | doAnswer(answerVoid(Runnable::run)) |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 203 | .when(mShadeController).addPostCollapseAction(any(Runnable.class)); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 204 | |
| 205 | // set up Handler to synchronously invoke the Runnable arg |
| 206 | doAnswer(answerVoid(Runnable::run)) |
| 207 | .when(mHandler).post(any(Runnable.class)); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 208 | |
| 209 | doAnswer(answerVoid(Runnable::run)) |
| 210 | .when(mHandler).postAtFrontOfQueue(any(Runnable.class)); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | @Test |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 214 | public void testOnNotificationClicked_keyGuardShowing() |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 215 | throws PendingIntent.CanceledException, RemoteException { |
| 216 | // Given |
Ned Burns | 1c2b85a4 | 2019-11-14 15:37:03 -0500 | [diff] [blame] | 217 | StatusBarNotification sbn = mNotificationRow.getEntry().getSbn(); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 218 | sbn.getNotification().contentIntent = mContentIntent; |
| 219 | sbn.getNotification().flags |= Notification.FLAG_AUTO_CANCEL; |
| 220 | |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 221 | when(mKeyguardStateController.isShowing()).thenReturn(true); |
Heemin Seog | bd9bcbf | 2019-12-04 17:07:32 -0800 | [diff] [blame] | 222 | when(mStatusBar.isOccluded()).thenReturn(true); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 223 | |
| 224 | // When |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 225 | mNotificationActivityStarter.onNotificationClicked(sbn, mNotificationRow); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 226 | |
| 227 | // Then |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 228 | verify(mShadeController, atLeastOnce()).collapsePanel(); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 229 | |
| 230 | verify(mContentIntent).sendAndReturnResult( |
| 231 | any(Context.class), |
| 232 | anyInt() /* code */, |
| 233 | any() /* fillInIntent */, |
| 234 | any() /* PendingIntent.OnFinished */, |
| 235 | any() /* Handler */, |
| 236 | any() /* requiredPermission */, |
| 237 | any() /* Bundle options */); |
| 238 | |
| 239 | verify(mAssistManager).hideAssist(); |
| 240 | |
| 241 | verify(mStatusBarService).onNotificationClick( |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 242 | eq(sbn.getKey()), any(NotificationVisibility.class)); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 243 | |
| 244 | // Notification is removed due to FLAG_AUTO_CANCEL |
Mady Mellor | c2ff011 | 2019-03-28 14:18:06 -0700 | [diff] [blame] | 245 | verify(mEntryManager).performRemoveNotification(eq(sbn), eq(REASON_CLICK)); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | @Test |
| 249 | public void testOnNotificationClicked_bubble_noContentIntent_noKeyGuard() |
| 250 | throws RemoteException { |
Ned Burns | 1c2b85a4 | 2019-11-14 15:37:03 -0500 | [diff] [blame] | 251 | StatusBarNotification sbn = mBubbleNotificationRow.getEntry().getSbn(); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 252 | |
| 253 | // Given |
| 254 | sbn.getNotification().contentIntent = null; |
| 255 | |
| 256 | // When |
| 257 | mNotificationActivityStarter.onNotificationClicked(sbn, mBubbleNotificationRow); |
| 258 | |
| 259 | // Then |
| 260 | verify(mBubbleController).expandStackAndSelectBubble(eq(sbn.getKey())); |
| 261 | |
| 262 | // This is called regardless, and simply short circuits when there is nothing to do. |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 263 | verify(mShadeController, atLeastOnce()).collapsePanel(); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 264 | |
| 265 | verify(mAssistManager).hideAssist(); |
| 266 | |
| 267 | verify(mStatusBarService).onNotificationClick( |
| 268 | eq(sbn.getKey()), any(NotificationVisibility.class)); |
| 269 | |
| 270 | // The content intent should NOT be sent on click. |
| 271 | verifyZeroInteractions(mContentIntent); |
| 272 | |
| 273 | // Notification should not be cancelled. |
Mady Mellor | c2ff011 | 2019-03-28 14:18:06 -0700 | [diff] [blame] | 274 | verify(mEntryManager, never()).performRemoveNotification(eq(sbn), anyInt()); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | @Test |
| 278 | public void testOnNotificationClicked_bubble_noContentIntent_keyGuardShowing() |
| 279 | throws RemoteException { |
Ned Burns | 1c2b85a4 | 2019-11-14 15:37:03 -0500 | [diff] [blame] | 280 | StatusBarNotification sbn = mBubbleNotificationRow.getEntry().getSbn(); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 281 | |
| 282 | // Given |
| 283 | sbn.getNotification().contentIntent = null; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 284 | when(mKeyguardStateController.isShowing()).thenReturn(true); |
Heemin Seog | bd9bcbf | 2019-12-04 17:07:32 -0800 | [diff] [blame] | 285 | when(mStatusBar.isOccluded()).thenReturn(true); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 286 | |
| 287 | // When |
| 288 | mNotificationActivityStarter.onNotificationClicked(sbn, mBubbleNotificationRow); |
| 289 | |
| 290 | // Then |
| 291 | verify(mBubbleController).expandStackAndSelectBubble(eq(sbn.getKey())); |
| 292 | |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 293 | verify(mShadeController, atLeastOnce()).collapsePanel(); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 294 | |
| 295 | verify(mAssistManager).hideAssist(); |
| 296 | |
| 297 | verify(mStatusBarService).onNotificationClick( |
| 298 | eq(sbn.getKey()), any(NotificationVisibility.class)); |
| 299 | |
| 300 | // The content intent should NOT be sent on click. |
| 301 | verifyZeroInteractions(mContentIntent); |
| 302 | |
| 303 | // Notification should not be cancelled. |
Mady Mellor | c2ff011 | 2019-03-28 14:18:06 -0700 | [diff] [blame] | 304 | verify(mEntryManager, never()).performRemoveNotification(eq(sbn), anyInt()); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | @Test |
| 308 | public void testOnNotificationClicked_bubble_withContentIntent_keyGuardShowing() |
| 309 | throws RemoteException { |
Ned Burns | 1c2b85a4 | 2019-11-14 15:37:03 -0500 | [diff] [blame] | 310 | StatusBarNotification sbn = mBubbleNotificationRow.getEntry().getSbn(); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 311 | |
| 312 | // Given |
| 313 | sbn.getNotification().contentIntent = mContentIntent; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 314 | when(mKeyguardStateController.isShowing()).thenReturn(true); |
Heemin Seog | bd9bcbf | 2019-12-04 17:07:32 -0800 | [diff] [blame] | 315 | when(mStatusBar.isOccluded()).thenReturn(true); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 316 | |
| 317 | // When |
| 318 | mNotificationActivityStarter.onNotificationClicked(sbn, mBubbleNotificationRow); |
| 319 | |
| 320 | // Then |
| 321 | verify(mBubbleController).expandStackAndSelectBubble(eq(sbn.getKey())); |
| 322 | |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 323 | verify(mShadeController, atLeastOnce()).collapsePanel(); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 324 | |
| 325 | verify(mAssistManager).hideAssist(); |
| 326 | |
| 327 | verify(mStatusBarService).onNotificationClick( |
| 328 | eq(sbn.getKey()), any(NotificationVisibility.class)); |
| 329 | |
| 330 | // The content intent should NOT be sent on click. |
| 331 | verify(mContentIntent).getIntent(); |
| 332 | verify(mContentIntent).isActivity(); |
| 333 | verifyNoMoreInteractions(mContentIntent); |
| 334 | |
| 335 | // Notification should not be cancelled. |
Mady Mellor | c2ff011 | 2019-03-28 14:18:06 -0700 | [diff] [blame] | 336 | verify(mEntryManager, never()).performRemoveNotification(eq(sbn), anyInt()); |
Mark Renouf | 6b2331c | 2019-03-21 13:40:08 -0400 | [diff] [blame] | 337 | } |
| 338 | } |