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 
17 package com.android.systemui.mediaprojection.taskswitcher
18 
19 import androidx.test.ext.junit.runners.AndroidJUnit4
20 import androidx.test.filters.SmallTest
21 import com.android.systemui.Flags.FLAG_PSS_TASK_SWITCHER
22 import com.android.systemui.SysuiTestCase
23 import com.android.systemui.mediaprojection.taskswitcher.ui.TaskSwitcherNotificationCoordinator
24 import com.android.systemui.util.mockito.mock
25 import org.junit.Test
26 import org.junit.runner.RunWith
27 import org.mockito.Mockito.verify
28 import org.mockito.Mockito.verifyZeroInteractions
29 
30 @RunWith(AndroidJUnit4::class)
31 @SmallTest
32 class MediaProjectionTaskSwitcherCoreStartableTest : SysuiTestCase() {
33 
34     private val coordinator = mock<TaskSwitcherNotificationCoordinator>()
35 
36     private val coreStartable =
<lambda>null37         MediaProjectionTaskSwitcherCoreStartable(notificationCoordinatorLazy = { coordinator })
38 
39     @Test
start_flagEnabled_startsCoordinatornull40     fun start_flagEnabled_startsCoordinator() {
41         mSetFlagsRule.enableFlags(FLAG_PSS_TASK_SWITCHER)
42 
43         coreStartable.start()
44 
45         verify(coordinator).start()
46     }
47 
48     @Test
start_flagDisabled_doesNotStartCoordinatornull49     fun start_flagDisabled_doesNotStartCoordinator() {
50         mSetFlagsRule.disableFlags(FLAG_PSS_TASK_SWITCHER)
51 
52         coreStartable.start()
53 
54         verifyZeroInteractions(coordinator)
55     }
56 }
57