1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package com.android.systemui.statusbar.phone.fragment; 16 17 import static android.view.Display.DEFAULT_DISPLAY; 18 19 import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.ANIMATING_IN; 20 import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.ANIMATING_OUT; 21 import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.IDLE; 22 import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.RUNNING_CHIP_ANIM; 23 24 import static org.junit.Assert.assertEquals; 25 import static org.junit.Assert.assertFalse; 26 import static org.junit.Assert.assertNotEquals; 27 import static org.junit.Assert.assertTrue; 28 import static org.mockito.ArgumentMatchers.any; 29 import static org.mockito.Matchers.eq; 30 import static org.mockito.Mockito.atLeast; 31 import static org.mockito.Mockito.doAnswer; 32 import static org.mockito.Mockito.mock; 33 import static org.mockito.Mockito.when; 34 35 import android.app.Fragment; 36 import android.app.StatusBarManager; 37 import android.content.Context; 38 import android.os.Bundle; 39 import android.os.UserHandle; 40 import android.provider.Settings; 41 import android.testing.AndroidTestingRunner; 42 import android.testing.TestableLooper.RunWithLooper; 43 import android.view.View; 44 import android.view.ViewPropertyAnimator; 45 import android.widget.FrameLayout; 46 47 import androidx.core.animation.Animator; 48 import androidx.test.filters.SmallTest; 49 50 import com.android.keyguard.KeyguardUpdateMonitor; 51 import com.android.systemui.R; 52 import com.android.systemui.SysuiBaseFragmentTest; 53 import com.android.systemui.dump.DumpManager; 54 import com.android.systemui.flags.FeatureFlags; 55 import com.android.systemui.plugins.DarkIconDispatcher; 56 import com.android.systemui.plugins.log.LogBuffer; 57 import com.android.systemui.plugins.log.LogcatEchoTracker; 58 import com.android.systemui.plugins.statusbar.StatusBarStateController; 59 import com.android.systemui.shade.NotificationPanelViewController; 60 import com.android.systemui.shade.ShadeExpansionStateManager; 61 import com.android.systemui.statusbar.CommandQueue; 62 import com.android.systemui.statusbar.DisableFlagsLogger; 63 import com.android.systemui.statusbar.OperatorNameViewController; 64 import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler; 65 import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; 66 import com.android.systemui.statusbar.phone.NotificationIconAreaController; 67 import com.android.systemui.statusbar.phone.StatusBarHideIconsForBouncerManager; 68 import com.android.systemui.statusbar.phone.StatusBarIconController; 69 import com.android.systemui.statusbar.phone.StatusBarLocationPublisher; 70 import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent; 71 import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController; 72 import com.android.systemui.statusbar.policy.KeyguardStateController; 73 import com.android.systemui.statusbar.window.StatusBarWindowStateController; 74 import com.android.systemui.statusbar.window.StatusBarWindowStateListener; 75 import com.android.systemui.util.CarrierConfigTracker; 76 import com.android.systemui.util.concurrency.FakeExecutor; 77 import com.android.systemui.util.settings.SecureSettings; 78 import com.android.systemui.util.time.FakeSystemClock; 79 80 import org.junit.Before; 81 import org.junit.Test; 82 import org.junit.runner.RunWith; 83 import org.mockito.Mock; 84 import org.mockito.Mockito; 85 import org.mockito.MockitoAnnotations; 86 87 import java.util.ArrayList; 88 import java.util.List; 89 90 @RunWith(AndroidTestingRunner.class) 91 @RunWithLooper(setAsMainLooper = true) 92 @SmallTest 93 public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { 94 95 private NotificationIconAreaController mMockNotificationAreaController; 96 private View mNotificationAreaInner; 97 private OngoingCallController mOngoingCallController; 98 private SystemStatusAnimationScheduler mAnimationScheduler; 99 private StatusBarLocationPublisher mLocationPublisher; 100 // Set in instantiate() 101 private StatusBarIconController mStatusBarIconController; 102 private KeyguardStateController mKeyguardStateController; 103 104 private final CommandQueue mCommandQueue = mock(CommandQueue.class); 105 private OperatorNameViewController.Factory mOperatorNameViewControllerFactory; 106 private OperatorNameViewController mOperatorNameViewController; 107 private SecureSettings mSecureSettings; 108 private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock()); 109 private final CarrierConfigTracker mCarrierConfigTracker = mock(CarrierConfigTracker.class); 110 111 @Mock 112 private StatusBarFragmentComponent.Factory mStatusBarFragmentComponentFactory; 113 @Mock 114 private StatusBarFragmentComponent mStatusBarFragmentComponent; 115 @Mock 116 private StatusBarStateController mStatusBarStateController; 117 @Mock 118 private HeadsUpAppearanceController mHeadsUpAppearanceController; 119 @Mock 120 private NotificationPanelViewController mNotificationPanelViewController; 121 @Mock 122 private StatusBarIconController.DarkIconManager.Factory mIconManagerFactory; 123 @Mock 124 private StatusBarIconController.DarkIconManager mIconManager; 125 @Mock 126 private StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager; 127 @Mock 128 private DumpManager mDumpManager; 129 @Mock 130 private StatusBarWindowStateController mStatusBarWindowStateController; 131 @Mock 132 private KeyguardUpdateMonitor mKeyguardUpdateMonitor; 133 134 private List<StatusBarWindowStateListener> mStatusBarWindowStateListeners = new ArrayList<>(); 135 CollapsedStatusBarFragmentTest()136 public CollapsedStatusBarFragmentTest() { 137 super(CollapsedStatusBarFragment.class); 138 } 139 140 @Before setup()141 public void setup() { 142 injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES); 143 mDependency.injectMockDependency(DarkIconDispatcher.class); 144 145 // Keep the window state listeners so we can dispatch to them to test the status bar 146 // fragment's response. 147 doAnswer(invocation -> { 148 mStatusBarWindowStateListeners.add(invocation.getArgument(0)); 149 return null; 150 }).when(mStatusBarWindowStateController).addListener( 151 any(StatusBarWindowStateListener.class)); 152 } 153 154 @Test testDisableNone()155 public void testDisableNone() { 156 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 157 158 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 159 160 assertEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 161 assertEquals(View.VISIBLE, getClockView().getVisibility()); 162 } 163 164 @Test testDisableSystemInfo_systemAnimationIdle_doesHide()165 public void testDisableSystemInfo_systemAnimationIdle_doesHide() { 166 when(mAnimationScheduler.getAnimationState()).thenReturn(IDLE); 167 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 168 169 fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_SYSTEM_INFO, 0, false); 170 171 assertEquals(View.INVISIBLE, getEndSideContentView().getVisibility()); 172 173 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 174 175 assertEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 176 } 177 178 @Test testSystemStatusAnimation_startedDisabled_finishedWithAnimator_showsSystemInfo()179 public void testSystemStatusAnimation_startedDisabled_finishedWithAnimator_showsSystemInfo() { 180 // GIVEN the status bar hides the system info via disable flags, while there is no event 181 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 182 when(mAnimationScheduler.getAnimationState()).thenReturn(IDLE); 183 fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_SYSTEM_INFO, 0, false); 184 assertEquals(View.INVISIBLE, getEndSideContentView().getVisibility()); 185 186 // WHEN the disable flags are cleared during a system event animation 187 when(mAnimationScheduler.getAnimationState()).thenReturn(RUNNING_CHIP_ANIM); 188 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 189 190 // THEN the view is made visible again, but still low alpha 191 assertEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 192 assertEquals(0, getEndSideContentView().getAlpha(), 0.01); 193 194 // WHEN the system event animation finishes 195 when(mAnimationScheduler.getAnimationState()).thenReturn(ANIMATING_OUT); 196 Animator anim = fragment.onSystemEventAnimationFinish(false); 197 anim.start(); 198 processAllMessages(); 199 anim.end(); 200 201 // THEN the system info is full alpha 202 assertEquals(1, getEndSideContentView().getAlpha(), 0.01); 203 } 204 205 @Test testSystemStatusAnimation_systemInfoDisabled_staysInvisible()206 public void testSystemStatusAnimation_systemInfoDisabled_staysInvisible() { 207 // GIVEN the status bar hides the system info via disable flags, while there is no event 208 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 209 when(mAnimationScheduler.getAnimationState()).thenReturn(IDLE); 210 fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_SYSTEM_INFO, 0, false); 211 assertEquals(View.INVISIBLE, getEndSideContentView().getVisibility()); 212 213 // WHEN the system event animation finishes 214 when(mAnimationScheduler.getAnimationState()).thenReturn(ANIMATING_OUT); 215 Animator anim = fragment.onSystemEventAnimationFinish(false); 216 anim.start(); 217 processAllMessages(); 218 anim.end(); 219 220 // THEN the system info is at full alpha, but still INVISIBLE (since the disable flag is 221 // still set) 222 assertEquals(1, getEndSideContentView().getAlpha(), 0.01); 223 assertEquals(View.INVISIBLE, getEndSideContentView().getVisibility()); 224 } 225 226 227 @Test testSystemStatusAnimation_notDisabled_animatesAlphaZero()228 public void testSystemStatusAnimation_notDisabled_animatesAlphaZero() { 229 // GIVEN the status bar is not disabled 230 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 231 when(mAnimationScheduler.getAnimationState()).thenReturn(ANIMATING_IN); 232 // WHEN the system event animation begins 233 Animator anim = fragment.onSystemEventAnimationBegin(); 234 anim.start(); 235 processAllMessages(); 236 anim.end(); 237 238 // THEN the system info is visible but alpha 0 239 assertEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 240 assertEquals(0, getEndSideContentView().getAlpha(), 0.01); 241 } 242 243 @Test testSystemStatusAnimation_notDisabled_animatesBackToAlphaOne()244 public void testSystemStatusAnimation_notDisabled_animatesBackToAlphaOne() { 245 // GIVEN the status bar is not disabled 246 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 247 when(mAnimationScheduler.getAnimationState()).thenReturn(ANIMATING_IN); 248 // WHEN the system event animation begins 249 Animator anim = fragment.onSystemEventAnimationBegin(); 250 anim.start(); 251 processAllMessages(); 252 anim.end(); 253 254 // THEN the system info is visible but alpha 0 255 assertEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 256 assertEquals(0, getEndSideContentView().getAlpha(), 0.01); 257 258 // WHEN the system event animation finishes 259 when(mAnimationScheduler.getAnimationState()).thenReturn(ANIMATING_OUT); 260 anim = fragment.onSystemEventAnimationFinish(false); 261 anim.start(); 262 processAllMessages(); 263 anim.end(); 264 265 // THEN the syste info is full alpha and VISIBLE 266 assertEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 267 assertEquals(1, getEndSideContentView().getAlpha(), 0.01); 268 } 269 270 @Test testDisableNotifications()271 public void testDisableNotifications() { 272 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 273 274 fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_NOTIFICATION_ICONS, 0, false); 275 276 Mockito.verify(mNotificationAreaInner, atLeast(1)).setVisibility(eq(View.INVISIBLE)); 277 278 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 279 280 Mockito.verify(mNotificationAreaInner, atLeast(1)).setVisibility(eq(View.VISIBLE)); 281 } 282 283 @Test testDisableClock()284 public void testDisableClock() { 285 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 286 287 fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_CLOCK, 0, false); 288 289 assertEquals(View.GONE, getClockView().getVisibility()); 290 291 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 292 293 assertEquals(View.VISIBLE, getClockView().getVisibility()); 294 } 295 296 @Test userChip_defaultVisibilityIsGone()297 public void userChip_defaultVisibilityIsGone() { 298 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 299 300 assertEquals(View.GONE, getUserChipView().getVisibility()); 301 } 302 303 @Test disable_noOngoingCall_chipHidden()304 public void disable_noOngoingCall_chipHidden() { 305 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 306 307 when(mOngoingCallController.hasOngoingCall()).thenReturn(false); 308 309 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 310 311 assertEquals(View.GONE, 312 mFragment.getView().findViewById(R.id.ongoing_call_chip).getVisibility()); 313 } 314 315 @Test disable_hasOngoingCall_chipDisplayedAndNotificationIconsHidden()316 public void disable_hasOngoingCall_chipDisplayedAndNotificationIconsHidden() { 317 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 318 319 when(mOngoingCallController.hasOngoingCall()).thenReturn(true); 320 321 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 322 323 assertEquals(View.VISIBLE, 324 mFragment.getView().findViewById(R.id.ongoing_call_chip).getVisibility()); 325 Mockito.verify(mNotificationAreaInner, atLeast(1)).setVisibility(eq(View.INVISIBLE)); 326 327 } 328 329 @Test disable_hasOngoingCallButNotificationIconsDisabled_chipHidden()330 public void disable_hasOngoingCallButNotificationIconsDisabled_chipHidden() { 331 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 332 333 when(mOngoingCallController.hasOngoingCall()).thenReturn(true); 334 335 fragment.disable(DEFAULT_DISPLAY, 336 StatusBarManager.DISABLE_NOTIFICATION_ICONS, 0, false); 337 338 assertEquals(View.GONE, 339 mFragment.getView().findViewById(R.id.ongoing_call_chip).getVisibility()); 340 } 341 342 @Test disable_hasOngoingCallButAlsoHun_chipHidden()343 public void disable_hasOngoingCallButAlsoHun_chipHidden() { 344 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 345 346 when(mOngoingCallController.hasOngoingCall()).thenReturn(true); 347 when(mHeadsUpAppearanceController.shouldBeVisible()).thenReturn(true); 348 349 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 350 351 assertEquals(View.GONE, 352 mFragment.getView().findViewById(R.id.ongoing_call_chip).getVisibility()); 353 } 354 355 @Test disable_ongoingCallEnded_chipHidden()356 public void disable_ongoingCallEnded_chipHidden() { 357 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 358 359 when(mOngoingCallController.hasOngoingCall()).thenReturn(true); 360 361 // Ongoing call started 362 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 363 assertEquals(View.VISIBLE, 364 mFragment.getView().findViewById(R.id.ongoing_call_chip).getVisibility()); 365 366 // Ongoing call ended 367 when(mOngoingCallController.hasOngoingCall()).thenReturn(false); 368 369 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 370 371 assertEquals(View.GONE, 372 mFragment.getView().findViewById(R.id.ongoing_call_chip).getVisibility()); 373 } 374 375 @Test disable_isDozing_clockAndSystemInfoVisible()376 public void disable_isDozing_clockAndSystemInfoVisible() { 377 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 378 when(mStatusBarStateController.isDozing()).thenReturn(true); 379 380 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 381 382 assertEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 383 assertEquals(View.VISIBLE, getClockView().getVisibility()); 384 } 385 386 @Test disable_NotDozing_clockAndSystemInfoVisible()387 public void disable_NotDozing_clockAndSystemInfoVisible() { 388 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 389 when(mStatusBarStateController.isDozing()).thenReturn(false); 390 391 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 392 393 assertEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 394 assertEquals(View.VISIBLE, getClockView().getVisibility()); 395 } 396 397 @Test disable_headsUpShouldBeVisibleTrue_clockDisabled()398 public void disable_headsUpShouldBeVisibleTrue_clockDisabled() { 399 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 400 when(mHeadsUpAppearanceController.shouldBeVisible()).thenReturn(true); 401 402 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 403 404 assertEquals(View.GONE, getClockView().getVisibility()); 405 } 406 407 @Test disable_headsUpShouldBeVisibleFalse_clockNotDisabled()408 public void disable_headsUpShouldBeVisibleFalse_clockNotDisabled() { 409 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 410 when(mHeadsUpAppearanceController.shouldBeVisible()).thenReturn(false); 411 412 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 413 414 assertEquals(View.VISIBLE, getClockView().getVisibility()); 415 } 416 417 @Test setUp_fragmentCreatesDaggerComponent()418 public void setUp_fragmentCreatesDaggerComponent() { 419 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 420 421 assertEquals(mStatusBarFragmentComponent, fragment.getStatusBarFragmentComponent()); 422 } 423 424 @Test testBlockedIcons_obeysSettingForVibrateIcon_settingOff()425 public void testBlockedIcons_obeysSettingForVibrateIcon_settingOff() { 426 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 427 String str = mContext.getString(com.android.internal.R.string.status_bar_volume); 428 429 // GIVEN the setting is off 430 when(mSecureSettings.getInt(Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON, 0)) 431 .thenReturn(0); 432 433 // WHEN CollapsedStatusBarFragment builds the blocklist 434 fragment.updateBlockedIcons(); 435 436 // THEN status_bar_volume SHOULD be present in the list 437 boolean contains = fragment.getBlockedIcons().contains(str); 438 assertTrue(contains); 439 } 440 441 @Test testBlockedIcons_obeysSettingForVibrateIcon_settingOn()442 public void testBlockedIcons_obeysSettingForVibrateIcon_settingOn() { 443 CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 444 String str = mContext.getString(com.android.internal.R.string.status_bar_volume); 445 446 // GIVEN the setting is ON 447 when(mSecureSettings.getIntForUser(Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON, 0, 448 UserHandle.USER_CURRENT)) 449 .thenReturn(1); 450 451 // WHEN CollapsedStatusBarFragment builds the blocklist 452 fragment.updateBlockedIcons(); 453 454 // THEN status_bar_volume SHOULD NOT be present in the list 455 boolean contains = fragment.getBlockedIcons().contains(str); 456 assertFalse(contains); 457 } 458 459 @Test testStatusBarIcons_hiddenThroughoutCameraLaunch()460 public void testStatusBarIcons_hiddenThroughoutCameraLaunch() { 461 final CollapsedStatusBarFragment fragment = resumeAndGetFragment(); 462 463 mockSecureCameraLaunch(fragment, true /* launched */); 464 465 // Status icons should be invisible or gone, but certainly not VISIBLE. 466 assertNotEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 467 assertNotEquals(View.VISIBLE, getClockView().getVisibility()); 468 469 mockSecureCameraLaunchFinished(); 470 471 assertNotEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 472 assertNotEquals(View.VISIBLE, getClockView().getVisibility()); 473 474 mockSecureCameraLaunch(fragment, false /* launched */); 475 476 assertEquals(View.VISIBLE, getEndSideContentView().getVisibility()); 477 assertEquals(View.VISIBLE, getClockView().getVisibility()); 478 } 479 480 @Override instantiate(Context context, String className, Bundle arguments)481 protected Fragment instantiate(Context context, String className, Bundle arguments) { 482 MockitoAnnotations.initMocks(this); 483 setUpDaggerComponent(); 484 mOngoingCallController = mock(OngoingCallController.class); 485 mAnimationScheduler = mock(SystemStatusAnimationScheduler.class); 486 mLocationPublisher = mock(StatusBarLocationPublisher.class); 487 mStatusBarIconController = mock(StatusBarIconController.class); 488 mStatusBarStateController = mock(StatusBarStateController.class); 489 mKeyguardStateController = mock(KeyguardStateController.class); 490 mOperatorNameViewController = mock(OperatorNameViewController.class); 491 mOperatorNameViewControllerFactory = mock(OperatorNameViewController.Factory.class); 492 when(mOperatorNameViewControllerFactory.create(any())) 493 .thenReturn(mOperatorNameViewController); 494 when(mIconManagerFactory.create(any(), any())).thenReturn(mIconManager); 495 mSecureSettings = mock(SecureSettings.class); 496 497 setUpNotificationIconAreaController(); 498 return new CollapsedStatusBarFragment( 499 mStatusBarFragmentComponentFactory, 500 mOngoingCallController, 501 mAnimationScheduler, 502 mLocationPublisher, 503 mMockNotificationAreaController, 504 new ShadeExpansionStateManager(), 505 mock(FeatureFlags.class), 506 mStatusBarIconController, 507 mIconManagerFactory, 508 mStatusBarHideIconsForBouncerManager, 509 mKeyguardStateController, 510 mNotificationPanelViewController, 511 mStatusBarStateController, 512 mCommandQueue, 513 mCarrierConfigTracker, 514 new CollapsedStatusBarFragmentLogger( 515 new LogBuffer("TEST", 1, mock(LogcatEchoTracker.class)), 516 new DisableFlagsLogger() 517 ), 518 mOperatorNameViewControllerFactory, 519 mSecureSettings, 520 mExecutor, 521 mDumpManager, 522 mStatusBarWindowStateController, 523 mKeyguardUpdateMonitor); 524 } 525 setUpDaggerComponent()526 private void setUpDaggerComponent() { 527 when(mStatusBarFragmentComponentFactory.create(any())) 528 .thenReturn(mStatusBarFragmentComponent); 529 when(mStatusBarFragmentComponent.getHeadsUpAppearanceController()) 530 .thenReturn(mHeadsUpAppearanceController); 531 } 532 setUpNotificationIconAreaController()533 private void setUpNotificationIconAreaController() { 534 mMockNotificationAreaController = mock(NotificationIconAreaController.class); 535 536 mNotificationAreaInner = mock(View.class); 537 538 when(mNotificationAreaInner.getLayoutParams()).thenReturn( 539 new FrameLayout.LayoutParams(100, 100)); 540 when(mNotificationAreaInner.animate()).thenReturn(mock(ViewPropertyAnimator.class)); 541 542 when(mMockNotificationAreaController.getNotificationInnerAreaView()).thenReturn( 543 mNotificationAreaInner); 544 } 545 546 /** 547 * Configure mocks to return values consistent with the secure camera animating itself launched 548 * over the keyguard. 549 */ mockSecureCameraLaunch(CollapsedStatusBarFragment fragment, boolean launched)550 private void mockSecureCameraLaunch(CollapsedStatusBarFragment fragment, boolean launched) { 551 when(mKeyguardUpdateMonitor.isSecureCameraLaunchedOverKeyguard()).thenReturn(launched); 552 when(mKeyguardStateController.isOccluded()).thenReturn(launched); 553 554 if (launched) { 555 fragment.onCameraLaunchGestureDetected(0 /* source */); 556 } else { 557 for (StatusBarWindowStateListener listener : mStatusBarWindowStateListeners) { 558 listener.onStatusBarWindowStateChanged(StatusBarManager.WINDOW_STATE_SHOWING); 559 } 560 } 561 562 fragment.disable(DEFAULT_DISPLAY, 0, 0, false); 563 } 564 565 /** 566 * Configure mocks to return values consistent with the secure camera showing over the keyguard 567 * with its launch animation finished. 568 */ mockSecureCameraLaunchFinished()569 private void mockSecureCameraLaunchFinished() { 570 for (StatusBarWindowStateListener listener : mStatusBarWindowStateListeners) { 571 listener.onStatusBarWindowStateChanged(StatusBarManager.WINDOW_STATE_HIDDEN); 572 } 573 } 574 resumeAndGetFragment()575 private CollapsedStatusBarFragment resumeAndGetFragment() { 576 mFragments.dispatchResume(); 577 processAllMessages(); 578 return (CollapsedStatusBarFragment) mFragment; 579 } 580 getUserChipView()581 private View getUserChipView() { 582 return mFragment.getView().findViewById(R.id.user_switcher_container); 583 } 584 getClockView()585 private View getClockView() { 586 return mFragment.getView().findViewById(R.id.clock); 587 } 588 getEndSideContentView()589 private View getEndSideContentView() { 590 return mFragment.getView().findViewById(R.id.status_bar_end_side_content); 591 } 592 } 593