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