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.systemui.notetask 17 18 import android.os.UserHandle 19 import android.testing.AndroidTestingRunner 20 import androidx.test.filters.SmallTest 21 import com.android.systemui.SysuiTestCase 22 import com.android.systemui.notetask.NoteTaskEntryPoint.WIDGET_PICKER_SHORTCUT_IN_MULTI_WINDOW_MODE 23 import com.google.common.truth.Truth.assertThat 24 import org.junit.Test 25 import org.junit.runner.RunWith 26 27 /** atest SystemUITests:NoteTaskInfoTest */ 28 @SmallTest 29 @RunWith(AndroidTestingRunner::class) 30 internal class NoteTaskInfoTest : SysuiTestCase() { 31 32 @Test 33 fun launchMode_keyguardLocked_launchModeActivity() { 34 val underTest = DEFAULT_INFO.copy(isKeyguardLocked = true) 35 36 assertThat(underTest.launchMode).isEqualTo(NoteTaskLaunchMode.Activity) 37 } 38 39 @Test 40 fun launchMode_multiWindowMode_launchModeActivity() { 41 val underTest = DEFAULT_INFO.copy(entryPoint = WIDGET_PICKER_SHORTCUT_IN_MULTI_WINDOW_MODE) 42 43 assertThat(underTest.launchMode).isEqualTo(NoteTaskLaunchMode.Activity) 44 } 45 46 @Test 47 fun launchMode_keyguardUnlocked_launchModeAppBubble() { 48 val underTest = DEFAULT_INFO.copy(isKeyguardLocked = false) 49 50 assertThat(underTest.launchMode).isEqualTo(NoteTaskLaunchMode.AppBubble) 51 } 52 53 private companion object { 54 55 val DEFAULT_INFO = 56 NoteTaskInfo( 57 packageName = "com.android.note.app", 58 uid = 123456, 59 user = UserHandle.of(0), 60 ) 61 } 62 } 63