• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.ArgumentMatchers.eq;
22 import static org.mockito.Mockito.verify;
23 
24 import android.test.suitebuilder.annotation.SmallTest;
25 import android.testing.AndroidTestingRunner;
26 import android.testing.TestableLooper.RunWithLooper;
27 
28 import com.android.systemui.SysuiTestCase;
29 import com.android.systemui.statusbar.policy.ConfigurationController;
30 
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.mockito.Mock;
35 import org.mockito.MockitoAnnotations;
36 
37 @SmallTest
38 @RunWith(AndroidTestingRunner.class)
39 @RunWithLooper
40 public class KeyguardMessageAreaTest extends SysuiTestCase {
41     @Mock
42     private ConfigurationController mConfigurationController;
43     @Mock
44     private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
45     private KeyguardMessageArea mMessageArea;
46 
47     @Before
setUp()48     public void setUp() throws Exception {
49         MockitoAnnotations.initMocks(this);
50         mMessageArea = new KeyguardMessageArea(mContext, null, mKeyguardUpdateMonitor,
51                 mConfigurationController);
52         waitForIdleSync();
53     }
54 
55     @Test
onAttachedToWindow_registersConfigurationCallback()56     public void onAttachedToWindow_registersConfigurationCallback() {
57         mMessageArea.onAttachedToWindow();
58         verify(mConfigurationController).addCallback(eq(mMessageArea));
59 
60         mMessageArea.onDetachedFromWindow();
61         verify(mConfigurationController).removeCallback(eq(mMessageArea));
62     }
63 
64     @Test
clearFollowedByMessage_keepsMessage()65     public void clearFollowedByMessage_keepsMessage() {
66         mMessageArea.setMessage("");
67         mMessageArea.setMessage("test");
68 
69         CharSequence[] messageText = new CharSequence[1];
70         messageText[0] = mMessageArea.getText();
71 
72         assertEquals("test", messageText[0]);
73     }
74 
75 }
76