kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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 | |
Heemin Seog | 9b078d3 | 2020-04-21 15:07:32 -0700 | [diff] [blame] | 17 | package com.android.systemui.car.navigationbar; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 18 | |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 19 | import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; |
| 20 | import static android.view.InsetsState.ITYPE_STATUS_BAR; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 21 | import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS; |
| 22 | import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_STATUS_BARS; |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 23 | |
| 24 | import static com.google.common.truth.Truth.assertThat; |
| 25 | |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 26 | import static org.mockito.ArgumentMatchers.any; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 27 | import static org.mockito.Mockito.verify; |
| 28 | import static org.mockito.Mockito.when; |
| 29 | |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 30 | import android.graphics.Rect; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 31 | import android.os.Handler; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 32 | import android.os.RemoteException; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 33 | import android.testing.AndroidTestingRunner; |
| 34 | import android.testing.TestableLooper; |
| 35 | import android.testing.TestableResources; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 36 | import android.util.ArrayMap; |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 37 | import android.view.Display; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 38 | import android.view.WindowManager; |
| 39 | |
Heemin Seog | df741ac | 2020-03-27 09:38:26 -0700 | [diff] [blame] | 40 | import androidx.test.filters.SmallTest; |
| 41 | |
Heemin Seog | 23f18d0 | 2020-04-24 17:53:22 -0700 | [diff] [blame] | 42 | import com.android.internal.statusbar.IStatusBarService; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 43 | import com.android.internal.statusbar.RegisterStatusBarResult; |
| 44 | import com.android.internal.view.AppearanceRegion; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 45 | import com.android.systemui.R; |
| 46 | import com.android.systemui.SysuiTestCase; |
| 47 | import com.android.systemui.car.CarDeviceProvisionedController; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 48 | import com.android.systemui.statusbar.CommandQueue; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 49 | import com.android.systemui.statusbar.phone.AutoHideController; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 50 | import com.android.systemui.statusbar.phone.LightBarController; |
| 51 | import com.android.systemui.statusbar.phone.LightBarTransitionsController; |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 52 | import com.android.systemui.statusbar.phone.PhoneStatusBarPolicy; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 53 | import com.android.systemui.statusbar.phone.StatusBarIconController; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 54 | import com.android.systemui.statusbar.phone.SysuiDarkIconDispatcher; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 55 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 56 | import com.android.systemui.util.concurrency.FakeExecutor; |
| 57 | import com.android.systemui.util.time.FakeSystemClock; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 58 | |
| 59 | import org.junit.Before; |
| 60 | import org.junit.Test; |
| 61 | import org.junit.runner.RunWith; |
| 62 | import org.mockito.ArgumentCaptor; |
| 63 | import org.mockito.Mock; |
| 64 | import org.mockito.MockitoAnnotations; |
| 65 | |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 66 | @RunWith(AndroidTestingRunner.class) |
| 67 | @TestableLooper.RunWithLooper |
| 68 | @SmallTest |
| 69 | public class CarNavigationBarTest extends SysuiTestCase { |
| 70 | |
| 71 | private CarNavigationBar mCarNavigationBar; |
| 72 | private TestableResources mTestableResources; |
| 73 | private Handler mHandler; |
| 74 | |
| 75 | @Mock |
| 76 | private CarNavigationBarController mCarNavigationBarController; |
| 77 | @Mock |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 78 | private LightBarController mLightBarController; |
| 79 | @Mock |
| 80 | private SysuiDarkIconDispatcher mStatusBarIconController; |
| 81 | @Mock |
| 82 | private LightBarTransitionsController mLightBarTransitionsController; |
| 83 | @Mock |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 84 | private WindowManager mWindowManager; |
| 85 | @Mock |
| 86 | private CarDeviceProvisionedController mDeviceProvisionedController; |
| 87 | @Mock |
| 88 | private AutoHideController mAutoHideController; |
| 89 | @Mock |
| 90 | private ButtonSelectionStateListener mButtonSelectionStateListener; |
| 91 | @Mock |
Heemin Seog | 23f18d0 | 2020-04-24 17:53:22 -0700 | [diff] [blame] | 92 | private IStatusBarService mBarService; |
| 93 | @Mock |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 94 | private KeyguardStateController mKeyguardStateController; |
| 95 | @Mock |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 96 | private ButtonSelectionStateController mButtonSelectionStateController; |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 97 | @Mock |
| 98 | private PhoneStatusBarPolicy mIconPolicy; |
| 99 | @Mock |
| 100 | private StatusBarIconController mIconController; |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 101 | |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 102 | private RegisterStatusBarResult mBarResult; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 103 | private AppearanceRegion[] mAppearanceRegions; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 104 | private FakeExecutor mUiBgExecutor; |
| 105 | |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 106 | @Before |
| 107 | public void setUp() { |
| 108 | MockitoAnnotations.initMocks(this); |
| 109 | mTestableResources = mContext.getOrCreateTestableResources(); |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 110 | mHandler = Handler.getMain(); |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 111 | mUiBgExecutor = new FakeExecutor(new FakeSystemClock()); |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 112 | when(mStatusBarIconController.getTransitionsController()).thenReturn( |
| 113 | mLightBarTransitionsController); |
| 114 | mAppearanceRegions = new AppearanceRegion[] { |
| 115 | new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, new Rect()) |
| 116 | }; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 117 | mBarResult = new RegisterStatusBarResult( |
| 118 | /* icons= */ new ArrayMap<>(), |
| 119 | /* disabledFlags1= */ 0, |
| 120 | /* appearance= */ 0, |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 121 | mAppearanceRegions, |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 122 | /* imeWindowVis= */ 0, |
| 123 | /* imeBackDisposition= */ 0, |
| 124 | /* showImeSwitcher= */ false, |
| 125 | /* disabledFlags2= */ 0, |
| 126 | /* imeToken= */ null, |
| 127 | /* navbarColorMangedByIme= */ false, |
| 128 | /* appFullscreen= */ false, |
| 129 | /* appImmersive= */ false, |
| 130 | /* transientBarTypes= */ new int[]{}); |
| 131 | try { |
| 132 | when(mBarService.registerStatusBar(any())).thenReturn(mBarResult); |
| 133 | } catch (RemoteException e) { |
| 134 | e.printStackTrace(); |
| 135 | } |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 136 | mCarNavigationBar = new CarNavigationBar(mContext, mTestableResources.getResources(), |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 137 | mCarNavigationBarController, mLightBarController, mStatusBarIconController, |
| 138 | mWindowManager, mDeviceProvisionedController, new CommandQueue(mContext), |
| 139 | mAutoHideController, mButtonSelectionStateListener, mHandler, mUiBgExecutor, |
| 140 | mBarService, () -> mKeyguardStateController, mButtonSelectionStateController, |
| 141 | () -> mIconPolicy, () -> mIconController); |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | @Test |
| 145 | public void restartNavbars_refreshesTaskChanged() { |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 146 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 147 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 148 | ArgumentCaptor<CarDeviceProvisionedController.DeviceProvisionedListener> |
| 149 | deviceProvisionedCallbackCaptor = ArgumentCaptor.forClass( |
| 150 | CarDeviceProvisionedController.DeviceProvisionedListener.class); |
| 151 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 152 | mCarNavigationBar.start(); |
| 153 | // switching the currentUserSetup value to force restart the navbars. |
| 154 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false); |
| 155 | verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture()); |
| 156 | |
| 157 | deviceProvisionedCallbackCaptor.getValue().onUserSwitched(); |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 158 | waitForIdleSync(mHandler); |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 159 | |
| 160 | verify(mButtonSelectionStateListener).onTaskStackChanged(); |
| 161 | } |
JianYang Liu | 4fbd981 | 2020-03-09 13:39:58 -0700 | [diff] [blame] | 162 | |
| 163 | @Test |
| 164 | public void restartNavBars_newUserNotSetupWithKeyguardShowing_showsKeyguardButtons() { |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 165 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 166 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
JianYang Liu | 4fbd981 | 2020-03-09 13:39:58 -0700 | [diff] [blame] | 167 | ArgumentCaptor<CarDeviceProvisionedController.DeviceProvisionedListener> |
| 168 | deviceProvisionedCallbackCaptor = ArgumentCaptor.forClass( |
| 169 | CarDeviceProvisionedController.DeviceProvisionedListener.class); |
| 170 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 171 | mCarNavigationBar.start(); |
| 172 | when(mKeyguardStateController.isShowing()).thenReturn(true); |
| 173 | // switching the currentUserSetup value to force restart the navbars. |
| 174 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false); |
| 175 | verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture()); |
| 176 | |
| 177 | deviceProvisionedCallbackCaptor.getValue().onUserSwitched(); |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 178 | waitForIdleSync(mHandler); |
JianYang Liu | 4fbd981 | 2020-03-09 13:39:58 -0700 | [diff] [blame] | 179 | |
| 180 | verify(mCarNavigationBarController).showAllKeyguardButtons(false); |
| 181 | } |
| 182 | |
| 183 | @Test |
| 184 | public void restartNavbars_newUserIsSetupWithKeyguardHidden_hidesKeyguardButtons() { |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 185 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 186 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
JianYang Liu | 4fbd981 | 2020-03-09 13:39:58 -0700 | [diff] [blame] | 187 | ArgumentCaptor<CarDeviceProvisionedController.DeviceProvisionedListener> |
| 188 | deviceProvisionedCallbackCaptor = ArgumentCaptor.forClass( |
| 189 | CarDeviceProvisionedController.DeviceProvisionedListener.class); |
| 190 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 191 | mCarNavigationBar.start(); |
| 192 | when(mKeyguardStateController.isShowing()).thenReturn(true); |
| 193 | // switching the currentUserSetup value to force restart the navbars. |
| 194 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false); |
| 195 | verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture()); |
| 196 | deviceProvisionedCallbackCaptor.getValue().onUserSwitched(); |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 197 | waitForIdleSync(mHandler); |
JianYang Liu | 4fbd981 | 2020-03-09 13:39:58 -0700 | [diff] [blame] | 198 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 199 | when(mKeyguardStateController.isShowing()).thenReturn(false); |
| 200 | |
| 201 | deviceProvisionedCallbackCaptor.getValue().onUserSetupChanged(); |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 202 | waitForIdleSync(mHandler); |
JianYang Liu | 4fbd981 | 2020-03-09 13:39:58 -0700 | [diff] [blame] | 203 | |
| 204 | verify(mCarNavigationBarController).hideAllKeyguardButtons(true); |
| 205 | } |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 206 | |
| 207 | @Test |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 208 | public void restartNavBars_lightAppearance_darkensAllIcons() { |
| 209 | mAppearanceRegions[0] = new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, new Rect()); |
| 210 | |
| 211 | mCarNavigationBar.start(); |
| 212 | |
| 213 | verify(mLightBarTransitionsController).setIconsDark( |
| 214 | /* dark= */ true, /* animate= */ false); |
| 215 | } |
| 216 | |
| 217 | @Test |
| 218 | public void restartNavBars_opaqueAppearance_lightensAllIcons() { |
| 219 | mAppearanceRegions[0] = new AppearanceRegion(APPEARANCE_OPAQUE_STATUS_BARS, new Rect()); |
| 220 | |
| 221 | mCarNavigationBar.start(); |
| 222 | |
| 223 | verify(mLightBarTransitionsController).setIconsDark( |
| 224 | /* dark= */ false, /* animate= */ false); |
| 225 | } |
| 226 | |
| 227 | @Test |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 228 | public void showTransient_wrongDisplayId_transientModeNotUpdated() { |
| 229 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 230 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
| 231 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 232 | mCarNavigationBar.start(); |
| 233 | |
| 234 | int randomDisplay = Display.DEFAULT_DISPLAY + 10; |
| 235 | int[] insetTypes = new int[]{}; |
| 236 | mCarNavigationBar.showTransient(randomDisplay, insetTypes); |
| 237 | |
| 238 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isFalse(); |
| 239 | } |
| 240 | |
| 241 | @Test |
| 242 | public void showTransient_correctDisplayId_noStatusBarInset_transientModeNotUpdated() { |
| 243 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 244 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
| 245 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 246 | mCarNavigationBar.start(); |
| 247 | |
| 248 | int[] insetTypes = new int[]{}; |
| 249 | mCarNavigationBar.showTransient(Display.DEFAULT_DISPLAY, insetTypes); |
| 250 | |
| 251 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isFalse(); |
| 252 | } |
| 253 | |
| 254 | @Test |
| 255 | public void showTransient_correctDisplayId_statusBarInset_transientModeUpdated() { |
| 256 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 257 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
| 258 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 259 | mCarNavigationBar.start(); |
| 260 | |
| 261 | int[] insetTypes = new int[]{ITYPE_STATUS_BAR}; |
| 262 | mCarNavigationBar.showTransient(Display.DEFAULT_DISPLAY, insetTypes); |
| 263 | |
| 264 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isTrue(); |
| 265 | } |
| 266 | |
| 267 | @Test |
| 268 | public void showTransient_correctDisplayId_noNavBarInset_transientModeNotUpdated() { |
| 269 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 270 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
| 271 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 272 | mCarNavigationBar.start(); |
| 273 | |
| 274 | int[] insetTypes = new int[]{}; |
| 275 | mCarNavigationBar.showTransient(Display.DEFAULT_DISPLAY, insetTypes); |
| 276 | |
| 277 | assertThat(mCarNavigationBar.isNavBarTransientShown()).isFalse(); |
| 278 | } |
| 279 | |
| 280 | @Test |
| 281 | public void showTransient_correctDisplayId_navBarInset_transientModeUpdated() { |
| 282 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 283 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
| 284 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 285 | mCarNavigationBar.start(); |
| 286 | |
| 287 | int[] insetTypes = new int[]{ITYPE_NAVIGATION_BAR}; |
| 288 | mCarNavigationBar.showTransient(Display.DEFAULT_DISPLAY, insetTypes); |
| 289 | |
| 290 | assertThat(mCarNavigationBar.isNavBarTransientShown()).isTrue(); |
| 291 | } |
| 292 | |
| 293 | @Test |
| 294 | public void abortTransient_wrongDisplayId_transientModeNotCleared() { |
| 295 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 296 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
| 297 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 298 | mCarNavigationBar.start(); |
| 299 | mCarNavigationBar.showTransient(Display.DEFAULT_DISPLAY, |
| 300 | new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR}); |
| 301 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isTrue(); |
| 302 | assertThat(mCarNavigationBar.isNavBarTransientShown()).isTrue(); |
| 303 | |
| 304 | int[] insetTypes = new int[]{}; |
| 305 | int randomDisplay = Display.DEFAULT_DISPLAY + 10; |
| 306 | mCarNavigationBar.abortTransient(randomDisplay, insetTypes); |
| 307 | |
| 308 | // The transient booleans were not cleared. |
| 309 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isTrue(); |
| 310 | assertThat(mCarNavigationBar.isNavBarTransientShown()).isTrue(); |
| 311 | } |
| 312 | |
| 313 | @Test |
| 314 | public void abortTransient_correctDisplayId_noInsets_transientModeNotCleared() { |
| 315 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 316 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
| 317 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 318 | mCarNavigationBar.start(); |
| 319 | mCarNavigationBar.showTransient(Display.DEFAULT_DISPLAY, |
| 320 | new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR}); |
| 321 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isTrue(); |
| 322 | assertThat(mCarNavigationBar.isNavBarTransientShown()).isTrue(); |
| 323 | |
| 324 | int[] insetTypes = new int[]{}; |
| 325 | mCarNavigationBar.abortTransient(Display.DEFAULT_DISPLAY, insetTypes); |
| 326 | |
| 327 | // The transient booleans were not cleared. |
| 328 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isTrue(); |
| 329 | assertThat(mCarNavigationBar.isNavBarTransientShown()).isTrue(); |
| 330 | } |
| 331 | |
| 332 | @Test |
| 333 | public void abortTransient_correctDisplayId_statusBarInset_transientModeCleared() { |
| 334 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 335 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
| 336 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 337 | mCarNavigationBar.start(); |
| 338 | mCarNavigationBar.showTransient(Display.DEFAULT_DISPLAY, |
| 339 | new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR}); |
| 340 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isTrue(); |
| 341 | assertThat(mCarNavigationBar.isNavBarTransientShown()).isTrue(); |
| 342 | |
| 343 | int[] insetTypes = new int[]{ITYPE_STATUS_BAR}; |
| 344 | mCarNavigationBar.abortTransient(Display.DEFAULT_DISPLAY, insetTypes); |
| 345 | |
| 346 | // The transient booleans were cleared. |
| 347 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isFalse(); |
| 348 | assertThat(mCarNavigationBar.isNavBarTransientShown()).isFalse(); |
| 349 | } |
| 350 | |
| 351 | @Test |
| 352 | public void abortTransient_correctDisplayId_navBarInset_transientModeCleared() { |
| 353 | mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true); |
| 354 | mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true); |
| 355 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); |
| 356 | mCarNavigationBar.start(); |
| 357 | mCarNavigationBar.showTransient(Display.DEFAULT_DISPLAY, |
| 358 | new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR}); |
| 359 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isTrue(); |
| 360 | assertThat(mCarNavigationBar.isNavBarTransientShown()).isTrue(); |
| 361 | |
| 362 | int[] insetTypes = new int[]{ITYPE_NAVIGATION_BAR}; |
| 363 | mCarNavigationBar.abortTransient(Display.DEFAULT_DISPLAY, insetTypes); |
| 364 | |
| 365 | // The transient booleans were cleared. |
| 366 | assertThat(mCarNavigationBar.isStatusBarTransientShown()).isFalse(); |
| 367 | assertThat(mCarNavigationBar.isNavBarTransientShown()).isFalse(); |
| 368 | } |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 369 | } |