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 18 19 import android.content.Context 20 import android.content.Intent 21 import android.testing.TestableLooper 22 import androidx.test.ext.junit.runners.AndroidJUnit4 23 import androidx.test.filters.SmallTest 24 import androidx.test.rule.ActivityTestRule 25 import com.android.dx.mockito.inline.extended.ExtendedMockito.verify 26 import com.android.systemui.SysuiTestCase 27 import com.android.systemui.activity.SingleActivityFactory 28 import com.android.systemui.notetask.LaunchNotesRoleSettingsTrampolineActivity.Companion.ACTION_MANAGE_NOTES_ROLE_FROM_QUICK_AFFORDANCE 29 import com.android.systemui.notetask.NoteTaskEntryPoint.QUICK_AFFORDANCE 30 import com.android.systemui.util.mockito.any 31 import com.android.systemui.util.mockito.eq 32 import org.junit.After 33 import org.junit.Before 34 import org.junit.Rule 35 import org.junit.Test 36 import org.junit.runner.RunWith 37 import org.mockito.Mock 38 import org.mockito.MockitoAnnotations 39 40 @RunWith(AndroidJUnit4::class) 41 @SmallTest 42 @TestableLooper.RunWithLooper 43 class LaunchNotesRoleSettingsTrampolineActivityTest : SysuiTestCase() { 44 45 @Mock lateinit var noteTaskController: NoteTaskController 46 47 @Rule 48 @JvmField 49 val activityRule = 50 ActivityTestRule( <lambda>null51 /* activityFactory= */ SingleActivityFactory { 52 LaunchNotesRoleSettingsTrampolineActivity(noteTaskController) 53 }, 54 /* initialTouchMode= */ false, 55 /* launchActivity= */ false, 56 ) 57 58 @Before setUpnull59 fun setUp() { 60 MockitoAnnotations.initMocks(this) 61 } 62 63 @After tearDownnull64 fun tearDown() { 65 activityRule.finishActivity() 66 } 67 68 @Test startActivity_noAction_shouldLaunchNotesRoleSettingTaskWithNullEntryPointnull69 fun startActivity_noAction_shouldLaunchNotesRoleSettingTaskWithNullEntryPoint() { 70 activityRule.launchActivity(/* startIntent= */ null) 71 72 verify(noteTaskController).startNotesRoleSetting(any(Context::class.java), eq(null)) 73 } 74 75 @Test startActivity_quickAffordanceAction_shouldLaunchNotesRoleSettingTaskWithQuickAffordanceEntryPointnull76 fun startActivity_quickAffordanceAction_shouldLaunchNotesRoleSettingTaskWithQuickAffordanceEntryPoint() { // ktlint-disable max-line-length 77 activityRule.launchActivity(Intent(ACTION_MANAGE_NOTES_ROLE_FROM_QUICK_AFFORDANCE)) 78 79 verify(noteTaskController) 80 .startNotesRoleSetting(any(Context::class.java), eq(QUICK_AFFORDANCE)) 81 } 82 } 83