1/* 2 * Copyright (C) 2016 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 19import static junit.framework.Assert.assertEquals; 20 21import static org.mockito.Mockito.mock; 22 23import android.os.Handler; 24import android.os.Looper; 25import android.support.test.runner.AndroidJUnit4; 26import android.test.suitebuilder.annotation.SmallTest; 27 28import com.android.systemui.SysuiTestCase; 29 30import org.junit.Before; 31import org.junit.Test; 32import org.junit.runner.RunWith; 33 34@SmallTest 35@RunWith(AndroidJUnit4.class) 36public class KeyguardMessageAreaTest extends SysuiTestCase { 37 private Handler mHandler = new Handler(Looper.getMainLooper()); 38 private KeyguardMessageArea mMessageArea; 39 40 @Before 41 public void setUp() throws Exception { 42 KeyguardUpdateMonitor monitor = mock(KeyguardUpdateMonitor.class); 43 mHandler.post(()-> mMessageArea = new KeyguardMessageArea(mContext, null, monitor)); 44 waitForIdleSync(); 45 } 46 47 @Test 48 public void clearFollowedByMessage_keepsMessage() { 49 mHandler.post(()-> { 50 mMessageArea.setMessage(""); 51 mMessageArea.setMessage("test"); 52 }); 53 54 waitForIdleSync(); 55 56 CharSequence[] messageText = new CharSequence[1]; 57 mHandler.post(()-> { 58 messageText[0] = mMessageArea.getText(); 59 }); 60 61 waitForIdleSync(); 62 63 assertEquals("test", messageText[0]); 64 } 65 66} 67