Julia Reynolds | a8a6c17 | 2020-01-28 08:26:46 -0500 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package com.android.systemui.statusbar.phone; |
| 17 | |
| 18 | import static org.junit.Assert.assertFalse; |
| 19 | import static org.junit.Assert.assertTrue; |
| 20 | import static org.mockito.ArgumentMatchers.anyInt; |
| 21 | import static org.mockito.Mockito.mock; |
| 22 | import static org.mockito.Mockito.when; |
| 23 | |
| 24 | import android.testing.AndroidTestingRunner; |
| 25 | import android.testing.TestableLooper; |
| 26 | |
| 27 | import androidx.test.filters.SmallTest; |
| 28 | |
| 29 | import com.android.systemui.SysuiTestCase; |
| 30 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
| 31 | import com.android.systemui.statusbar.NotificationListener; |
| 32 | import com.android.systemui.statusbar.NotificationMediaManager; |
| 33 | import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; |
| 34 | |
| 35 | import org.junit.Before; |
| 36 | import org.junit.Test; |
| 37 | import org.junit.runner.RunWith; |
| 38 | import org.mockito.Mock; |
| 39 | import org.mockito.MockitoAnnotations; |
| 40 | |
| 41 | @SmallTest |
| 42 | @RunWith(AndroidTestingRunner.class) |
| 43 | @TestableLooper.RunWithLooper |
| 44 | public 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 | } |