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; |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 20 | import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 21 | import static android.view.Display.DEFAULT_DISPLAY; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 22 | |
| 23 | import static junit.framework.Assert.assertFalse; |
| 24 | import static junit.framework.Assert.assertTrue; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 25 | import static junit.framework.TestCase.fail; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 26 | |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 27 | import static org.mockito.ArgumentMatchers.any; |
| 28 | import static org.mockito.ArgumentMatchers.anyBoolean; |
| 29 | import static org.mockito.ArgumentMatchers.anyInt; |
| 30 | import static org.mockito.ArgumentMatchers.anyString; |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 31 | import static org.mockito.ArgumentMatchers.eq; |
Lucas Dupin | 3cfd688 | 2019-03-19 15:22:03 -0700 | [diff] [blame] | 32 | import static org.mockito.Mockito.clearInvocations; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 33 | import static org.mockito.Mockito.doAnswer; |
| 34 | import static org.mockito.Mockito.mock; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 35 | import static org.mockito.Mockito.never; |
Lucas Dupin | d510730 | 2018-03-19 15:30:29 -0700 | [diff] [blame] | 36 | import static org.mockito.Mockito.reset; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 37 | import static org.mockito.Mockito.times; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 38 | import static org.mockito.Mockito.verify; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 39 | import static org.mockito.Mockito.when; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 40 | |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 41 | import android.app.Notification; |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 42 | import android.app.StatusBarManager; |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 43 | import android.app.trust.TrustManager; |
Fabian Kozynski | ff5e91f | 2019-09-24 15:38:08 -0400 | [diff] [blame] | 44 | import android.content.BroadcastReceiver; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 45 | import android.content.Context; |
Fabian Kozynski | ff5e91f | 2019-09-24 15:38:08 -0400 | [diff] [blame] | 46 | import android.content.IntentFilter; |
Lucas Dupin | 2c3992b | 2019-03-11 16:34:08 -0700 | [diff] [blame] | 47 | import android.hardware.display.AmbientDisplayConfiguration; |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 48 | import android.hardware.fingerprint.FingerprintManager; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 49 | import android.metrics.LogMaker; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 50 | import android.os.Binder; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 51 | import android.os.Handler; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 52 | import android.os.IPowerManager; |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 53 | import android.os.Looper; |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 54 | import android.os.PowerManager; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 55 | import android.os.RemoteException; |
Fabian Kozynski | ff5e91f | 2019-09-24 15:38:08 -0400 | [diff] [blame] | 56 | import android.os.UserHandle; |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 57 | import android.service.dreams.IDreamManager; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 58 | import android.support.test.metricshelper.MetricsAsserts; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 59 | import android.testing.AndroidTestingRunner; |
| 60 | import android.testing.TestableLooper; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 61 | import android.testing.TestableLooper.RunWithLooper; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 62 | import android.util.DisplayMetrics; |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 63 | import android.util.SparseArray; |
Dave Mankoff | bbc2f8f | 2019-10-21 12:21:29 -0400 | [diff] [blame] | 64 | import android.view.ViewGroup; |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 65 | import android.view.ViewGroup.LayoutParams; |
Dave Mankoff | bbc2f8f | 2019-10-21 12:21:29 -0400 | [diff] [blame] | 66 | import android.widget.LinearLayout; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 67 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 68 | import androidx.test.filters.SmallTest; |
| 69 | |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 70 | import com.android.internal.colorextraction.ColorExtractor; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 71 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 72 | import com.android.internal.logging.testing.FakeMetricsLogger; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 73 | import com.android.internal.statusbar.IStatusBarService; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 74 | import com.android.keyguard.KeyguardUpdateMonitor; |
Dave Mankoff | bbc2f8f | 2019-10-21 12:21:29 -0400 | [diff] [blame] | 75 | import com.android.keyguard.ViewMediatorCallback; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 76 | import com.android.systemui.Dependency; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 77 | import com.android.systemui.ForegroundServiceController; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 78 | import com.android.systemui.InitController; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 79 | import com.android.systemui.R; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 80 | import com.android.systemui.SysuiTestCase; |
Jason Monk | d97204c | 2018-12-21 15:49:04 -0500 | [diff] [blame] | 81 | import com.android.systemui.UiOffloadThread; |
Fabian Kozynski | 1f32cf0 | 2018-10-23 12:23:31 -0400 | [diff] [blame] | 82 | import com.android.systemui.appops.AppOpsController; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 83 | import com.android.systemui.assist.AssistManager; |
Fabian Kozynski | ff5e91f | 2019-09-24 15:38:08 -0400 | [diff] [blame] | 84 | import com.android.systemui.broadcast.BroadcastDispatcher; |
Mady Mellor | cd9b130 | 2018-11-06 18:08:04 -0800 | [diff] [blame] | 85 | import com.android.systemui.bubbles.BubbleController; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 86 | import com.android.systemui.classifier.FalsingManagerFake; |
| 87 | import com.android.systemui.colorextraction.SysuiColorExtractor; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 88 | import com.android.systemui.doze.DozeLog; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 89 | import com.android.systemui.keyguard.KeyguardViewMediator; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 90 | import com.android.systemui.keyguard.ScreenLifecycle; |
Adrian Roos | 6d5ebb7 | 2017-08-03 15:10:22 +0200 | [diff] [blame] | 91 | import com.android.systemui.keyguard.WakefulnessLifecycle; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 92 | import com.android.systemui.plugins.ActivityStarter.OnDismissAction; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 93 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Jason Monk | 5ecf80c | 2017-07-06 15:28:17 -0400 | [diff] [blame] | 94 | import com.android.systemui.statusbar.CommandQueue; |
Ned Burns | f098dbf | 2019-09-13 19:17:53 -0400 | [diff] [blame] | 95 | import com.android.systemui.statusbar.FeatureFlags; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 96 | import com.android.systemui.statusbar.KeyguardIndicationController; |
Charles Chen | 10ca70b | 2018-11-28 00:03:38 +0800 | [diff] [blame] | 97 | import com.android.systemui.statusbar.NavigationBarController; |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 98 | import com.android.systemui.statusbar.NotificationEntryBuilder; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 99 | import com.android.systemui.statusbar.NotificationListener; |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 100 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 101 | import com.android.systemui.statusbar.NotificationMediaManager; |
| 102 | import com.android.systemui.statusbar.NotificationPresenter; |
| 103 | import com.android.systemui.statusbar.NotificationRemoteInputManager; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 104 | import com.android.systemui.statusbar.NotificationViewHierarchyManager; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 105 | import com.android.systemui.statusbar.PulseExpansionHandler; |
Selim Cinek | 7c6fe5b | 2018-04-09 18:27:13 -0700 | [diff] [blame] | 106 | import com.android.systemui.statusbar.RemoteInputController; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 107 | import com.android.systemui.statusbar.StatusBarState; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 108 | import com.android.systemui.statusbar.StatusBarStateControllerImpl; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 109 | import com.android.systemui.statusbar.VibratorHelper; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 110 | import com.android.systemui.statusbar.notification.BypassHeadsUpNotifier; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 111 | import com.android.systemui.statusbar.notification.DynamicPrivacyController; |
Ned Burns | f098dbf | 2019-09-13 19:17:53 -0400 | [diff] [blame] | 112 | import com.android.systemui.statusbar.notification.NewNotifPipeline; |
Gus Prevas | b43dc65 | 2018-12-20 13:11:45 -0500 | [diff] [blame] | 113 | import com.android.systemui.statusbar.notification.NotificationAlertingManager; |
Gus Prevas | 26bc59b | 2018-12-19 11:26:39 -0500 | [diff] [blame] | 114 | import com.android.systemui.statusbar.notification.NotificationEntryListener; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 115 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 116 | import com.android.systemui.statusbar.notification.NotificationFilter; |
| 117 | import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 118 | import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 119 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 120 | import com.android.systemui.statusbar.notification.collection.NotificationData; |
| 121 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Beverly | 85d4c19 | 2019-09-30 11:40:39 -0400 | [diff] [blame] | 122 | import com.android.systemui.statusbar.notification.logging.NotifLog; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 123 | import com.android.systemui.statusbar.notification.logging.NotificationLogger; |
| 124 | import com.android.systemui.statusbar.notification.row.NotificationGutsManager; |
| 125 | import com.android.systemui.statusbar.notification.stack.NotificationListContainer; |
| 126 | import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; |
Lucas Dupin | bd7366d | 2019-09-25 13:39:21 -0700 | [diff] [blame] | 127 | import com.android.systemui.statusbar.policy.BatteryController; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 128 | import com.android.systemui.statusbar.policy.ConfigurationController; |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 129 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 130 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 131 | import com.android.systemui.statusbar.policy.NetworkController; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 132 | import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; |
jovanak | 5f6dc61 | 2018-03-27 11:59:22 -0700 | [diff] [blame] | 133 | import com.android.systemui.statusbar.policy.UserSwitcherController; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 134 | import com.android.systemui.statusbar.policy.ZenModeController; |
| 135 | import com.android.systemui.util.InjectionInflationController; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 136 | |
| 137 | import org.junit.Before; |
| 138 | import org.junit.Test; |
| 139 | import org.junit.runner.RunWith; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 140 | import org.mockito.Mock; |
| 141 | import org.mockito.MockitoAnnotations; |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 142 | |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 143 | import java.io.ByteArrayOutputStream; |
| 144 | import java.io.PrintWriter; |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 145 | import java.util.ArrayList; |
| 146 | |
Dave Mankoff | a874996 | 2019-10-18 10:44:07 -0400 | [diff] [blame] | 147 | import dagger.Lazy; |
| 148 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 149 | @SmallTest |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 150 | @RunWith(AndroidTestingRunner.class) |
Dave Mankoff | fd18b14 | 2019-09-30 16:59:55 -0400 | [diff] [blame] | 151 | @RunWithLooper(setAsMainLooper = true) |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 152 | public class StatusBarTest extends SysuiTestCase { |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 153 | |
| 154 | private StatusBar mStatusBar; |
| 155 | private FakeMetricsLogger mMetricsLogger; |
| 156 | private PowerManager mPowerManager; |
| 157 | private TestableNotificationInterruptionStateProvider mNotificationInterruptionStateProvider; |
| 158 | private CommandQueue mCommandQueue; |
| 159 | |
Ned Burns | f098dbf | 2019-09-13 19:17:53 -0400 | [diff] [blame] | 160 | @Mock private FeatureFlags mFeatureFlags; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 161 | @Mock private LightBarController mLightBarController; |
| 162 | @Mock private StatusBarIconController mStatusBarIconController; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 163 | @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 164 | @Mock private KeyguardStateController mKeyguardStateController; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 165 | @Mock private KeyguardIndicationController mKeyguardIndicationController; |
| 166 | @Mock private NotificationStackScrollLayout mStackScroller; |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 167 | @Mock private HeadsUpManagerPhone mHeadsUpManager; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 168 | @Mock private NotificationPanelView mNotificationPanelView; |
| 169 | @Mock private IStatusBarService mBarService; |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 170 | @Mock private IDreamManager mDreamManager; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 171 | @Mock private ScrimController mScrimController; |
Lucas Dupin | 988efb2 | 2018-12-04 16:53:58 -0800 | [diff] [blame] | 172 | @Mock private DozeScrimController mDozeScrimController; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 173 | @Mock private ArrayList<NotificationEntry> mNotificationList; |
Dave Mankoff | bbc2f8f | 2019-10-21 12:21:29 -0400 | [diff] [blame] | 174 | @Mock private Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 175 | @Mock private BiometricUnlockController mBiometricUnlockController; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 176 | @Mock private NotificationData mNotificationData; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 177 | @Mock private NotificationInterruptionStateProvider.HeadsUpSuppressor mHeadsUpSuppressor; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 178 | @Mock private VisualStabilityManager mVisualStabilityManager; |
| 179 | @Mock private NotificationListener mNotificationListener; |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 180 | @Mock private KeyguardViewMediator mKeyguardViewMediator; |
jovanak | 5f6dc61 | 2018-03-27 11:59:22 -0700 | [diff] [blame] | 181 | @Mock private NotificationLockscreenUserManager mLockscreenUserManager; |
Selim Cinek | 7c6fe5b | 2018-04-09 18:27:13 -0700 | [diff] [blame] | 182 | @Mock private NotificationRemoteInputManager mRemoteInputManager; |
| 183 | @Mock private RemoteInputController mRemoteInputController; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 184 | @Mock private StatusBarStateControllerImpl mStatusBarStateController; |
Lucas Dupin | bd7366d | 2019-09-25 13:39:21 -0700 | [diff] [blame] | 185 | @Mock private BatteryController mBatteryController; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 186 | @Mock private DeviceProvisionedController mDeviceProvisionedController; |
Selim Cinek | 5454a0d | 2019-07-30 17:14:50 -0700 | [diff] [blame] | 187 | @Mock private StatusBarNotificationPresenter mNotificationPresenter; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 188 | @Mock private NotificationEntryListener mEntryListener; |
| 189 | @Mock private NotificationFilter mNotificationFilter; |
| 190 | @Mock private NotificationAlertingManager mNotificationAlertingManager; |
| 191 | @Mock private NotificationLogger.ExpansionStateLogger mExpansionStateLogger; |
| 192 | @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; |
| 193 | @Mock private AmbientDisplayConfiguration mAmbientDisplayConfiguration; |
| 194 | @Mock private StatusBarWindowView mStatusBarWindowView; |
| 195 | @Mock private BroadcastDispatcher mBroadcastDispatcher; |
| 196 | @Mock private AssistManager mAssistManager; |
| 197 | @Mock private NotificationGutsManager mNotificationGutsManager; |
| 198 | @Mock private NotificationMediaManager mNotificationMediaManager; |
| 199 | @Mock private ForegroundServiceController mForegroundServiceController; |
| 200 | @Mock private AppOpsController mAppOpsController; |
| 201 | @Mock private NavigationBarController mNavigationBarController; |
| 202 | @Mock private BypassHeadsUpNotifier mBypassHeadsUpNotifier; |
| 203 | @Mock private SysuiColorExtractor mColorExtractor; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 204 | @Mock private ColorExtractor.GradientColors mGradientColors; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 205 | @Mock private DozeLog mDozeLog; |
| 206 | @Mock private PulseExpansionHandler mPulseExpansionHandler; |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 207 | @Mock private NotificationWakeUpCoordinator mNotificationWakeUpCoordinator; |
| 208 | @Mock private KeyguardBypassController mKeyguardBypassController; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 209 | @Mock private InjectionInflationController mInjectionInflationController; |
| 210 | @Mock private DynamicPrivacyController mDynamicPrivacyController; |
Ned Burns | f098dbf | 2019-09-13 19:17:53 -0400 | [diff] [blame] | 211 | @Mock private NewNotifPipeline mNewNotifPipeline; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 212 | @Mock private ZenModeController mZenModeController; |
| 213 | @Mock private AutoHideController mAutoHideController; |
| 214 | @Mock private NotificationViewHierarchyManager mNotificationViewHierarchyManager; |
| 215 | @Mock private UserSwitcherController mUserSwitcherController; |
| 216 | @Mock private NetworkController mNetworkController; |
| 217 | @Mock private VibratorHelper mVibratorHelper; |
| 218 | @Mock private BubbleController mBubbleController; |
| 219 | @Mock private NotificationGroupManager mGroupManager; |
| 220 | @Mock private NotificationGroupAlertTransferHelper mGroupAlertTransferHelper; |
| 221 | @Mock private StatusBarWindowController mStatusBarWindowController; |
| 222 | @Mock private NotificationIconAreaController mNotificationIconAreaController; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 223 | @Mock private StatusBarWindowViewController.Builder mStatusBarWindowViewControllerBuilder; |
| 224 | @Mock private StatusBarWindowViewController mStatusBarWindowViewController; |
Beverly | 85d4c19 | 2019-09-30 11:40:39 -0400 | [diff] [blame] | 225 | @Mock private NotifLog mNotifLog; |
Dave Mankoff | 2aff6c3 | 2019-10-14 17:40:37 -0400 | [diff] [blame] | 226 | @Mock private DozeParameters mDozeParameters; |
Dave Mankoff | a874996 | 2019-10-18 10:44:07 -0400 | [diff] [blame] | 227 | @Mock private Lazy<LockscreenWallpaper> mLockscreenWallpaperLazy; |
| 228 | @Mock private LockscreenWallpaper mLockscreenWallpaper; |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 229 | @Mock private DozeServiceHost mDozeServiceHost; |
Dave Mankoff | bbc2f8f | 2019-10-21 12:21:29 -0400 | [diff] [blame] | 230 | @Mock private LinearLayout mLockIconContainer; |
| 231 | @Mock private ViewMediatorCallback mKeyguardVieMediatorCallback; |
Lucas Dupin | 64171fe | 2019-10-30 14:28:29 -0700 | [diff] [blame] | 232 | @Mock private KeyguardLiftController mKeyguardLiftController; |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 233 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 234 | @Before |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 235 | public void setup() throws Exception { |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 236 | MockitoAnnotations.initMocks(this); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 237 | mDependency.injectTestDependency(NotificationFilter.class, mNotificationFilter); |
Dave Mankoff | bbc2f8f | 2019-10-21 12:21:29 -0400 | [diff] [blame] | 238 | mDependency.injectMockDependency(KeyguardDismissUtil.class); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 239 | |
| 240 | IPowerManager powerManagerService = mock(IPowerManager.class); |
| 241 | mPowerManager = new PowerManager(mContext, powerManagerService, |
| 242 | Handler.createAsync(Looper.myLooper())); |
| 243 | |
| 244 | mNotificationInterruptionStateProvider = |
| 245 | new TestableNotificationInterruptionStateProvider(mContext, mPowerManager, |
Mady Mellor | c55b412 | 2019-06-07 18:14:02 -0700 | [diff] [blame] | 246 | mDreamManager, mAmbientDisplayConfiguration, mNotificationFilter, |
Lucas Dupin | bd7366d | 2019-09-25 13:39:21 -0700 | [diff] [blame] | 247 | mStatusBarStateController, mBatteryController); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 248 | |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 249 | mContext.addMockSystemService(TrustManager.class, mock(TrustManager.class)); |
| 250 | mContext.addMockSystemService(FingerprintManager.class, mock(FingerprintManager.class)); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 251 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 252 | mMetricsLogger = new FakeMetricsLogger(); |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 253 | TestableNotificationEntryManager entryManager = new TestableNotificationEntryManager( |
Evan Laird | 367b614 | 2019-08-30 14:40:34 -0400 | [diff] [blame] | 254 | mNotificationData); |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 255 | NotificationLogger notificationLogger = new NotificationLogger(mNotificationListener, |
| 256 | Dependency.get(UiOffloadThread.class), entryManager, mStatusBarStateController, |
Tony Mak | 202f25d | 2019-01-07 14:40:39 +0000 | [diff] [blame] | 257 | mExpansionStateLogger); |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 258 | notificationLogger.setVisibilityReporter(mock(Runnable.class)); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 259 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 260 | mCommandQueue = mock(CommandQueue.class); |
| 261 | when(mCommandQueue.asBinder()).thenReturn(new Binder()); |
| 262 | mContext.putComponent(CommandQueue.class, mCommandQueue); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 263 | |
| 264 | mContext.setTheme(R.style.Theme_SystemUI_Light); |
| 265 | |
| 266 | when(mStackScroller.generateLayoutParams(any())).thenReturn(new LayoutParams(0, 0)); |
| 267 | when(mNotificationPanelView.getLayoutParams()).thenReturn(new LayoutParams(0, 0)); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 268 | when(powerManagerService.isInteractive()).thenReturn(true); |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 269 | when(mStackScroller.getActivatedChild()).thenReturn(null); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 270 | |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 271 | doAnswer(invocation -> { |
| 272 | OnDismissAction onDismissAction = (OnDismissAction) invocation.getArguments()[0]; |
| 273 | onDismissAction.onDismiss(); |
| 274 | return null; |
| 275 | }).when(mStatusBarKeyguardViewManager).dismissWithAction(any(), any(), anyBoolean()); |
| 276 | |
| 277 | doAnswer(invocation -> { |
| 278 | Runnable runnable = (Runnable) invocation.getArguments()[0]; |
| 279 | runnable.run(); |
| 280 | return null; |
| 281 | }).when(mStatusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(any()); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 282 | |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 283 | mNotificationInterruptionStateProvider.setUpWithPresenter(mNotificationPresenter, |
| 284 | mHeadsUpManager, mHeadsUpSuppressor); |
| 285 | |
Selim Cinek | 7c6fe5b | 2018-04-09 18:27:13 -0700 | [diff] [blame] | 286 | when(mRemoteInputManager.getController()).thenReturn(mRemoteInputController); |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 287 | |
| 288 | WakefulnessLifecycle wakefulnessLifecycle = new WakefulnessLifecycle(); |
| 289 | wakefulnessLifecycle.dispatchStartedWakingUp(); |
| 290 | wakefulnessLifecycle.dispatchFinishedWakingUp(); |
| 291 | |
| 292 | when(mGradientColors.supportsDarkText()).thenReturn(true); |
| 293 | when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors); |
| 294 | ConfigurationController configurationController = new ConfigurationControllerImpl(mContext); |
| 295 | |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 296 | when(mStatusBarWindowViewControllerBuilder.build()) |
| 297 | .thenReturn(mStatusBarWindowViewController); |
| 298 | |
Dave Mankoff | a874996 | 2019-10-18 10:44:07 -0400 | [diff] [blame] | 299 | when(mLockscreenWallpaperLazy.get()).thenReturn(mLockscreenWallpaper); |
Dave Mankoff | bbc2f8f | 2019-10-21 12:21:29 -0400 | [diff] [blame] | 300 | when(mBiometricUnlockControllerLazy.get()).thenReturn(mBiometricUnlockController); |
Dave Mankoff | a874996 | 2019-10-18 10:44:07 -0400 | [diff] [blame] | 301 | |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 302 | mStatusBar = new StatusBar( |
Dave Mankoff | a5d8a39 | 2019-10-10 12:21:09 -0400 | [diff] [blame] | 303 | mContext, |
Ned Burns | f098dbf | 2019-09-13 19:17:53 -0400 | [diff] [blame] | 304 | mFeatureFlags, |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 305 | mLightBarController, |
| 306 | mAutoHideController, |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 307 | mKeyguardUpdateMonitor, |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 308 | mStatusBarIconController, |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 309 | mDozeLog, |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 310 | mInjectionInflationController, |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 311 | mPulseExpansionHandler, |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 312 | mNotificationWakeUpCoordinator, |
| 313 | mKeyguardBypassController, |
| 314 | mKeyguardStateController, |
| 315 | mHeadsUpManager, |
| 316 | mDynamicPrivacyController, |
| 317 | mBypassHeadsUpNotifier, |
| 318 | true, |
Ned Burns | f098dbf | 2019-09-13 19:17:53 -0400 | [diff] [blame] | 319 | () -> mNewNotifPipeline, |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 320 | new FalsingManagerFake(), |
| 321 | mBroadcastDispatcher, |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 322 | new RemoteInputQuickSettingsDisabler( |
| 323 | mContext, |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 324 | configurationController |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 325 | ), |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 326 | mNotificationGutsManager, |
| 327 | notificationLogger, |
| 328 | entryManager, |
| 329 | mNotificationInterruptionStateProvider, |
| 330 | mNotificationViewHierarchyManager, |
| 331 | mForegroundServiceController, |
| 332 | mAppOpsController, |
| 333 | mKeyguardViewMediator, |
| 334 | mZenModeController, |
| 335 | mNotificationAlertingManager, |
| 336 | new DisplayMetrics(), |
| 337 | mMetricsLogger, |
| 338 | Dependency.get(UiOffloadThread.class), |
| 339 | mNotificationMediaManager, |
| 340 | mLockscreenUserManager, |
| 341 | mRemoteInputManager, |
| 342 | mUserSwitcherController, |
| 343 | mNetworkController, |
| 344 | mBatteryController, |
| 345 | mColorExtractor, |
| 346 | new ScreenLifecycle(), |
| 347 | wakefulnessLifecycle, |
| 348 | mStatusBarStateController, |
| 349 | mVibratorHelper, |
| 350 | mBubbleController, |
| 351 | mGroupManager, |
| 352 | mGroupAlertTransferHelper, |
| 353 | mVisualStabilityManager, |
| 354 | mDeviceProvisionedController, |
| 355 | mNavigationBarController, |
| 356 | mAssistManager, |
| 357 | mNotificationListener, |
| 358 | configurationController, |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 359 | mStatusBarWindowController, |
Beverly | 85d4c19 | 2019-09-30 11:40:39 -0400 | [diff] [blame] | 360 | mStatusBarWindowViewControllerBuilder, |
Dave Mankoff | 2aff6c3 | 2019-10-14 17:40:37 -0400 | [diff] [blame] | 361 | mNotifLog, |
Dave Mankoff | a874996 | 2019-10-18 10:44:07 -0400 | [diff] [blame] | 362 | mDozeParameters, |
| 363 | mScrimController, |
Lucas Dupin | 64171fe | 2019-10-30 14:28:29 -0700 | [diff] [blame] | 364 | mKeyguardLiftController, |
Dave Mankoff | bbc2f8f | 2019-10-21 12:21:29 -0400 | [diff] [blame] | 365 | mLockscreenWallpaperLazy, |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 366 | mBiometricUnlockControllerLazy, |
| 367 | mDozeServiceHost, |
| 368 | mPowerManager, |
| 369 | mDozeScrimController); |
Dave Mankoff | bbc2f8f | 2019-10-21 12:21:29 -0400 | [diff] [blame] | 370 | |
| 371 | when(mStatusBarWindowView.findViewById(R.id.lock_icon_container)).thenReturn( |
| 372 | mLockIconContainer); |
| 373 | |
| 374 | when(mKeyguardViewMediator.registerStatusBar(any(StatusBar.class), any(ViewGroup.class), |
| 375 | any(NotificationPanelView.class), any(BiometricUnlockController.class), |
| 376 | any(ViewGroup.class), any(ViewGroup.class), any(KeyguardBypassController.class))) |
| 377 | .thenReturn(mStatusBarKeyguardViewManager); |
| 378 | |
| 379 | when(mKeyguardViewMediator.getViewMediatorCallback()).thenReturn( |
| 380 | mKeyguardVieMediatorCallback); |
| 381 | |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 382 | // TODO: we should be able to call mStatusBar.start() and have all the below values |
| 383 | // initialized automatically. |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 384 | mStatusBar.mComponents = mContext.getComponents(); |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 385 | mStatusBar.mStatusBarWindow = mStatusBarWindowView; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 386 | mStatusBar.mNotificationPanel = mNotificationPanelView; |
| 387 | mStatusBar.mCommandQueue = mCommandQueue; |
| 388 | mStatusBar.mDozeScrimController = mDozeScrimController; |
| 389 | mStatusBar.mNotificationIconAreaController = mNotificationIconAreaController; |
| 390 | mStatusBar.mPresenter = mNotificationPresenter; |
| 391 | mStatusBar.mKeyguardIndicationController = mKeyguardIndicationController; |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 392 | mStatusBar.mBarService = mBarService; |
| 393 | mStatusBar.mStackScroller = mStackScroller; |
Dave Mankoff | 0cf8dfc | 2019-09-27 12:46:41 -0400 | [diff] [blame] | 394 | mStatusBar.mStatusBarWindowViewController = mStatusBarWindowViewController; |
Dave Mankoff | bbc2f8f | 2019-10-21 12:21:29 -0400 | [diff] [blame] | 395 | mStatusBar.startKeyguard(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 396 | mStatusBar.putComponent(StatusBar.class, mStatusBar); |
| 397 | Dependency.get(InitController.class).executePostInitTasks(); |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 398 | entryManager.setUpForTest(mock(NotificationPresenter.class), mStackScroller, |
Evan Laird | 367b614 | 2019-08-30 14:40:34 -0400 | [diff] [blame] | 399 | mHeadsUpManager); |
Dave Mankoff | beef8f1 | 2019-10-03 19:06:55 +0000 | [diff] [blame] | 400 | entryManager.addNotificationEntryListener(mEntryListener); |
| 401 | notificationLogger.setUpWithContainer(mStackScroller); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 402 | } |
| 403 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 404 | @Test |
Jason Monk | 5ecf80c | 2017-07-06 15:28:17 -0400 | [diff] [blame] | 405 | public void testSetBouncerShowing_noCrash() { |
| 406 | mStatusBar.mCommandQueue = mock(CommandQueue.class); |
| 407 | mStatusBar.setBouncerShowing(true); |
| 408 | } |
| 409 | |
| 410 | @Test |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 411 | public void executeRunnableDismissingKeyguard_nullRunnable_showingAndOccluded() { |
| 412 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 413 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(true); |
| 414 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 415 | mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 416 | } |
| 417 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 418 | @Test |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 419 | public void executeRunnableDismissingKeyguard_nullRunnable_showing() { |
| 420 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 421 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 422 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 423 | mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 424 | } |
| 425 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 426 | @Test |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 427 | public void executeRunnableDismissingKeyguard_nullRunnable_notShowing() { |
| 428 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); |
| 429 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
| 430 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 431 | mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false); |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 432 | } |
| 433 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 434 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 435 | public void lockscreenStateMetrics_notShowing() { |
| 436 | // uninteresting state, except that fingerprint must be non-zero |
| 437 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 438 | when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 439 | // interesting state |
| 440 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); |
| 441 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 442 | when(mKeyguardStateController.isMethodSecure()).thenReturn(false); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 443 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 444 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 445 | MetricsAsserts.assertHasLog("missing hidden insecure lockscreen log", |
| 446 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 447 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 448 | .setType(MetricsEvent.TYPE_CLOSE) |
| 449 | .setSubtype(0)); |
| 450 | } |
| 451 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 452 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 453 | public void lockscreenStateMetrics_notShowing_secure() { |
| 454 | // uninteresting state, except that fingerprint must be non-zero |
| 455 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 456 | when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 457 | // interesting state |
| 458 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); |
| 459 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 460 | when(mKeyguardStateController.isMethodSecure()).thenReturn(true); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 461 | |
| 462 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 463 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 464 | MetricsAsserts.assertHasLog("missing hidden secure lockscreen log", |
| 465 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 466 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 467 | .setType(MetricsEvent.TYPE_CLOSE) |
| 468 | .setSubtype(1)); |
| 469 | } |
| 470 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 471 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 472 | public void lockscreenStateMetrics_isShowing() { |
| 473 | // uninteresting state, except that fingerprint must be non-zero |
| 474 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 475 | when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 476 | // interesting state |
| 477 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 478 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 479 | when(mKeyguardStateController.isMethodSecure()).thenReturn(false); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 480 | |
| 481 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 482 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 483 | MetricsAsserts.assertHasLog("missing insecure lockscreen showing", |
| 484 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 485 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 486 | .setType(MetricsEvent.TYPE_OPEN) |
| 487 | .setSubtype(0)); |
| 488 | } |
| 489 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 490 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 491 | public void lockscreenStateMetrics_isShowing_secure() { |
| 492 | // uninteresting state, except that fingerprint must be non-zero |
| 493 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 494 | when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 495 | // interesting state |
| 496 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 497 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 498 | when(mKeyguardStateController.isMethodSecure()).thenReturn(true); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 499 | |
| 500 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 501 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 502 | MetricsAsserts.assertHasLog("missing secure lockscreen showing log", |
| 503 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 504 | new LogMaker(MetricsEvent.LOCKSCREEN) |
| 505 | .setType(MetricsEvent.TYPE_OPEN) |
| 506 | .setSubtype(1)); |
| 507 | } |
| 508 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 509 | @Test |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 510 | public void lockscreenStateMetrics_isShowingBouncer() { |
| 511 | // uninteresting state, except that fingerprint must be non-zero |
| 512 | when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 513 | when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 514 | // interesting state |
| 515 | when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); |
| 516 | when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(true); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 517 | when(mKeyguardStateController.isMethodSecure()).thenReturn(true); |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 518 | |
| 519 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
| 520 | |
Chris Wren | ef31990 | 2017-03-07 17:58:31 -0500 | [diff] [blame] | 521 | MetricsAsserts.assertHasLog("missing bouncer log", |
| 522 | mMetricsLogger.getLogs(), |
Chris Wren | 27a52fa | 2017-02-01 14:21:43 -0500 | [diff] [blame] | 523 | new LogMaker(MetricsEvent.BOUNCER) |
| 524 | .setType(MetricsEvent.TYPE_OPEN) |
| 525 | .setSubtype(1)); |
| 526 | } |
| 527 | |
Adrian Roos | 02de498 | 2017-02-11 09:35:54 +0100 | [diff] [blame] | 528 | @Test |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 529 | public void testShouldHeadsUp_nonSuppressedGroupSummary() throws Exception { |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 530 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 531 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 532 | when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 533 | when(mDreamManager.isDreaming()).thenReturn(false); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 534 | when(mHeadsUpSuppressor.canHeadsUp(any(), any())).thenReturn(true); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 535 | |
| 536 | Notification n = new Notification.Builder(getContext(), "a") |
| 537 | .setGroup("a") |
| 538 | .setGroupSummary(true) |
| 539 | .setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY) |
| 540 | .build(); |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 541 | |
| 542 | NotificationEntry entry = new NotificationEntryBuilder() |
| 543 | .setPkg("a") |
| 544 | .setOpPkg("a") |
| 545 | .setTag("a") |
| 546 | .setNotification(n) |
| 547 | .setImportance(IMPORTANCE_HIGH) |
| 548 | .build(); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 549 | |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 550 | assertTrue(mNotificationInterruptionStateProvider.shouldHeadsUp(entry)); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | @Test |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 554 | public void testShouldHeadsUp_suppressedGroupSummary() throws Exception { |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 555 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 556 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 557 | when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 558 | when(mDreamManager.isDreaming()).thenReturn(false); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 559 | when(mHeadsUpSuppressor.canHeadsUp(any(), any())).thenReturn(true); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 560 | |
| 561 | Notification n = new Notification.Builder(getContext(), "a") |
| 562 | .setGroup("a") |
| 563 | .setGroupSummary(true) |
| 564 | .setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN) |
| 565 | .build(); |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 566 | |
| 567 | NotificationEntry entry = new NotificationEntryBuilder() |
| 568 | .setPkg("a") |
| 569 | .setOpPkg("a") |
| 570 | .setTag("a") |
| 571 | .setNotification(n) |
| 572 | .setImportance(IMPORTANCE_HIGH) |
| 573 | .build(); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 574 | |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 575 | assertFalse(mNotificationInterruptionStateProvider.shouldHeadsUp(entry)); |
Julia Reynolds | 3020315 | 2017-05-26 13:36:31 -0400 | [diff] [blame] | 576 | } |
| 577 | |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 578 | @Test |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 579 | public void testShouldHeadsUp_suppressedHeadsUp() throws Exception { |
Beverly | 38159ce | 2017-07-13 16:39:24 -0400 | [diff] [blame] | 580 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 581 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 582 | when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 583 | when(mDreamManager.isDreaming()).thenReturn(false); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 584 | when(mHeadsUpSuppressor.canHeadsUp(any(), any())).thenReturn(true); |
Julia Reynolds | 24653c3 | 2018-03-02 13:16:37 -0500 | [diff] [blame] | 585 | |
| 586 | Notification n = new Notification.Builder(getContext(), "a").build(); |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 587 | |
| 588 | NotificationEntry entry = new NotificationEntryBuilder() |
| 589 | .setPkg("a") |
| 590 | .setOpPkg("a") |
| 591 | .setTag("a") |
| 592 | .setNotification(n) |
| 593 | .setImportance(IMPORTANCE_HIGH) |
Ned Burns | 47c98f1 | 2019-09-06 17:12:07 -0400 | [diff] [blame] | 594 | .setSuppressedVisualEffects(SUPPRESSED_EFFECT_PEEK) |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 595 | .build(); |
| 596 | |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 597 | assertFalse(mNotificationInterruptionStateProvider.shouldHeadsUp(entry)); |
Julia Reynolds | 24653c3 | 2018-03-02 13:16:37 -0500 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | @Test |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 601 | public void testShouldHeadsUp_noSuppressedHeadsUp() throws Exception { |
Julia Reynolds | 24653c3 | 2018-03-02 13:16:37 -0500 | [diff] [blame] | 602 | when(mPowerManager.isScreenOn()).thenReturn(true); |
| 603 | when(mHeadsUpManager.isSnoozed(anyString())).thenReturn(false); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 604 | when(mNotificationFilter.shouldFilterOut(any())).thenReturn(false); |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 605 | when(mDreamManager.isDreaming()).thenReturn(false); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 606 | when(mHeadsUpSuppressor.canHeadsUp(any(), any())).thenReturn(true); |
Beverly | 38159ce | 2017-07-13 16:39:24 -0400 | [diff] [blame] | 607 | |
| 608 | Notification n = new Notification.Builder(getContext(), "a").build(); |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 609 | |
| 610 | NotificationEntry entry = new NotificationEntryBuilder() |
| 611 | .setPkg("a") |
| 612 | .setOpPkg("a") |
| 613 | .setTag("a") |
| 614 | .setNotification(n) |
| 615 | .setImportance(IMPORTANCE_HIGH) |
| 616 | .build(); |
Beverly | 38159ce | 2017-07-13 16:39:24 -0400 | [diff] [blame] | 617 | |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 618 | assertTrue(mNotificationInterruptionStateProvider.shouldHeadsUp(entry)); |
Beverly | 38159ce | 2017-07-13 16:39:24 -0400 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | @Test |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 622 | public void testLogHidden() { |
| 623 | try { |
| 624 | mStatusBar.handleVisibleToUserChanged(false); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 625 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 626 | verify(mBarService, times(1)).onPanelHidden(); |
| 627 | verify(mBarService, never()).onPanelRevealed(anyBoolean(), anyInt()); |
| 628 | } catch (RemoteException e) { |
| 629 | fail(); |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | @Test |
Kevin | a97ea05 | 2018-09-11 13:53:18 -0700 | [diff] [blame] | 634 | public void testPanelOpenForHeadsUp() { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 635 | when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(true); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 636 | when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); |
| 637 | when(mNotificationData.getActiveNotifications()).thenReturn(mNotificationList); |
| 638 | when(mNotificationList.size()).thenReturn(5); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 639 | when(mNotificationPresenter.isPresenterFullyCollapsed()).thenReturn(true); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 640 | mStatusBar.setBarStateForTest(StatusBarState.SHADE); |
| 641 | |
| 642 | try { |
| 643 | mStatusBar.handleVisibleToUserChanged(true); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 644 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 645 | verify(mBarService, never()).onPanelHidden(); |
| 646 | verify(mBarService, times(1)).onPanelRevealed(false, 1); |
| 647 | } catch (RemoteException e) { |
| 648 | fail(); |
| 649 | } |
| 650 | TestableLooper.get(this).processAllMessages(); |
| 651 | } |
| 652 | |
| 653 | @Test |
| 654 | public void testPanelOpenAndClear() { |
| 655 | when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); |
| 656 | when(mNotificationData.getActiveNotifications()).thenReturn(mNotificationList); |
| 657 | when(mNotificationList.size()).thenReturn(5); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 658 | when(mNotificationPresenter.isPresenterFullyCollapsed()).thenReturn(false); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 659 | mStatusBar.setBarStateForTest(StatusBarState.SHADE); |
| 660 | |
| 661 | try { |
| 662 | mStatusBar.handleVisibleToUserChanged(true); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 663 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 664 | verify(mBarService, never()).onPanelHidden(); |
| 665 | verify(mBarService, times(1)).onPanelRevealed(true, 5); |
| 666 | } catch (RemoteException e) { |
| 667 | fail(); |
| 668 | } |
| 669 | TestableLooper.get(this).processAllMessages(); |
| 670 | } |
| 671 | |
| 672 | @Test |
| 673 | public void testPanelOpenAndNoClear() { |
| 674 | when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); |
| 675 | when(mNotificationData.getActiveNotifications()).thenReturn(mNotificationList); |
| 676 | when(mNotificationList.size()).thenReturn(5); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 677 | when(mNotificationPresenter.isPresenterFullyCollapsed()).thenReturn(false); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 678 | mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); |
| 679 | |
| 680 | try { |
| 681 | mStatusBar.handleVisibleToUserChanged(true); |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 682 | waitForUiOffloadThread(); |
Chris Wren | 621933f | 2017-06-14 15:59:03 -0400 | [diff] [blame] | 683 | verify(mBarService, never()).onPanelHidden(); |
| 684 | verify(mBarService, times(1)).onPanelRevealed(false, 5); |
| 685 | } catch (RemoteException e) { |
| 686 | fail(); |
| 687 | } |
| 688 | TestableLooper.get(this).processAllMessages(); |
| 689 | } |
| 690 | |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 691 | @Test |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 692 | public void testDisableExpandStatusBar() { |
| 693 | mStatusBar.setBarStateForTest(StatusBarState.SHADE); |
| 694 | mStatusBar.setUserSetupForTest(true); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 695 | when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(true); |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 696 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 697 | when(mCommandQueue.panelsEnabled()).thenReturn(false); |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 698 | mStatusBar.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_NONE, |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 699 | StatusBarManager.DISABLE2_NOTIFICATION_SHADE, false); |
| 700 | verify(mNotificationPanelView).setQsExpansionEnabled(false); |
| 701 | mStatusBar.animateExpandNotificationsPanel(); |
| 702 | verify(mNotificationPanelView, never()).expand(anyBoolean()); |
| 703 | mStatusBar.animateExpandSettingsPanel(null); |
| 704 | verify(mNotificationPanelView, never()).expand(anyBoolean()); |
| 705 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 706 | when(mCommandQueue.panelsEnabled()).thenReturn(true); |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 707 | mStatusBar.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_NONE, |
| 708 | StatusBarManager.DISABLE2_NONE, false); |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 709 | verify(mNotificationPanelView).setQsExpansionEnabled(true); |
| 710 | mStatusBar.animateExpandNotificationsPanel(); |
Eugene Susla | 2de6955 | 2018-03-20 13:22:17 -0700 | [diff] [blame] | 711 | verify(mNotificationPanelView).expandWithoutQs(); |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 712 | mStatusBar.animateExpandSettingsPanel(null); |
Eugene Susla | 2de6955 | 2018-03-20 13:22:17 -0700 | [diff] [blame] | 713 | verify(mNotificationPanelView).expandWithQs(); |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | @Test |
Jason Monk | 5130537 | 2017-06-22 11:41:08 -0400 | [diff] [blame] | 717 | public void testDump_DoesNotCrash() { |
| 718 | mStatusBar.dump(null, new PrintWriter(new ByteArrayOutputStream()), null); |
| 719 | } |
| 720 | |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 721 | @Test |
| 722 | @RunWithLooper(setAsMainLooper = true) |
| 723 | public void testUpdateKeyguardState_DoesNotCrash() { |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 724 | mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); |
| 725 | when(mLockscreenUserManager.getCurrentProfiles()).thenReturn( |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 726 | new SparseArray<>()); |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 727 | mStatusBar.onStateChanged(StatusBarState.SHADE); |
Jason Monk | 9c4faa8 | 2017-08-15 09:32:27 -0400 | [diff] [blame] | 728 | } |
| 729 | |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 730 | @Test |
| 731 | public void testFingerprintNotification_UpdatesScrims() { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 732 | mStatusBar.notifyBiometricAuthModeChanged(); |
Lucas Dupin | c2e7546 | 2017-12-06 13:59:25 -0800 | [diff] [blame] | 733 | verify(mScrimController).transitionTo(any(), any()); |
| 734 | } |
| 735 | |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 736 | @Test |
| 737 | public void testFingerprintUnlock_UpdatesScrims() { |
| 738 | // Simulate unlocking from AoD with fingerprint. |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 739 | when(mBiometricUnlockController.getMode()) |
| 740 | .thenReturn(BiometricUnlockController.MODE_WAKE_AND_UNLOCK); |
Lucas Dupin | 311eac8 | 2017-12-11 14:40:07 -0800 | [diff] [blame] | 741 | mStatusBar.updateScrimController(); |
| 742 | verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); |
| 743 | } |
| 744 | |
Lucas Dupin | d510730 | 2018-03-19 15:30:29 -0700 | [diff] [blame] | 745 | @Test |
| 746 | public void testSetOccluded_propagatesToScrimController() { |
| 747 | mStatusBar.setOccluded(true); |
| 748 | verify(mScrimController).setKeyguardOccluded(eq(true)); |
| 749 | |
| 750 | reset(mScrimController); |
| 751 | mStatusBar.setOccluded(false); |
| 752 | verify(mScrimController).setKeyguardOccluded(eq(false)); |
| 753 | } |
| 754 | |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 755 | @Test |
Lucas Dupin | 988efb2 | 2018-12-04 16:53:58 -0800 | [diff] [blame] | 756 | public void testPulseWhileDozing_updatesScrimController() { |
| 757 | mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); |
| 758 | mStatusBar.showKeyguardImpl(); |
Julia Reynolds | ed1c9af | 2018-03-21 15:21:09 -0400 | [diff] [blame] | 759 | |
Lucas Dupin | 988efb2 | 2018-12-04 16:53:58 -0800 | [diff] [blame] | 760 | // Starting a pulse should change the scrim controller to the pulsing state |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 761 | when(mDozeServiceHost.isPulsing()).thenReturn(true); |
| 762 | mStatusBar.updateScrimController(); |
Lucas Dupin | 988efb2 | 2018-12-04 16:53:58 -0800 | [diff] [blame] | 763 | verify(mScrimController).transitionTo(eq(ScrimState.PULSING), any()); |
| 764 | |
| 765 | // Ending a pulse should take it back to keyguard state |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 766 | when(mDozeServiceHost.isPulsing()).thenReturn(false); |
| 767 | mStatusBar.updateScrimController(); |
Lucas Dupin | 988efb2 | 2018-12-04 16:53:58 -0800 | [diff] [blame] | 768 | verify(mScrimController).transitionTo(eq(ScrimState.KEYGUARD)); |
| 769 | } |
| 770 | |
| 771 | @Test |
jovanak | 5f6dc61 | 2018-03-27 11:59:22 -0700 | [diff] [blame] | 772 | public void testSetState_changesIsFullScreenUserSwitcherState() { |
| 773 | mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); |
| 774 | assertFalse(mStatusBar.isFullScreenUserSwitcherState()); |
| 775 | |
| 776 | mStatusBar.setBarStateForTest(StatusBarState.FULLSCREEN_USER_SWITCHER); |
| 777 | assertTrue(mStatusBar.isFullScreenUserSwitcherState()); |
| 778 | } |
| 779 | |
| 780 | @Test |
| 781 | public void testShowKeyguardImplementation_setsState() { |
| 782 | when(mLockscreenUserManager.getCurrentProfiles()).thenReturn(new SparseArray<>()); |
| 783 | |
| 784 | mStatusBar.setBarStateForTest(StatusBarState.SHADE); |
| 785 | |
| 786 | // By default, showKeyguardImpl sets state to KEYGUARD. |
| 787 | mStatusBar.showKeyguardImpl(); |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 788 | verify(mStatusBarStateController).setState(eq(StatusBarState.KEYGUARD)); |
jovanak | 5f6dc61 | 2018-03-27 11:59:22 -0700 | [diff] [blame] | 789 | |
| 790 | // If useFullscreenUserSwitcher is true, state is set to FULLSCREEN_USER_SWITCHER. |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 791 | when(mUserSwitcherController.useFullscreenUserSwitcher()).thenReturn(true); |
jovanak | 5f6dc61 | 2018-03-27 11:59:22 -0700 | [diff] [blame] | 792 | mStatusBar.showKeyguardImpl(); |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 793 | verify(mStatusBarStateController).setState(eq(StatusBarState.FULLSCREEN_USER_SWITCHER)); |
jovanak | 5f6dc61 | 2018-03-27 11:59:22 -0700 | [diff] [blame] | 794 | } |
| 795 | |
Lucas Dupin | 29a07ec | 2018-11-13 16:56:49 -0800 | [diff] [blame] | 796 | @Test |
Lucas Dupin | 29a07ec | 2018-11-13 16:56:49 -0800 | [diff] [blame] | 797 | public void testOnStartedWakingUp_isNotDozing() { |
| 798 | mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); |
| 799 | when(mStatusBarStateController.isKeyguardRequested()).thenReturn(true); |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 800 | when(mDozeServiceHost.getDozingRequested()).thenReturn(true); |
| 801 | mStatusBar.updateIsKeyguard(); |
| 802 | // TODO: mNotificationPanelView.expand(false) gets called twice. Should be once. |
| 803 | verify(mNotificationPanelView, times(2)).expand(eq(false)); |
Lucas Dupin | 3cfd688 | 2019-03-19 15:22:03 -0700 | [diff] [blame] | 804 | clearInvocations(mNotificationPanelView); |
Lucas Dupin | 29a07ec | 2018-11-13 16:56:49 -0800 | [diff] [blame] | 805 | |
| 806 | mStatusBar.mWakefulnessObserver.onStartedWakingUp(); |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 807 | verify(mDozeServiceHost).stopDozing(); |
Lucas Dupin | 3cfd688 | 2019-03-19 15:22:03 -0700 | [diff] [blame] | 808 | verify(mNotificationPanelView).expand(eq(false)); |
| 809 | } |
| 810 | |
| 811 | @Test |
| 812 | public void testOnStartedWakingUp_doesNotDismissBouncer_whenPulsing() { |
| 813 | mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); |
| 814 | when(mStatusBarStateController.isKeyguardRequested()).thenReturn(true); |
Dave Mankoff | 1193aa4 | 2019-10-28 17:51:26 -0400 | [diff] [blame] | 815 | when(mDozeServiceHost.getDozingRequested()).thenReturn(true); |
| 816 | mStatusBar.updateIsKeyguard(); |
Lucas Dupin | 3cfd688 | 2019-03-19 15:22:03 -0700 | [diff] [blame] | 817 | clearInvocations(mNotificationPanelView); |
| 818 | |
| 819 | mStatusBar.setBouncerShowing(true); |
| 820 | mStatusBar.mWakefulnessObserver.onStartedWakingUp(); |
| 821 | verify(mNotificationPanelView, never()).expand(anyBoolean()); |
Lucas Dupin | 29a07ec | 2018-11-13 16:56:49 -0800 | [diff] [blame] | 822 | } |
| 823 | |
Fabian Kozynski | ff5e91f | 2019-09-24 15:38:08 -0400 | [diff] [blame] | 824 | @Test |
| 825 | public void testRegisterBroadcastsonDispatcher() { |
| 826 | mStatusBar.registerBroadcastReceiver(); |
| 827 | verify(mBroadcastDispatcher).registerReceiver( |
| 828 | any(BroadcastReceiver.class), |
| 829 | any(IntentFilter.class), |
| 830 | eq(null), |
| 831 | any(UserHandle.class)); |
| 832 | } |
| 833 | |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 834 | public static class TestableNotificationEntryManager extends NotificationEntryManager { |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 835 | |
Evan Laird | 367b614 | 2019-08-30 14:40:34 -0400 | [diff] [blame] | 836 | public TestableNotificationEntryManager(NotificationData notificationData) { |
Beverly | 85d4c19 | 2019-09-30 11:40:39 -0400 | [diff] [blame] | 837 | super(notificationData, mock(NotifLog.class)); |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | public void setUpForTest(NotificationPresenter presenter, |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 841 | NotificationListContainer listContainer, |
Evan Laird | 367b614 | 2019-08-30 14:40:34 -0400 | [diff] [blame] | 842 | HeadsUpManagerPhone headsUpManager) { |
Gus Prevas | 8621bd2 | 2018-12-20 15:04:25 -0500 | [diff] [blame] | 843 | super.setUpWithPresenter(presenter, listContainer, headsUpManager); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 844 | } |
| 845 | } |
| 846 | |
| 847 | public static class TestableNotificationInterruptionStateProvider extends |
| 848 | NotificationInterruptionStateProvider { |
| 849 | |
Dave Mankoff | bb9575f | 2019-10-02 12:23:49 -0400 | [diff] [blame] | 850 | TestableNotificationInterruptionStateProvider( |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 851 | Context context, |
| 852 | PowerManager powerManager, |
Lucas Dupin | 2c3992b | 2019-03-11 16:34:08 -0700 | [diff] [blame] | 853 | IDreamManager dreamManager, |
Mady Mellor | c55b412 | 2019-06-07 18:14:02 -0700 | [diff] [blame] | 854 | AmbientDisplayConfiguration ambientDisplayConfiguration, |
| 855 | NotificationFilter filter, |
Lucas Dupin | bd7366d | 2019-09-25 13:39:21 -0700 | [diff] [blame] | 856 | StatusBarStateController controller, |
| 857 | BatteryController batteryController) { |
Mady Mellor | c55b412 | 2019-06-07 18:14:02 -0700 | [diff] [blame] | 858 | super(context, powerManager, dreamManager, ambientDisplayConfiguration, filter, |
Lucas Dupin | bd7366d | 2019-09-25 13:39:21 -0700 | [diff] [blame] | 859 | batteryController, controller); |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 860 | mUseHeadsUp = true; |
| 861 | } |
Adrian Roos | ef7a402 | 2017-01-19 14:48:35 -0800 | [diff] [blame] | 862 | } |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 863 | } |