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; |
| 25 | import android.support.test.filters.SmallTest; |
| 26 | import android.testing.AndroidTestingRunner; |
| 27 | import android.testing.TestableLooper; |
| 28 | |
| 29 | import com.android.systemui.SysuiTestCase; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 30 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 31 | import com.android.systemui.statusbar.NotificationListener; |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 32 | import com.android.systemui.statusbar.NotificationMediaManager; |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 33 | |
| 34 | import org.junit.Before; |
| 35 | import org.junit.Test; |
| 36 | import org.junit.runner.RunWith; |
| 37 | import org.mockito.Mock; |
| 38 | import org.mockito.MockitoAnnotations; |
| 39 | |
| 40 | @SmallTest |
| 41 | @RunWith(AndroidTestingRunner.class) |
| 42 | @TestableLooper.RunWithLooper |
| 43 | public class NotificationIconAreaControllerTest extends SysuiTestCase { |
| 44 | |
| 45 | @Mock |
| 46 | private NotificationListener mListener; |
| 47 | @Mock |
| 48 | StatusBar mStatusBar; |
| 49 | @Mock |
| 50 | StatusBarStateController mStatusBarStateController; |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 51 | @Mock |
| 52 | private NotificationMediaManager mMediaManager; |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 53 | private NotificationIconAreaController mController; |
| 54 | |
| 55 | @Before |
| 56 | public void setup() { |
| 57 | MockitoAnnotations.initMocks(this); |
| 58 | |
| 59 | mController = new NotificationIconAreaController(mContext, mStatusBar, |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 60 | mStatusBarStateController, mListener, mMediaManager); |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 61 | } |
| 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 | } |