1 /* 2 * Copyright (C) 2020 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 static com.google.common.truth.Truth.assertThat; 20 21 import android.test.suitebuilder.annotation.SmallTest; 22 import android.testing.AndroidTestingRunner; 23 import android.testing.TestableLooper.RunWithLooper; 24 import android.view.View; 25 26 import com.android.systemui.SysuiTestCase; 27 28 import org.junit.Before; 29 import org.junit.Test; 30 import org.junit.runner.RunWith; 31 import org.mockito.MockitoAnnotations; 32 33 @SmallTest 34 @RunWith(AndroidTestingRunner.class) 35 @RunWithLooper 36 public class AuthKeyguardMessageAreaTest extends SysuiTestCase { 37 private KeyguardMessageArea mKeyguardMessageArea; 38 39 @Before setUp()40 public void setUp() throws Exception { 41 MockitoAnnotations.initMocks(this); 42 mKeyguardMessageArea = new AuthKeyguardMessageArea(mContext, null); 43 mKeyguardMessageArea.setIsVisible(true); 44 } 45 46 @Test testShowsTextField()47 public void testShowsTextField() { 48 mKeyguardMessageArea.setVisibility(View.INVISIBLE); 49 mKeyguardMessageArea.setMessage("oobleck", /* animate= */ true); 50 assertThat(mKeyguardMessageArea.getVisibility()).isEqualTo(View.VISIBLE); 51 assertThat(mKeyguardMessageArea.getText()).isEqualTo("oobleck"); 52 } 53 54 @Test testHiddenWhenBouncerHidden()55 public void testHiddenWhenBouncerHidden() { 56 mKeyguardMessageArea.setIsVisible(false); 57 mKeyguardMessageArea.setVisibility(View.INVISIBLE); 58 mKeyguardMessageArea.setMessage("oobleck", /* animate= */ true); 59 assertThat(mKeyguardMessageArea.getVisibility()).isEqualTo(View.INVISIBLE); 60 assertThat(mKeyguardMessageArea.getText()).isEqualTo("oobleck"); 61 } 62 63 @Test testClearsTextField()64 public void testClearsTextField() { 65 mKeyguardMessageArea.setVisibility(View.VISIBLE); 66 mKeyguardMessageArea.setMessage("", /* animate= */ true); 67 assertThat(mKeyguardMessageArea.getVisibility()).isEqualTo(View.INVISIBLE); 68 assertThat(mKeyguardMessageArea.getText()).isEqualTo(""); 69 } 70 } 71