blob: 42a89509975de444aa062e82c4abc5f8b3dc539e [file] [log] [blame]
Lucas Dupin1fc01dc2018-09-24 16:43:06 -07001/*
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
17package com.android.keyguard
18
Brett Chabot84151d92019-02-27 15:37:59 -080019import androidx.test.filters.SmallTest
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070020import android.testing.AndroidTestingRunner
21import android.testing.TestableLooper
22import android.view.LayoutInflater
23
Sunny Goyal87fccf02019-08-13 17:39:10 -070024import com.android.systemui.R
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070025import com.android.systemui.SysuiTestCase
Lucas Dupin2e838ac2019-04-17 16:50:58 -070026import com.android.systemui.statusbar.policy.ConfigurationController
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070027import com.google.common.truth.Truth.assertThat
28
29import org.junit.Before
30import org.junit.Test
31import org.junit.runner.RunWith
Lucas Dupin2e838ac2019-04-17 16:50:58 -070032import org.mockito.Mockito.mock
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070033
34@SmallTest
35@RunWith(AndroidTestingRunner::class)
36@TestableLooper.RunWithLooper
37class KeyguardPatternViewTest : SysuiTestCase() {
38
39 private lateinit var mKeyguardPatternView: KeyguardPatternView
40 private lateinit var mSecurityMessage: KeyguardMessageArea
41
42 @Before
43 fun setup() {
44 val inflater = LayoutInflater.from(context)
45 mKeyguardPatternView = inflater.inflate(R.layout.keyguard_pattern_view, null)
46 as KeyguardPatternView
Lucas Dupin2e838ac2019-04-17 16:50:58 -070047 mSecurityMessage = KeyguardMessageArea(mContext, null,
48 mock(KeyguardUpdateMonitor::class.java), mock(ConfigurationController::class.java))
49 mKeyguardPatternView.mSecurityMessageDisplay = mSecurityMessage
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070050 }
51
52 @Test
Lucas Dupinc6b50c62018-10-09 20:00:35 -070053 fun onPause_clearsTextField() {
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070054 mSecurityMessage.setMessage("an old message")
Lucas Dupinc6b50c62018-10-09 20:00:35 -070055 mKeyguardPatternView.onPause()
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070056 assertThat(mSecurityMessage.text).isEqualTo("")
57 }
58}