Home | History | Annotate | Download | only in keyguard
      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.SysuiTestCase
     25 import com.android.systemui.statusbar.policy.ConfigurationController
     26 import com.google.common.truth.Truth.assertThat
     27 
     28 import org.junit.Before
     29 import org.junit.Test
     30 import org.junit.runner.RunWith
     31 import org.mockito.Mockito.mock
     32 
     33 @SmallTest
     34 @RunWith(AndroidTestingRunner::class)
     35 @TestableLooper.RunWithLooper
     36 class 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
     46         mSecurityMessage = KeyguardMessageArea(mContext, null,
     47                 mock(KeyguardUpdateMonitor::class.java), mock(ConfigurationController::class.java))
     48         mKeyguardPatternView.mSecurityMessageDisplay = mSecurityMessage
     49     }
     50 
     51     @Test
     52     fun onPause_clearsTextField() {
     53         mSecurityMessage.setMessage("an old message")
     54         mKeyguardPatternView.onPause()
     55         assertThat(mSecurityMessage.text).isEqualTo("")
     56     }
     57 }
     58