• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.res.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 PinShapeNonHintingViewTest : SysuiTestCase() {
34     lateinit var underTest: PinShapeNonHintingView
35 
36     @Before
setupnull37     fun setup() {
38         underTest =
39             LayoutInflater.from(context).inflate(R.layout.keyguard_pin_shape_non_hinting_view, null)
40                 as PinShapeNonHintingView
41     }
42 
43     @Test
testAppendnull44     fun testAppend() {
45         // Add more when animation part is complete
46         underTest.append()
47         Truth.assertThat(underTest.childCount).isEqualTo(1)
48     }
49 
50     @Test
testDeletenull51     fun testDelete() {
52         for (i in 0 until 3) {
53             underTest.append()
54         }
55         underTest.delete()
56 
57         underTest.postDelayed(
58             { Truth.assertThat(underTest.childCount).isEqualTo(2) },
59             PasswordTextView.DISAPPEAR_DURATION + 100L
60         )
61     }
62 
63     @Test
testResetnull64     fun testReset() {
65         for (i in 0 until 3) {
66             underTest.append()
67         }
68         underTest.reset()
69         underTest.postDelayed(
70             { Truth.assertThat(underTest.childCount).isEqualTo(0) },
71             PasswordTextView.DISAPPEAR_DURATION + 100L
72         )
73     }
74 }
75