blob: 120d0b093e0e927e6a61a2f2bd5e0378f91bc676 [file] [log] [blame]
Julia Reynolds12ad7ca2019-01-28 09:29:16 -05001/*
2 * Copyright (C) 2019 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.systemui.statusbar.phone;
18
19import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;
20
21import static org.junit.Assert.assertFalse;
22import static org.junit.Assert.assertTrue;
Julia Reynolds12ad7ca2019-01-28 09:29:16 -050023
Julia Reynolds12ad7ca2019-01-28 09:29:16 -050024import android.provider.Settings;
25import android.support.test.filters.SmallTest;
26import android.testing.AndroidTestingRunner;
27import android.testing.TestableLooper;
28
29import com.android.systemui.SysuiTestCase;
Beverly8fdb5332019-02-04 14:29:49 -050030import com.android.systemui.plugins.statusbar.StatusBarStateController;
Julia Reynolds12ad7ca2019-01-28 09:29:16 -050031import com.android.systemui.statusbar.NotificationListener;
Lucas Dupin20403372019-02-14 19:59:18 -080032import com.android.systemui.statusbar.NotificationMediaManager;
Julia Reynolds12ad7ca2019-01-28 09:29:16 -050033
34import org.junit.Before;
35import org.junit.Test;
36import org.junit.runner.RunWith;
37import org.mockito.Mock;
38import org.mockito.MockitoAnnotations;
39
40@SmallTest
41@RunWith(AndroidTestingRunner.class)
42@TestableLooper.RunWithLooper
43public class NotificationIconAreaControllerTest extends SysuiTestCase {
44
45 @Mock
46 private NotificationListener mListener;
47 @Mock
48 StatusBar mStatusBar;
49 @Mock
50 StatusBarStateController mStatusBarStateController;
Lucas Dupin20403372019-02-14 19:59:18 -080051 @Mock
52 private NotificationMediaManager mMediaManager;
Julia Reynolds12ad7ca2019-01-28 09:29:16 -050053 private NotificationIconAreaController mController;
54
55 @Before
56 public void setup() {
57 MockitoAnnotations.initMocks(this);
58
59 mController = new NotificationIconAreaController(mContext, mStatusBar,
Lucas Dupin20403372019-02-14 19:59:18 -080060 mStatusBarStateController, mListener, mMediaManager);
Julia Reynolds12ad7ca2019-01-28 09:29:16 -050061 }
62
63 @Test
64 public void testNotificationIcons_featureOff() {
65 Settings.Secure.putInt(
66 mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 0);
67 assertTrue(mController.shouldShouldLowPriorityIcons());
68 }
69
70 @Test
71 public void testNotificationIcons_featureOn_settingHideIcons() {
72 Settings.Secure.putInt(
73 mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
74 mController.mSettingsListener.onStatusBarIconsBehaviorChanged(true);
75
76 assertFalse(mController.shouldShouldLowPriorityIcons());
77 }
78
79 @Test
80 public void testNotificationIcons_featureOn_settingShowIcons() {
81 Settings.Secure.putInt(
82 mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
83 mController.mSettingsListener.onStatusBarIconsBehaviorChanged(false);
84
85 assertTrue(mController.shouldShouldLowPriorityIcons());
86 }
87}