1 /*
2  * Copyright (C) 2024 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.assist.domain.interactor
18 
19 import android.platform.test.annotations.EnableFlags
20 import androidx.test.ext.junit.runners.AndroidJUnit4
21 import androidx.test.filters.SmallTest
22 import com.android.systemui.Flags
23 import com.android.systemui.SysuiTestCase
24 import com.android.systemui.coroutines.collectLastValue
25 import com.android.systemui.kosmos.testScope
26 import com.android.systemui.testKosmos
27 import com.google.common.truth.Truth.assertThat
28 import kotlinx.coroutines.ExperimentalCoroutinesApi
29 import kotlinx.coroutines.test.runCurrent
30 import kotlinx.coroutines.test.runTest
31 import org.junit.Test
32 import org.junit.runner.RunWith
33 
34 @OptIn(ExperimentalCoroutinesApi::class)
35 @RunWith(AndroidJUnit4::class)
36 @SmallTest
37 class AssistInteractorTest : SysuiTestCase() {
38     private val kosmos = testKosmos()
39     private val testScope = kosmos.testScope
40 
41     private val underTest = kosmos.assistInteractor
42 
43     @Test
44     @EnableFlags(Flags.FLAG_ENABLE_CONTEXTUAL_TIPS, Flags.FLAG_ENABLE_CONTEXTUAL_TIP_FOR_POWER_OFF)
onAssistantStartednull45     fun onAssistantStarted() =
46         testScope.runTest {
47             val invocationType by collectLastValue(underTest.latestInvocationType)
48             underTest.onAssistantStarted(3)
49             runCurrent()
50 
51             assertThat(invocationType).isEqualTo(3)
52         }
53 }
54