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.keyguard
18 
19 import android.testing.AndroidTestingRunner
20 import android.testing.TestableLooper
21 import android.view.LayoutInflater
22 import androidx.test.filters.SmallTest
23 import com.android.systemui.R
24 import com.android.systemui.SysuiTestCase
25 import com.google.common.truth.Truth
26 import org.junit.Before
27 import org.junit.Test
28 import org.junit.runner.RunWith
29 
30 @SmallTest
31 @RunWith(AndroidTestingRunner::class)
32 @TestableLooper.RunWithLooper
33 class PinShapeHintingViewTest : SysuiTestCase() {
34     lateinit var underTest: PinShapeHintingView
35 
36     @Before
37     fun setup() {
38         underTest =
39             LayoutInflater.from(context).inflate(R.layout.keyguard_pin_shape_hinting_view, null)
40                 as PinShapeHintingView
41     }
42 
43     @Test
44     fun testAppend() {
45         // Add more when animation part is complete
46         underTest.append()
47         Truth.assertThat(underTest.childCount).isEqualTo(6)
48     }
49 
50     @Test
51     fun testDelete() {
52         underTest.delete()
53         Truth.assertThat(underTest.childCount).isEqualTo(6)
54     }
55 
56     @Test
57     fun testReset() {
58         for (i in 0 until 3) {
59             underTest.append()
60         }
61         underTest.reset()
62         Truth.assertThat(underTest.childCount).isEqualTo(6)
63     }
64 }
65