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.keyguard
17 
18 import android.graphics.drawable.Drawable
19 import android.graphics.drawable.GradientDrawable
20 import android.testing.AndroidTestingRunner
21 import android.testing.TestableLooper
22 import androidx.test.filters.SmallTest
23 import com.android.systemui.SysuiTestCase
24 import org.junit.Before
25 import org.junit.Test
26 import org.junit.runner.RunWith
27 import org.mockito.Mock
28 import org.mockito.Mockito.anyFloat
29 import org.mockito.Mockito.never
30 import org.mockito.Mockito.reset
31 import org.mockito.Mockito.verify
32 import org.mockito.MockitoAnnotations
33 
34 @SmallTest
35 @RunWith(AndroidTestingRunner::class)
36 @TestableLooper.RunWithLooper
37 class NumPadAnimatorTest : SysuiTestCase() {
38     @Mock lateinit var background: GradientDrawable
39     @Mock lateinit var buttonImage: Drawable
40     private lateinit var underTest: NumPadAnimator
41 
42     @Before
43     fun setup() {
44         MockitoAnnotations.initMocks(this)
45         underTest = NumPadAnimator(context, background, 0, buttonImage)
46     }
47 
48     @Test
49     fun testOnLayout() {
50         underTest.onLayout(100, 100)
51         verify(background).cornerRadius = 50f
52         reset(background)
53         underTest.onLayout(100, 100)
54         verify(background, never()).cornerRadius = anyFloat()
55     }
56 }
57