1 /*
2  * Copyright (C) 2022 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.classifier
18 
19 import android.testing.AndroidTestingRunner
20 import android.view.View
21 import android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK
22 import android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK
23 import androidx.test.filters.SmallTest
24 import com.android.systemui.SysuiTestCase
25 import org.junit.Before
26 import org.junit.Test
27 import org.junit.runner.RunWith
28 import org.mockito.Mock
29 import org.mockito.Mockito.never
30 import org.mockito.Mockito.verify
31 import org.mockito.MockitoAnnotations
32 
33 @SmallTest
34 @RunWith(AndroidTestingRunner::class)
35 class FalsingA11yDelegateTest : SysuiTestCase() {
36     @Mock lateinit var falsingCollector: FalsingCollector
37     @Mock lateinit var view: View
38     lateinit var underTest: FalsingA11yDelegate
39 
40     @Before
41     fun setup() {
42         MockitoAnnotations.initMocks(this)
43         underTest = FalsingA11yDelegate(falsingCollector)
44     }
45 
46     @Test
47     fun testPerformAccessibilityAction_ACTION_CLICK() {
48         underTest.performAccessibilityAction(view, ACTION_CLICK, null)
49         verify(falsingCollector).onA11yAction()
50     }
51 
52     @Test
53     fun testPerformAccessibilityAction_not_ACTION_CLICK() {
54         underTest.performAccessibilityAction(view, ACTION_LONG_CLICK, null)
55         verify(falsingCollector, never()).onA11yAction()
56     }
57 }
58