1 /* 2 * Copyright (C) 2023 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 package com.android.launcher3.taskbar 17 18 import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController 19 import com.android.launcher3.taskbar.bubbles.BubbleControllers 20 import com.android.launcher3.taskbar.overlay.TaskbarOverlayController 21 import com.android.systemui.shared.rotation.RotationButtonController 22 import java.util.Optional 23 import org.junit.Before 24 import org.mockito.Mock 25 import org.mockito.MockitoAnnotations 26 27 /** 28 * Helper class to extend to get access to all controllers. Gotta be careful of your relationship 29 * with this class though, it can be quite... controlling. 30 */ 31 abstract class TaskbarBaseTestCase { 32 33 @Mock lateinit var taskbarActivityContext: TaskbarActivityContext 34 @Mock lateinit var taskbarDragController: TaskbarDragController 35 @Mock lateinit var navButtonController: TaskbarNavButtonController 36 @Mock lateinit var navbarButtonsViewController: NavbarButtonsViewController 37 @Mock lateinit var rotationButtonController: RotationButtonController 38 @Mock lateinit var taskbarDragLayerController: TaskbarDragLayerController 39 @Mock lateinit var taskbarScrimViewController: TaskbarScrimViewController 40 @Mock lateinit var taskbarViewController: TaskbarViewController 41 @Mock lateinit var taskbarUnfoldAnimationController: TaskbarUnfoldAnimationController 42 @Mock lateinit var taskbarKeyguardController: TaskbarKeyguardController 43 @Mock lateinit var stashedHandleViewController: StashedHandleViewController 44 @Mock lateinit var taskbarStashController: TaskbarStashController 45 @Mock lateinit var taskbarAutohideSuspendController: TaskbarAutohideSuspendController 46 @Mock lateinit var taskbarPopupController: TaskbarPopupController 47 @Mock 48 lateinit var taskbarForceVisibleImmersiveController: TaskbarForceVisibleImmersiveController 49 @Mock lateinit var taskbarAllAppsController: TaskbarAllAppsController 50 @Mock lateinit var taskbarInsetsController: TaskbarInsetsController 51 @Mock lateinit var voiceInteractionWindowController: VoiceInteractionWindowController 52 @Mock lateinit var taskbarRecentAppsController: TaskbarRecentAppsController 53 @Mock lateinit var taskbarTranslationController: TaskbarTranslationController 54 @Mock lateinit var taskbarSpringOnStashController: TaskbarSpringOnStashController 55 @Mock lateinit var taskbarOverlayController: TaskbarOverlayController 56 @Mock lateinit var taskbarEduTooltipController: TaskbarEduTooltipController 57 @Mock lateinit var keyboardQuickSwitchController: KeyboardQuickSwitchController 58 @Mock lateinit var taskbarPinningController: TaskbarPinningController 59 @Mock lateinit var optionalBubbleControllers: Optional<BubbleControllers> 60 61 lateinit var taskbarControllers: TaskbarControllers 62 63 @Before setupnull64 open fun setup() { 65 /* 66 * NOTE: Mocking of controllers that are written in Kotlin won't work since their methods 67 * are final by default (and should not be changed only for tests), meaning unmockable. 68 * Womp, womp woooommmmppp. 69 * If you want to mock one of those methods, you need to make a parent interface that 70 * includes that method to allow mocking it. 71 */ 72 MockitoAnnotations.initMocks(this) 73 taskbarControllers = 74 TaskbarControllers( 75 taskbarActivityContext, 76 taskbarDragController, 77 navButtonController, 78 navbarButtonsViewController, 79 rotationButtonController, 80 taskbarDragLayerController, 81 taskbarViewController, 82 taskbarScrimViewController, 83 taskbarUnfoldAnimationController, 84 taskbarKeyguardController, 85 stashedHandleViewController, 86 taskbarStashController, 87 taskbarAutohideSuspendController, 88 taskbarPopupController, 89 taskbarForceVisibleImmersiveController, 90 taskbarOverlayController, 91 taskbarAllAppsController, 92 taskbarInsetsController, 93 voiceInteractionWindowController, 94 taskbarTranslationController, 95 taskbarSpringOnStashController, 96 taskbarRecentAppsController, 97 taskbarEduTooltipController, 98 keyboardQuickSwitchController, 99 taskbarPinningController, 100 optionalBubbleControllers, 101 ) 102 } 103 } 104