blob: ca7a5dbdc36d4131cacfd6572fffc63e2ade917b [file] [log] [blame]
Evan Laird367b6142019-08-30 14:40:34 -04001/*
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.notification
18
19import android.provider.DeviceConfig
20import android.provider.Settings
21import android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL
22import android.testing.AndroidTestingRunner
23
24import androidx.test.filters.SmallTest
25
26import com.android.internal.config.sysui.SystemUiDeviceConfigFlags.NOTIFICATIONS_USE_PEOPLE_FILTERING
27import com.android.systemui.SysuiTestCase
28import com.android.systemui.util.DeviceConfigProxyFake
29
Robert Snoebergerb6464ea2020-03-20 11:56:22 -040030import org.junit.After
Evan Laird367b6142019-08-30 14:40:34 -040031import org.junit.Assert.assertFalse
32import org.junit.Assert.assertTrue
33import org.junit.Before
34import org.junit.Test
35import org.junit.runner.RunWith
36
37@RunWith(AndroidTestingRunner::class)
38@SmallTest
39class NotificationSectionsFeatureManagerTest : SysuiTestCase() {
40 var manager: NotificationSectionsFeatureManager? = null
41 val proxyFake = DeviceConfigProxyFake()
Robert Snoebergerb6464ea2020-03-20 11:56:22 -040042 var originalQsMediaPlayer: Int = 0
Evan Laird367b6142019-08-30 14:40:34 -040043
44 @Before
45 public fun setup() {
46 Settings.Secure.putInt(mContext.getContentResolver(),
47 NOTIFICATION_NEW_INTERRUPTION_MODEL, 1)
48 manager = NotificationSectionsFeatureManager(proxyFake, mContext)
49 manager!!.clearCache()
Robert Snoebergerb6464ea2020-03-20 11:56:22 -040050 originalQsMediaPlayer = Settings.System.getInt(context.getContentResolver(),
51 "qs_media_player", 1)
Selim Cinek6eec7f22020-05-08 22:18:07 -070052 Settings.Global.putInt(context.getContentResolver(), "qs_media_player", 0)
Robert Snoebergerb6464ea2020-03-20 11:56:22 -040053 }
54
55 @After
56 public fun teardown() {
Selim Cinek6eec7f22020-05-08 22:18:07 -070057 Settings.Global.putInt(context.getContentResolver(), "qs_media_player",
Robert Snoebergerb6464ea2020-03-20 11:56:22 -040058 originalQsMediaPlayer)
Evan Laird367b6142019-08-30 14:40:34 -040059 }
60
61 @Test
62 public fun testPeopleFilteringOff_newInterruptionModelOn() {
63 proxyFake.setProperty(
64 DeviceConfig.NAMESPACE_SYSTEMUI, NOTIFICATIONS_USE_PEOPLE_FILTERING, "false", false)
65
66 assertFalse("People filtering should be disabled", manager!!.isFilteringEnabled())
67 assertTrue("Expecting 2 buckets when people filtering is disabled",
68 manager!!.getNumberOfBuckets() == 2)
69 }
70
71 @Test
72 public fun testPeopleFilteringOn_newInterruptionModelOn() {
73 proxyFake.setProperty(
74 DeviceConfig.NAMESPACE_SYSTEMUI, NOTIFICATIONS_USE_PEOPLE_FILTERING, "true", false)
75
76 assertTrue("People filtering should be enabled", manager!!.isFilteringEnabled())
Steve Elliottb0940382020-02-20 14:24:02 -050077 assertTrue("Expecting 4 buckets when people filtering is enabled",
78 manager!!.getNumberOfBuckets() == 4)
Evan Laird367b6142019-08-30 14:40:34 -040079 }
80}