blob: be43e19cfc70dfdea7a79adfc4cf8374966aaf44 [file] [log] [blame]
Julia Reynoldsa8a6c172020-01-28 08:26:46 -05001/*
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 */
16package com.android.systemui.statusbar.phone;
17
18import static org.junit.Assert.assertFalse;
19import static org.junit.Assert.assertTrue;
20import static org.mockito.ArgumentMatchers.anyInt;
21import static org.mockito.Mockito.mock;
22import static org.mockito.Mockito.when;
23
24import android.testing.AndroidTestingRunner;
25import android.testing.TestableLooper;
26
27import androidx.test.filters.SmallTest;
28
29import com.android.systemui.SysuiTestCase;
30import com.android.systemui.plugins.statusbar.StatusBarStateController;
31import com.android.systemui.statusbar.NotificationListener;
32import com.android.systemui.statusbar.NotificationMediaManager;
33import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
34
35import org.junit.Before;
36import org.junit.Test;
37import org.junit.runner.RunWith;
38import org.mockito.Mock;
39import org.mockito.MockitoAnnotations;
40
41@SmallTest
42@RunWith(AndroidTestingRunner.class)
43@TestableLooper.RunWithLooper
44public class NotificationIconAreaControllerTest extends SysuiTestCase {
45
46 @Mock
47 private NotificationListener mListener;
48 @Mock
49 StatusBar mStatusBar;
50 @Mock
51 StatusBarStateController mStatusBarStateController;
52 @Mock
53 NotificationWakeUpCoordinator mWakeUpCoordinator;
54 @Mock
55 KeyguardBypassController mKeyguardBypassController;
56 @Mock
57 NotificationMediaManager mNotificationMediaManager;
58 @Mock
59 DozeParameters mDozeParameters;
60 @Mock
61 NotificationShadeWindowView mNotificationShadeWindowView;
62 private NotificationIconAreaController mController;
63
64 @Before
65 public void setup() {
66 MockitoAnnotations.initMocks(this);
67
68 when(mStatusBar.getNotificationShadeWindowView()).thenReturn(mNotificationShadeWindowView);
69 when(mNotificationShadeWindowView.findViewById(anyInt())).thenReturn(
70 mock(NotificationIconContainer.class));
71
72 mController = new NotificationIconAreaController(mContext, mStatusBar,
73 mStatusBarStateController, mWakeUpCoordinator, mKeyguardBypassController,
74 mNotificationMediaManager, mListener, mDozeParameters);
75 }
76
77 @Test
78 public void testNotificationIcons_settingHideIcons() {
79 mController.mSettingsListener.onStatusBarIconsBehaviorChanged(true);
80
81 assertFalse(mController.shouldShouldLowPriorityIcons());
82 }
83
84 @Test
85 public void testNotificationIcons_settingShowIcons() {
86 mController.mSettingsListener.onStatusBarIconsBehaviorChanged(false);
87
88 assertTrue(mController.shouldShouldLowPriorityIcons());
89 }
90}