1 /*
2  * Copyright (C) 2018 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 androidx.test.filters.SmallTest
20 import android.testing.AndroidTestingRunner
21 import android.testing.TestableLooper
22 import android.view.LayoutInflater
23 
24 import com.android.systemui.R
25 import com.android.systemui.SysuiTestCase
26 import com.android.systemui.statusbar.policy.ConfigurationController
27 import com.google.common.truth.Truth.assertThat
28 
29 import org.junit.Before
30 import org.junit.Test
31 import org.junit.runner.RunWith
32 import org.mockito.Mockito.mock
33 
34 @SmallTest
35 @RunWith(AndroidTestingRunner::class)
36 @TestableLooper.RunWithLooper
37 class KeyguardPatternViewTest : SysuiTestCase() {
38 
39     private lateinit var mKeyguardPatternView: KeyguardPatternView
40     private lateinit var mSecurityMessage: KeyguardMessageArea
41 
42     @Before
setupnull43     fun setup() {
44         val inflater = LayoutInflater.from(context)
45         mDependency.injectMockDependency(KeyguardUpdateMonitor::class.java)
46         mKeyguardPatternView = inflater.inflate(R.layout.keyguard_pattern_view, null)
47                 as KeyguardPatternView
48         mSecurityMessage = KeyguardMessageArea(mContext, null,
49                 mock(KeyguardUpdateMonitor::class.java), mock(ConfigurationController::class.java))
50         mKeyguardPatternView.mSecurityMessageDisplay = mSecurityMessage
51     }
52 
53     @Test
onPause_clearsTextFieldnull54     fun onPause_clearsTextField() {
55         mSecurityMessage.setMessage("an old message")
56         mKeyguardPatternView.onPause()
57         assertThat(mSecurityMessage.text).isEqualTo("")
58     }
59 }
60