Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 19 | import static android.app.NotificationManager.IMPORTANCE_HIGH; |
| 20 | |
| 21 | import static junit.framework.Assert.assertFalse; |
| 22 | import static junit.framework.Assert.assertTrue; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 23 | import static junit.framework.TestCase.fail; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 24 | |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 25 | import static org.mockito.ArgumentMatchers.any; |
| 26 | import static org.mockito.ArgumentMatchers.anyBoolean; |
| 27 | import static org.mockito.ArgumentMatchers.anyInt; |
| 28 | import static org.mockito.ArgumentMatchers.anyString; |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 29 | import static org.mockito.ArgumentMatchers.eq; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 30 | import static org.mockito.Mockito.doAnswer; |
| 31 | import static org.mockito.Mockito.mock; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 32 | import static org.mockito.Mockito.never; |
| 33 | import static org.mockito.Mockito.times; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 34 | import static org.mockito.Mockito.verify; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 35 | import static org.mockito.Mockito.when; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 36 | |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 37 | import android.app.Notification; |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 38 | import android.app.StatusBarManager; |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 39 | import android.app.trust.TrustManager; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 40 | import android.content.Context; |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 41 | import android.hardware.fingerprint.FingerprintManager; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 42 | import android.metrics.LogMaker; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 43 | import android.os.Binder; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 44 | import android.os.Handler; |
| 45 | import android.os.HandlerThread; |
| 46 | import android.os.IPowerManager; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 47 | import android.os.PowerManager; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 48 | import android.os.RemoteException; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 49 | import android.os.UserHandle; |
| 50 | import android.service.notification.StatusBarNotification; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 51 | import android.support.test.filters.SmallTest; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 52 | import android.support.test.metricshelper.MetricsAsserts; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 53 | import android.testing.AndroidTestingRunner; |
| 54 | import android.testing.TestableLooper; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 55 | import android.testing.TestableLooper.RunWithLooper; |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 56 | import android.util.SparseArray; |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 57 | import android.view.ViewGroup.LayoutParams; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 58 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 59 | import com.android.internal.logging.MetricsLogger; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 60 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 61 | import com.android.internal.logging.testing.FakeMetricsLogger; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 62 | import com.android.internal.statusbar.IStatusBarService; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 63 | import com.android.keyguard.KeyguardHostView.OnDismissAction; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 64 | import com.android.systemui.ForegroundServiceController; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 65 | import com.android.systemui.R; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 66 | import com.android.systemui.SysuiTestCase; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 67 | import com.android.systemui.UiOffloadThread; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 68 | import com.android.systemui.assist.AssistManager; |
Adrian Roos | 6d5ebb7 | 2017-08-03 15:10:22 +0200 | [diff] [blame] | 69 | import com.android.systemui.keyguard.WakefulnessLifecycle; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 70 | import com.android.systemui.recents.misc.SystemServicesProxy; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 71 | import com.android.systemui.statusbar.ActivatableNotificationView; |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 72 | import com.android.systemui.statusbar.AppOpsListener; |
Jason Monk | 5ecf80c | 2017-07-06 15:28:17 -0400 | [diff] [blame] | 73 | import com.android.systemui.statusbar.CommandQueue; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 74 | import com.android.systemui.statusbar.KeyguardIndicationController; |
| 75 | import com.android.systemui.statusbar.NotificationData; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 76 | import com.android.systemui.statusbar.NotificationData.Entry; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 77 | import com.android.systemui.statusbar.NotificationEntryManager; |
| 78 | import com.android.systemui.statusbar.NotificationGutsManager; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 79 | import com.android.systemui.statusbar.NotificationListContainer; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 80 | import com.android.systemui.statusbar.NotificationListener; |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 81 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 82 | import com.android.systemui.statusbar.NotificationLogger; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 83 | import com.android.systemui.statusbar.NotificationMediaManager; |
| 84 | import com.android.systemui.statusbar.NotificationPresenter; |
| 85 | import com.android.systemui.statusbar.NotificationRemoteInputManager; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 86 | import com.android.systemui.statusbar.NotificationViewHierarchyManager; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 87 | import com.android.systemui.statusbar.StatusBarState; |
Selim Cinek | 7e222c3c | 2018-01-25 12:22:41 -0800 | [diff] [blame] | 88 | import com.android.systemui.statusbar.notification.ActivityLaunchAnimator; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 89 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 90 | import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 91 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 92 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
| 93 | import com.android.systemui.statusbar.policy.KeyguardMonitorImpl; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 94 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 95 | |
| 96 | import org.junit.Before; |
| 97 | import org.junit.Test; |
| 98 | import org.junit.runner.RunWith; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 99 | import org.mockito.Mock; |
| 100 | import org.mockito.MockitoAnnotations; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 101 | |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 102 | import java.io.ByteArrayOutputStream; |
| 103 | import java.io.PrintWriter; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 104 | import java.util.ArrayList; |
| 105 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 106 | @SmallTest |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 107 | @RunWith(AndroidTestingRunner.class) |
| 108 | @RunWithLooper |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 109 | public class StatusBarTest extends SysuiTestCase { |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 110 | @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; |
| 111 | @Mock private UnlockMethodCache mUnlockMethodCache; |
| 112 | @Mock private KeyguardIndicationController mKeyguardIndicationController; |
| 113 | @Mock private NotificationStackScrollLayout mStackScroller; |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 114 | @Mock private HeadsUpManagerPhone mHeadsUpManager; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 115 | @Mock private SystemServicesProxy mSystemServicesProxy; |
| 116 | @Mock private NotificationPanelView mNotificationPanelView; |
| 117 | @Mock private IStatusBarService mBarService; |
| 118 | @Mock private ScrimController mScrimController; |
| 119 | @Mock private ArrayList<Entry> mNotificationList; |
| 120 | @Mock private FingerprintUnlockController mFingerprintUnlockController; |
| 121 | @Mock private NotificationData mNotificationData; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 122 | |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 123 | // Mock dependencies: |
| 124 | @Mock private NotificationViewHierarchyManager mViewHierarchyManager; |
| 125 | @Mock private VisualStabilityManager mVisualStabilityManager; |
| 126 | @Mock private NotificationListener mNotificationListener; |
| 127 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 128 | private TestableStatusBar mStatusBar; |
| 129 | private FakeMetricsLogger mMetricsLogger; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 130 | private PowerManager mPowerManager; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 131 | private TestableNotificationEntryManager mEntryManager; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 132 | private NotificationLogger mNotificationLogger; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 133 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 134 | @Before |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 135 | public void setup() throws Exception { |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 136 | MockitoAnnotations.initMocks(this); |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 137 | mDependency.injectMockDependency(AssistManager.class); |
| 138 | mDependency.injectMockDependency(DeviceProvisionedController.class); |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 139 | mDependency.injectMockDependency(NotificationGroupManager.class); |
| 140 | mDependency.injectMockDependency(NotificationGutsManager.class); |
| 141 | mDependency.injectMockDependency(NotificationRemoteInputManager.class); |
| 142 | mDependency.injectMockDependency(NotificationMediaManager.class); |
| 143 | mDependency.injectMockDependency(ForegroundServiceController.class); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 144 | mDependency.injectTestDependency(NotificationViewHierarchyManager.class, |
| 145 | mViewHierarchyManager); |
| 146 | mDependency.injectTestDependency(VisualStabilityManager.class, mVisualStabilityManager); |
| 147 | mDependency.injectTestDependency(NotificationListener.class, mNotificationListener); |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 148 | mDependency.injectTestDependency(KeyguardMonitor.class, mock(KeyguardMonitorImpl.class)); |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 149 | mDependency.injectTestDependency(AppOpsListener.class, mock(AppOpsListener.class)); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 150 | |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 151 | mContext.addMockSystemService(TrustManager.class, mock(TrustManager.class)); |
| 152 | mContext.addMockSystemService(FingerprintManager.class, mock(FingerprintManager.class)); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 153 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 154 | mMetricsLogger = new FakeMetricsLogger(); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 155 | mDependency.injectTestDependency(MetricsLogger.class, mMetricsLogger); |
Eliot Courtney | 6c313d3 | 2017-12-14 19:57:51 +0900 | [diff] [blame] | 156 | mNotificationLogger = new NotificationLogger(); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 157 | mDependency.injectTestDependency(NotificationLogger.class, mNotificationLogger); |
| 158 | |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 159 | IPowerManager powerManagerService = mock(IPowerManager.class); |
| 160 | HandlerThread handlerThread = new HandlerThread("TestThread"); |
| 161 | handlerThread.start(); |
| 162 | mPowerManager = new PowerManager(mContext, powerManagerService, |
| 163 | new Handler(handlerThread.getLooper())); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 164 | |
| 165 | CommandQueue commandQueue = mock(CommandQueue.class); |
| 166 | when(commandQueue.asBinder()).thenReturn(new Binder()); |
| 167 | mContext.putComponent(CommandQueue.class, commandQueue); |
| 168 | |
| 169 | mContext.setTheme(R.style.Theme_SystemUI_Light); |
| 170 | |
| 171 | when(mStackScroller.generateLayoutParams(any())).thenReturn(new LayoutParams(0, 0)); |
| 172 | when(mNotificationPanelView.getLayoutParams()).thenReturn(new LayoutParams(0, 0)); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 173 | when(powerManagerService.isInteractive()).thenReturn(true); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 174 | when(mStackScroller.getActivatedChild()).thenReturn(null); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 175 | |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 176 | doAnswer(invocation -> { |
| 177 | OnDismissAction onDismissAction = (OnDismissAction) invocation.getArguments()[0]; |
| 178 | onDismissAction.onDismiss(); |
| 179 | return null; |
| 180 | }).when(mStatusBarKeyguardViewManager).dismissWithAction(any(), any(), anyBoolean()); |
| 181 | |
| 182 | doAnswer(invocation -> { |
| 183 | Runnable runnable = (Runnable) invocation.getArguments()[0]; |
| 184 | runnable.run(); |
| 185 | return null; |
| 186 | }).when(mStatusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(any()); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 187 | |
Eliot Courtney | 6c313d3 | 2017-12-14 19:57:51 +0900 | [diff] [blame] | 188 | mEntryManager = new TestableNotificationEntryManager(mSystemServicesProxy, mPowerManager, |
| 189 | mContext); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 190 | mStatusBar = new TestableStatusBar(mStatusBarKeyguardViewManager, mUnlockMethodCache, |
| 191 | mKeyguardIndicationController, mStackScroller, mHeadsUpManager, |
| 192 | mPowerManager, mNotificationPanelView, mBarService, mNotificationListener, |
| 193 | mNotificationLogger, mVisualStabilityManager, mViewHierarchyManager, |
Selim Cinek | 7e222c3c | 2018-01-25 12:22:41 -0800 | [diff] [blame] | 194 | mEntryManager, mScrimController, mFingerprintUnlockController, |
| 195 | mock(ActivityLaunchAnimator.class)); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 196 | mStatusBar.mContext = mContext; |
| 197 | mStatusBar.mComponents = mContext.getComponents(); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 198 | mEntryManager.setUpForTest(mStatusBar, mStackScroller, mStatusBar, mHeadsUpManager, |
| 199 | mNotificationData); |
Eliot Courtney | 4a96b36 | 2017-12-14 19:38:52 +0900 | [diff] [blame] | 200 | mNotificationLogger.setUpWithEntryManager(mEntryManager, mStackScroller); |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 201 | |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 202 | TestableLooper.get(this).setMessageHandler(m -> { |
| 203 | if (m.getCallback() == mStatusBar.mNotificationLogger.getVisibilityReporter()) { |
| 204 | return false; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 205 | } |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 206 | return true; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 207 | }); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 208 | } |
| 209 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 210 | @Test |
Jason Monk | 5ecf80c | 2017-07-06 15:28:17 -0400 | [diff] [blame] | 211 | public void testSetBouncerShowing_noCrash() { |
| 212 | mStatusBar.mCommandQueue = mock(CommandQueue.class); |
| 213 | mStatusBar.setBouncerShowing(true); |
| 214 | } |
| 215 | |
| 216 | @Test |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 217 | public void executeRunnableDismissingKeyguard_nullRunnable_showingAndOccluded() { |
| 218 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 219 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(true); |
| 220 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 221 | mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 222 | } |
| 223 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 224 | @Test |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 225 | public void executeRunnableDismissingKeyguard_nullRunnable_showing() { |
| 226 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 227 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 228 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 229 | mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 230 | } |
| 231 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 232 | @Test |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 233 | public void executeRunnableDismissingKeyguard_nullRunnable_notShowing() { |
| 234 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); |
| 235 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 236 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 237 | mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 238 | } |
| 239 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 240 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 241 | public void lockscreenStateMetrics_notShowing() { |
| 242 | // uninteresting state, except that fingerprint must be non-zero |
| 243 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 244 | when(mUnlockMethodCache.canSkipBouncer()).thenReturn(true); |
| 245 | // interesting state |
| 246 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); |
| 247 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
| 248 | when(mUnlockMethodCache.isMethodSecure()).thenReturn(false); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 249 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 250 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 251 | MetricsAsserts.assertHasLog("missing hidden insecure lockscreen log", |
| 252 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 253 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 254 | .setType(MetricsEvent.TYPE_CLOSE) |
| 255 | .setSubtype(0)); |
| 256 | } |
| 257 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 258 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 259 | public void lockscreenStateMetrics_notShowing_secure() { |
| 260 | // uninteresting state, except that fingerprint must be non-zero |
| 261 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 262 | when(mUnlockMethodCache.canSkipBouncer()).thenReturn(true); |
| 263 | // interesting state |
| 264 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); |
| 265 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
| 266 | when(mUnlockMethodCache.isMethodSecure()).thenReturn(true); |
| 267 | |
| 268 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 269 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 270 | MetricsAsserts.assertHasLog("missing hidden secure lockscreen log", |
| 271 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 272 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 273 | .setType(MetricsEvent.TYPE_CLOSE) |
| 274 | .setSubtype(1)); |
| 275 | } |
| 276 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 277 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 278 | public void lockscreenStateMetrics_isShowing() { |
| 279 | // uninteresting state, except that fingerprint must be non-zero |
| 280 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 281 | when(mUnlockMethodCache.canSkipBouncer()).thenReturn(true); |
| 282 | // interesting state |
| 283 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 284 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
| 285 | when(mUnlockMethodCache.isMethodSecure()).thenReturn(false); |
| 286 | |
| 287 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 288 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 289 | MetricsAsserts.assertHasLog("missing insecure lockscreen showing", |
| 290 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 291 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 292 | .setType(MetricsEvent.TYPE_OPEN) |
| 293 | .setSubtype(0)); |
| 294 | } |
| 295 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 296 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 297 | public void lockscreenStateMetrics_isShowing_secure() { |
| 298 | // uninteresting state, except that fingerprint must be non-zero |
| 299 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 300 | when(mUnlockMethodCache.canSkipBouncer()).thenReturn(true); |
| 301 | // interesting state |
| 302 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 303 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
| 304 | when(mUnlockMethodCache.isMethodSecure()).thenReturn(true); |
| 305 | |
| 306 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 307 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 308 | MetricsAsserts.assertHasLog("missing secure lockscreen showing log", |
| 309 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 310 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 311 | .setType(MetricsEvent.TYPE_OPEN) |
| 312 | .setSubtype(1)); |
| 313 | } |
| 314 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 315 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 316 | public void lockscreenStateMetrics_isShowingBouncer() { |
| 317 | // uninteresting state, except that fingerprint must be non-zero |
| 318 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 319 | when(mUnlockMethodCache.canSkipBouncer()).thenReturn(true); |
| 320 | // interesting state |
| 321 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 322 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(true); |
| 323 | when(mUnlockMethodCache.isMethodSecure()).thenReturn(true); |
| 324 | |
| 325 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 326 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 327 | MetricsAsserts.assertHasLog("missing bouncer log", |
| 328 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 329 | new LogMaker(MetricsEvent.BOUNCER) |
| 330 | .setType(MetricsEvent.TYPE_OPEN) |
| 331 | .setSubtype(1)); |
| 332 | } |
| 333 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 334 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 335 | public void onActivatedMetrics() { |
| 336 | ActivatableNotificationView view = mock(ActivatableNotificationView.class); |
| 337 | mStatusBar.onActivated(view); |
| 338 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 339 | MetricsAsserts.assertHasLog("missing lockscreen note tap log", |
| 340 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 341 | new LogMaker(MetricsEvent.ACTION_LS_NOTE) |
| 342 | .setType(MetricsEvent.TYPE_ACTION)); |
| 343 | } |
| 344 | |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 345 | @Test |
| 346 | public void testShouldPeek_nonSuppressedGroupSummary() { |
| 347 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 348 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
Julia Reynolds | 24653c3 | 2018-03-02 13:16:37 -0500 | [diff] [blame^] | 349 | when(mNotificationData.shouldSuppressStatusBar(any())).thenReturn(false); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 350 | when(mNotificationData.shouldFilterOut(any())).thenReturn(false); |
| 351 | when(mSystemServicesProxy.isDreaming()).thenReturn(false); |
| 352 | when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); |
| 353 | |
| 354 | Notification n = new Notification.Builder(getContext(), "a") |
| 355 | .setGroup("a") |
| 356 | .setGroupSummary(true) |
| 357 | .setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY) |
| 358 | .build(); |
| 359 | StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, |
| 360 | UserHandle.of(0), null, 0); |
| 361 | NotificationData.Entry entry = new NotificationData.Entry(sbn); |
| 362 | |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 363 | assertTrue(mEntryManager.shouldPeek(entry, sbn)); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | @Test |
| 367 | public void testShouldPeek_suppressedGroupSummary() { |
| 368 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 369 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
Julia Reynolds | 24653c3 | 2018-03-02 13:16:37 -0500 | [diff] [blame^] | 370 | when(mNotificationData.shouldSuppressStatusBar(any())).thenReturn(false); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 371 | when(mNotificationData.shouldFilterOut(any())).thenReturn(false); |
| 372 | when(mSystemServicesProxy.isDreaming()).thenReturn(false); |
| 373 | when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); |
| 374 | |
| 375 | Notification n = new Notification.Builder(getContext(), "a") |
| 376 | .setGroup("a") |
| 377 | .setGroupSummary(true) |
| 378 | .setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN) |
| 379 | .build(); |
| 380 | StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, |
| 381 | UserHandle.of(0), null, 0); |
| 382 | NotificationData.Entry entry = new NotificationData.Entry(sbn); |
| 383 | |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 384 | assertFalse(mEntryManager.shouldPeek(entry, sbn)); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 385 | } |
| 386 | |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 387 | @Test |
Julia Reynolds | 24653c3 | 2018-03-02 13:16:37 -0500 | [diff] [blame^] | 388 | public void testShouldPeek_suppressedPeek() { |
Beverly | 38159ce | 2017-07-13 16:39:24 -0400 | [diff] [blame] | 389 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 390 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
| 391 | when(mNotificationData.shouldFilterOut(any())).thenReturn(false); |
| 392 | when(mSystemServicesProxy.isDreaming()).thenReturn(false); |
| 393 | when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); |
| 394 | |
Julia Reynolds | 24653c3 | 2018-03-02 13:16:37 -0500 | [diff] [blame^] | 395 | when(mNotificationData.shouldSuppressPeek(any())).thenReturn(true); |
| 396 | |
| 397 | Notification n = new Notification.Builder(getContext(), "a").build(); |
| 398 | StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, |
| 399 | UserHandle.of(0), null, 0); |
| 400 | NotificationData.Entry entry = new NotificationData.Entry(sbn); |
| 401 | |
| 402 | assertFalse(mEntryManager.shouldPeek(entry, sbn)); |
| 403 | } |
| 404 | |
| 405 | @Test |
| 406 | public void testShouldPeek_noSuppressedPeek() { |
| 407 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 408 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
| 409 | when(mNotificationData.shouldFilterOut(any())).thenReturn(false); |
| 410 | when(mSystemServicesProxy.isDreaming()).thenReturn(false); |
| 411 | when(mNotificationData.getImportance(any())).thenReturn(IMPORTANCE_HIGH); |
| 412 | |
| 413 | when(mNotificationData.shouldSuppressPeek(any())).thenReturn(false); |
Beverly | 38159ce | 2017-07-13 16:39:24 -0400 | [diff] [blame] | 414 | |
| 415 | Notification n = new Notification.Builder(getContext(), "a").build(); |
| 416 | StatusBarNotification sbn = new StatusBarNotification("a", "a", 0, "a", 0, 0, n, |
| 417 | UserHandle.of(0), null, 0); |
| 418 | NotificationData.Entry entry = new NotificationData.Entry(sbn); |
| 419 | |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 420 | assertTrue(mEntryManager.shouldPeek(entry, sbn)); |
Beverly | 38159ce | 2017-07-13 16:39:24 -0400 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | @Test |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 424 | public void testLogHidden() { |
| 425 | try { |
| 426 | mStatusBar.handleVisibleToUserChanged(false); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 427 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 428 | verify(mBarService, times(1)).onPanelHidden(); |
| 429 | verify(mBarService, never()).onPanelRevealed(anyBoolean(), anyInt()); |
| 430 | } catch (RemoteException e) { |
| 431 | fail(); |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | @Test |
| 436 | public void testPanelOpenForPeek() { |
| 437 | when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); |
| 438 | when(mNotificationData.getActiveNotifications()).thenReturn(mNotificationList); |
| 439 | when(mNotificationList.size()).thenReturn(5); |
| 440 | when(mNotificationPanelView.isFullyCollapsed()).thenReturn(true); |
| 441 | mStatusBar.setBarStateForTest(StatusBarState.SHADE); |
| 442 | |
| 443 | try { |
| 444 | mStatusBar.handleVisibleToUserChanged(true); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 445 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 446 | verify(mBarService, never()).onPanelHidden(); |
| 447 | verify(mBarService, times(1)).onPanelRevealed(false, 1); |
| 448 | } catch (RemoteException e) { |
| 449 | fail(); |
| 450 | } |
| 451 | TestableLooper.get(this).processAllMessages(); |
| 452 | } |
| 453 | |
| 454 | @Test |
| 455 | public void testPanelOpenAndClear() { |
| 456 | when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); |
| 457 | when(mNotificationData.getActiveNotifications()).thenReturn(mNotificationList); |
| 458 | when(mNotificationList.size()).thenReturn(5); |
| 459 | when(mNotificationPanelView.isFullyCollapsed()).thenReturn(false); |
| 460 | mStatusBar.setBarStateForTest(StatusBarState.SHADE); |
| 461 | |
| 462 | try { |
| 463 | mStatusBar.handleVisibleToUserChanged(true); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 464 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 465 | verify(mBarService, never()).onPanelHidden(); |
| 466 | verify(mBarService, times(1)).onPanelRevealed(true, 5); |
| 467 | } catch (RemoteException e) { |
| 468 | fail(); |
| 469 | } |
| 470 | TestableLooper.get(this).processAllMessages(); |
| 471 | } |
| 472 | |
| 473 | @Test |
| 474 | public void testPanelOpenAndNoClear() { |
| 475 | when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); |
| 476 | when(mNotificationData.getActiveNotifications()).thenReturn(mNotificationList); |
| 477 | when(mNotificationList.size()).thenReturn(5); |
| 478 | when(mNotificationPanelView.isFullyCollapsed()).thenReturn(false); |
| 479 | mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); |
| 480 | |
| 481 | try { |
| 482 | mStatusBar.handleVisibleToUserChanged(true); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 483 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 484 | verify(mBarService, never()).onPanelHidden(); |
| 485 | verify(mBarService, times(1)).onPanelRevealed(false, 5); |
| 486 | } catch (RemoteException e) { |
| 487 | fail(); |
| 488 | } |
| 489 | TestableLooper.get(this).processAllMessages(); |
| 490 | } |
| 491 | |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 492 | @Test |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 493 | public void testDisableExpandStatusBar() { |
| 494 | mStatusBar.setBarStateForTest(StatusBarState.SHADE); |
| 495 | mStatusBar.setUserSetupForTest(true); |
| 496 | when(mStatusBar.isDeviceProvisioned()).thenReturn(true); |
| 497 | |
| 498 | mStatusBar.disable(StatusBarManager.DISABLE_NONE, |
| 499 | StatusBarManager.DISABLE2_NOTIFICATION_SHADE, false); |
| 500 | verify(mNotificationPanelView).setQsExpansionEnabled(false); |
| 501 | mStatusBar.animateExpandNotificationsPanel(); |
| 502 | verify(mNotificationPanelView, never()).expand(anyBoolean()); |
| 503 | mStatusBar.animateExpandSettingsPanel(null); |
| 504 | verify(mNotificationPanelView, never()).expand(anyBoolean()); |
| 505 | |
| 506 | mStatusBar.disable(StatusBarManager.DISABLE_NONE, StatusBarManager.DISABLE2_NONE, false); |
| 507 | verify(mNotificationPanelView).setQsExpansionEnabled(true); |
| 508 | mStatusBar.animateExpandNotificationsPanel(); |
| 509 | verify(mNotificationPanelView).expand(anyBoolean()); |
| 510 | mStatusBar.animateExpandSettingsPanel(null); |
| 511 | verify(mNotificationPanelView).expand(anyBoolean()); |
| 512 | } |
| 513 | |
| 514 | @Test |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 515 | public void testDump_DoesNotCrash() { |
| 516 | mStatusBar.dump(null, new PrintWriter(new ByteArrayOutputStream()), null); |
| 517 | } |
| 518 | |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 519 | @Test |
| 520 | @RunWithLooper(setAsMainLooper = true) |
| 521 | public void testUpdateKeyguardState_DoesNotCrash() { |
| 522 | mStatusBar.mStatusBarWindow = mock(StatusBarWindowView.class); |
| 523 | mStatusBar.mState = StatusBarState.KEYGUARD; |
| 524 | mStatusBar.mDozeScrimController = mock(DozeScrimController.class); |
| 525 | mStatusBar.mNotificationIconAreaController = mock(NotificationIconAreaController.class); |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 526 | mStatusBar.mLockscreenUserManager = mock(NotificationLockscreenUserManager.class); |
| 527 | when(mStatusBar.mLockscreenUserManager.getCurrentProfiles()).thenReturn( |
| 528 | new SparseArray<>()); |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 529 | mStatusBar.updateKeyguardState(false, false); |
| 530 | } |
| 531 | |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 532 | @Test |
| 533 | public void testFingerprintNotification_UpdatesScrims() { |
| 534 | mStatusBar.mStatusBarWindowManager = mock(StatusBarWindowManager.class); |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 535 | mStatusBar.mDozeScrimController = mock(DozeScrimController.class); |
Julia Reynolds | 24653c3 | 2018-03-02 13:16:37 -0500 | [diff] [blame^] | 536 | mStatusBar.mNotificationIconAreaController = mock(NotificationIconAreaController.class); |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 537 | mStatusBar.notifyFpAuthModeChanged(); |
| 538 | verify(mScrimController).transitionTo(any(), any()); |
| 539 | } |
| 540 | |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 541 | @Test |
| 542 | public void testFingerprintUnlock_UpdatesScrims() { |
| 543 | // Simulate unlocking from AoD with fingerprint. |
| 544 | when(mFingerprintUnlockController.getMode()) |
| 545 | .thenReturn(FingerprintUnlockController.MODE_WAKE_AND_UNLOCK); |
| 546 | mStatusBar.updateScrimController(); |
| 547 | verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); |
| 548 | } |
| 549 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 550 | static class TestableStatusBar extends StatusBar { |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 551 | public TestableStatusBar(StatusBarKeyguardViewManager man, |
| 552 | UnlockMethodCache unlock, KeyguardIndicationController key, |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 553 | NotificationStackScrollLayout stack, HeadsUpManagerPhone hum, |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 554 | PowerManager pm, NotificationPanelView panelView, |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 555 | IStatusBarService barService, NotificationListener notificationListener, |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 556 | NotificationLogger notificationLogger, |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 557 | VisualStabilityManager visualStabilityManager, |
| 558 | NotificationViewHierarchyManager viewHierarchyManager, |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 559 | TestableNotificationEntryManager entryManager, ScrimController scrimController, |
Selim Cinek | 7e222c3c | 2018-01-25 12:22:41 -0800 | [diff] [blame] | 560 | FingerprintUnlockController fingerprintUnlockController, |
| 561 | ActivityLaunchAnimator launchAnimator) { |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 562 | mStatusBarKeyguardViewManager = man; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 563 | mUnlockMethodCache = unlock; |
| 564 | mKeyguardIndicationController = key; |
| 565 | mStackScroller = stack; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 566 | mHeadsUpManager = hum; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 567 | mPowerManager = pm; |
Jorim Jaggi | fd3b1a1 | 2017-06-06 17:04:19 -0700 | [diff] [blame] | 568 | mNotificationPanel = panelView; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 569 | mBarService = barService; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 570 | mNotificationListener = notificationListener; |
| 571 | mNotificationLogger = notificationLogger; |
Adrian Roos | 6d5ebb7 | 2017-08-03 15:10:22 +0200 | [diff] [blame] | 572 | mWakefulnessLifecycle = createAwakeWakefulnessLifecycle(); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 573 | mVisualStabilityManager = visualStabilityManager; |
| 574 | mViewHierarchyManager = viewHierarchyManager; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 575 | mEntryManager = entryManager; |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 576 | mScrimController = scrimController; |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 577 | mFingerprintUnlockController = fingerprintUnlockController; |
Selim Cinek | 7e222c3c | 2018-01-25 12:22:41 -0800 | [diff] [blame] | 578 | mActivityLaunchAnimator = launchAnimator; |
Adrian Roos | 6d5ebb7 | 2017-08-03 15:10:22 +0200 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | private WakefulnessLifecycle createAwakeWakefulnessLifecycle() { |
| 582 | WakefulnessLifecycle wakefulnessLifecycle = new WakefulnessLifecycle(); |
| 583 | wakefulnessLifecycle.dispatchStartedWakingUp(); |
| 584 | wakefulnessLifecycle.dispatchFinishedWakingUp(); |
| 585 | return wakefulnessLifecycle; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 586 | } |
| 587 | |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 588 | @Override |
| 589 | protected void updateTheme() { |
| 590 | // Do nothing for now, until we have more mocking and StatusBar is smaller. |
| 591 | } |
| 592 | |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 593 | public void setBarStateForTest(int state) { |
| 594 | mState = state; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 595 | } |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 596 | |
| 597 | public void setUserSetupForTest(boolean userSetup) { |
| 598 | mUserSetup = userSetup; |
| 599 | } |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 600 | |
| 601 | } |
| 602 | |
| 603 | private class TestableNotificationEntryManager extends NotificationEntryManager { |
| 604 | |
Eliot Courtney | 6c313d3 | 2017-12-14 19:57:51 +0900 | [diff] [blame] | 605 | public TestableNotificationEntryManager(SystemServicesProxy systemServicesProxy, |
| 606 | PowerManager powerManager, Context context) { |
| 607 | super(context); |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 608 | mSystemServicesProxy = systemServicesProxy; |
| 609 | mPowerManager = powerManager; |
| 610 | } |
| 611 | |
| 612 | public void setUpForTest(NotificationPresenter presenter, |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 613 | NotificationListContainer listContainer, |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 614 | Callback callback, |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 615 | HeadsUpManagerPhone headsUpManager, |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 616 | NotificationData notificationData) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 617 | super.setUpWithPresenter(presenter, listContainer, callback, headsUpManager); |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 618 | mNotificationData = notificationData; |
| 619 | mUseHeadsUp = true; |
| 620 | } |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 621 | } |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 622 | } |