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