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.notetask.shortcut
18 
19 import android.testing.TestableLooper
20 import androidx.test.ext.junit.runners.AndroidJUnit4
21 import androidx.test.filters.SmallTest
22 import androidx.test.rule.ActivityTestRule
23 import com.android.dx.mockito.inline.extended.ExtendedMockito.verify
24 import com.android.systemui.SysuiTestCase
25 import com.android.systemui.activity.SingleActivityFactory
26 import com.android.systemui.notetask.NoteTaskController
27 import com.android.systemui.notetask.NoteTaskEntryPoint
28 import com.android.systemui.util.mockito.any
29 import com.android.systemui.util.mockito.eq
30 import org.junit.After
31 import org.junit.Before
32 import org.junit.Rule
33 import org.junit.Test
34 import org.junit.runner.RunWith
35 import org.mockito.Mock
36 import org.mockito.MockitoAnnotations
37 
38 @RunWith(AndroidJUnit4::class)
39 @SmallTest
40 @TestableLooper.RunWithLooper
41 class LaunchNoteTaskActivityTest : SysuiTestCase() {
42 
43     @Mock lateinit var noteTaskController: NoteTaskController
44 
45     @Rule
46     @JvmField
47     val activityRule =
48         ActivityTestRule<LaunchNoteTaskActivity>(
<lambda>null49             /* activityFactory= */ SingleActivityFactory {
50                 LaunchNoteTaskActivity(controller = noteTaskController)
51             },
52             /* initialTouchMode= */ false,
53             /* launchActivity= */ false,
54         )
55 
56     @Before
setUpnull57     fun setUp() {
58         MockitoAnnotations.initMocks(this)
59     }
60 
61     @After
tearDownnull62     fun tearDown() {
63         activityRule.finishActivity()
64     }
65 
66     @Test
startActivityOnNonWorkProfileUser_shouldLaunchNoteTasknull67     fun startActivityOnNonWorkProfileUser_shouldLaunchNoteTask() {
68         activityRule.launchActivity(/* startIntent= */ null)
69 
70         verify(noteTaskController)
71             .showNoteTaskAsUser(eq(NoteTaskEntryPoint.WIDGET_PICKER_SHORTCUT), any())
72     }
73 }
74