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 17 package com.android.keyguard; 18 19 import static junit.framework.Assert.assertEquals; 20 21 import static org.mockito.Mockito.mock; 22 23 import android.os.Handler; 24 import android.os.Looper; 25 import android.support.test.runner.AndroidJUnit4; 26 import android.test.suitebuilder.annotation.SmallTest; 27 28 import com.android.systemui.SysuiTestCase; 29 30 import org.junit.Before; 31 import org.junit.Test; 32 import org.junit.runner.RunWith; 33 34 @SmallTest 35 @RunWith(AndroidJUnit4.class) 36 public class KeyguardMessageAreaTest extends SysuiTestCase { 37 private Handler mHandler = new Handler(Looper.getMainLooper()); 38 private KeyguardMessageArea mMessageArea; 39 40 @Before setUp()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 clearFollowedByMessage_keepsMessage()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