Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
| 19 | import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL; |
| 20 | |
| 21 | import static org.junit.Assert.assertFalse; |
| 22 | import static org.junit.Assert.assertTrue; |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 23 | |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 24 | import android.provider.Settings; |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 25 | import android.testing.AndroidTestingRunner; |
| 26 | import android.testing.TestableLooper; |
| 27 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 28 | import androidx.test.filters.SmallTest; |
| 29 | |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 30 | import com.android.systemui.SysuiTestCase; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 31 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 32 | import com.android.systemui.statusbar.NotificationListener; |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 33 | import com.android.systemui.statusbar.NotificationMediaManager; |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 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; |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 52 | @Mock |
| 53 | private NotificationMediaManager mMediaManager; |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 54 | private NotificationIconAreaController mController; |
| 55 | |
| 56 | @Before |
| 57 | public void setup() { |
| 58 | MockitoAnnotations.initMocks(this); |
| 59 | |
| 60 | mController = new NotificationIconAreaController(mContext, mStatusBar, |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 61 | mStatusBarStateController, mListener, mMediaManager); |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | @Test |
| 65 | public void testNotificationIcons_featureOff() { |
| 66 | Settings.Secure.putInt( |
| 67 | mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 0); |
| 68 | assertTrue(mController.shouldShouldLowPriorityIcons()); |
| 69 | } |
| 70 | |
| 71 | @Test |
| 72 | public void testNotificationIcons_featureOn_settingHideIcons() { |
| 73 | Settings.Secure.putInt( |
| 74 | mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1); |
| 75 | mController.mSettingsListener.onStatusBarIconsBehaviorChanged(true); |
| 76 | |
| 77 | assertFalse(mController.shouldShouldLowPriorityIcons()); |
| 78 | } |
| 79 | |
| 80 | @Test |
| 81 | public void testNotificationIcons_featureOn_settingShowIcons() { |
| 82 | Settings.Secure.putInt( |
| 83 | mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1); |
| 84 | mController.mSettingsListener.onStatusBarIconsBehaviorChanged(false); |
| 85 | |
| 86 | assertTrue(mController.shouldShouldLowPriorityIcons()); |
| 87 | } |
| 88 | } |