blob: 5f03bdba40b42c420aeda650b2f6f13d404fb87d [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
24import com.android.systemui.SysuiTestCase
Lucas Dupin2e838ac2019-04-17 16:50:58 -070025import com.android.systemui.statusbar.policy.ConfigurationController
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070026import com.google.common.truth.Truth.assertThat
27
28import org.junit.Before
29import org.junit.Test
30import org.junit.runner.RunWith
Lucas Dupin2e838ac2019-04-17 16:50:58 -070031import org.mockito.Mockito.mock
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070032
33@SmallTest
34@RunWith(AndroidTestingRunner::class)
35@TestableLooper.RunWithLooper
36class KeyguardPatternViewTest : SysuiTestCase() {
37
38 private lateinit var mKeyguardPatternView: KeyguardPatternView
39 private lateinit var mSecurityMessage: KeyguardMessageArea
40
41 @Before
42 fun setup() {
43 val inflater = LayoutInflater.from(context)
44 mKeyguardPatternView = inflater.inflate(R.layout.keyguard_pattern_view, null)
45 as KeyguardPatternView
Lucas Dupin2e838ac2019-04-17 16:50:58 -070046 mSecurityMessage = KeyguardMessageArea(mContext, null,
47 mock(KeyguardUpdateMonitor::class.java), mock(ConfigurationController::class.java))
48 mKeyguardPatternView.mSecurityMessageDisplay = mSecurityMessage
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070049 }
50
51 @Test
Lucas Dupinc6b50c62018-10-09 20:00:35 -070052 fun onPause_clearsTextField() {
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070053 mSecurityMessage.setMessage("an old message")
Lucas Dupinc6b50c62018-10-09 20:00:35 -070054 mKeyguardPatternView.onPause()
Lucas Dupin1fc01dc2018-09-24 16:43:06 -070055 assertThat(mSecurityMessage.text).isEqualTo("")
56 }
57}