Lucas Dupin | 1fc01dc | 2018-09-24 16:43:06 -0700 | [diff] [blame] | 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 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 19 | import androidx.test.filters.SmallTest |
Lucas Dupin | 1fc01dc | 2018-09-24 16:43:06 -0700 | [diff] [blame] | 20 | import android.testing.AndroidTestingRunner |
| 21 | import android.testing.TestableLooper |
| 22 | import android.view.LayoutInflater |
| 23 | |
Sunny Goyal | 87fccf0 | 2019-08-13 17:39:10 -0700 | [diff] [blame] | 24 | import com.android.systemui.R |
Lucas Dupin | 1fc01dc | 2018-09-24 16:43:06 -0700 | [diff] [blame] | 25 | import com.android.systemui.SysuiTestCase |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 26 | import com.android.systemui.statusbar.policy.ConfigurationController |
Lucas Dupin | 1fc01dc | 2018-09-24 16:43:06 -0700 | [diff] [blame] | 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 |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 32 | import org.mockito.Mockito.mock |
Lucas Dupin | 1fc01dc | 2018-09-24 16:43:06 -0700 | [diff] [blame] | 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 |
| 43 | fun setup() { |
| 44 | val inflater = LayoutInflater.from(context) |
| 45 | mKeyguardPatternView = inflater.inflate(R.layout.keyguard_pattern_view, null) |
| 46 | as KeyguardPatternView |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 47 | mSecurityMessage = KeyguardMessageArea(mContext, null, |
| 48 | mock(KeyguardUpdateMonitor::class.java), mock(ConfigurationController::class.java)) |
| 49 | mKeyguardPatternView.mSecurityMessageDisplay = mSecurityMessage |
Lucas Dupin | 1fc01dc | 2018-09-24 16:43:06 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | @Test |
Lucas Dupin | c6b50c6 | 2018-10-09 20:00:35 -0700 | [diff] [blame] | 53 | fun onPause_clearsTextField() { |
Lucas Dupin | 1fc01dc | 2018-09-24 16:43:06 -0700 | [diff] [blame] | 54 | mSecurityMessage.setMessage("an old message") |
Lucas Dupin | c6b50c6 | 2018-10-09 20:00:35 -0700 | [diff] [blame] | 55 | mKeyguardPatternView.onPause() |
Lucas Dupin | 1fc01dc | 2018-09-24 16:43:06 -0700 | [diff] [blame] | 56 | assertThat(mSecurityMessage.text).isEqualTo("") |
| 57 | } |
| 58 | } |