Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2018 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 android.app.cts;
     18 
     19 import android.app.NotificationManager;
     20 import android.os.Parcel;
     21 import android.service.notification.ZenPolicy;
     22 
     23 import junit.framework.Assert;
     24 
     25 import org.junit.Test;
     26 
     27 public class ZenPolicyTest extends Assert {
     28 
     29     @Test
     30     public void testWriteToParcel() {
     31         ZenPolicy.Builder builder = new ZenPolicy.Builder()
     32                 .allowAlarms(true)
     33                 .allowCalls(ZenPolicy.PEOPLE_TYPE_NONE)
     34                 .allowMessages(ZenPolicy.PEOPLE_TYPE_STARRED)
     35                 .showInNotificationList(false);
     36         ZenPolicy policy = builder.build();
     37 
     38         Parcel parcel = Parcel.obtain();
     39         policy.writeToParcel(parcel, 0);
     40         parcel.setDataPosition(0);
     41 
     42         ZenPolicy policyFromParcel = ZenPolicy.CREATOR.createFromParcel(parcel);
     43         assertEquals(policy, policyFromParcel);
     44     }
     45 
     46     @Test
     47     public void testAlarms() {
     48         ZenPolicy.Builder builder = new ZenPolicy.Builder();
     49         ZenPolicy policy = builder.allowAlarms(true).build();
     50         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryAlarms());
     51         assertAllPriorityCategoriesUnsetExcept(policy,
     52                 NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS);
     53         assertAllVisualEffectsUnset(policy);
     54 
     55         policy = builder.allowAlarms(false).build();
     56         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryAlarms());
     57         assertAllPriorityCategoriesUnsetExcept(policy,
     58                 NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS);
     59         assertAllVisualEffectsUnset(policy);
     60     }
     61 
     62     @Test
     63     public void testMedia() {
     64         ZenPolicy.Builder builder = new ZenPolicy.Builder();
     65         ZenPolicy policy = builder.allowMedia(true).build();
     66         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryMedia());
     67         assertAllPriorityCategoriesUnsetExcept(policy,
     68                 NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA);
     69         assertAllVisualEffectsUnsetExcept(policy, -1);
     70 
     71         policy = builder.allowMedia(false).build();
     72         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryMedia());
     73         assertAllPriorityCategoriesUnsetExcept(policy,
     74                 NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA);
     75         assertAllVisualEffectsUnset(policy);
     76     }
     77 
     78     @Test
     79     public void testSystem() {
     80         ZenPolicy.Builder builder = new ZenPolicy.Builder();
     81         ZenPolicy policy = builder.allowSystem(true).build();
     82         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategorySystem());
     83         assertAllPriorityCategoriesUnsetExcept(policy,
     84                 NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM);
     85         assertAllVisualEffectsUnset(policy);
     86 
     87         policy = builder.allowSystem(false).build();
     88         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategorySystem());
     89         assertAllPriorityCategoriesUnsetExcept(policy,
     90                 NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM);
     91         assertAllVisualEffectsUnset(policy);
     92     }
     93 
     94     @Test
     95     public void testReminders() {
     96         ZenPolicy.Builder builder = new ZenPolicy.Builder();
     97         ZenPolicy policy = builder.allowReminders(true).build();
     98         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryReminders());
     99         assertAllPriorityCategoriesUnsetExcept(policy,
    100                 NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS);
    101         assertAllVisualEffectsUnset(policy);
    102 
    103         policy = builder.allowReminders(false).build();
    104         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryReminders());
    105         assertAllPriorityCategoriesUnsetExcept(policy,
    106                 NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS);
    107         assertAllVisualEffectsUnset(policy);
    108     }
    109 
    110     @Test
    111     public void testEvents() {
    112         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    113         ZenPolicy policy = builder.allowEvents(true).build();
    114         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryEvents());
    115         assertAllPriorityCategoriesUnsetExcept(policy,
    116                 NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS);
    117         assertAllVisualEffectsUnset(policy);
    118 
    119         builder.allowEvents(false);
    120         policy = builder.build();
    121         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryEvents());
    122         assertAllPriorityCategoriesUnsetExcept(policy,
    123                 NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS);
    124         assertAllVisualEffectsUnset(policy);
    125     }
    126 
    127     @Test
    128     public void testRepeatCallers() {
    129         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    130         ZenPolicy policy = builder.allowRepeatCallers(true).build();
    131         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryRepeatCallers());
    132         assertAllPriorityCategoriesUnsetExcept(policy,
    133                 NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS);
    134         assertAllVisualEffectsUnset(policy);
    135 
    136         policy = builder.allowRepeatCallers(false).build();
    137         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryRepeatCallers());
    138         assertAllPriorityCategoriesUnsetExcept(policy,
    139                 NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS);
    140         assertAllVisualEffectsUnset(policy);
    141     }
    142 
    143     @Test
    144     public void testMessages() {
    145         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    146         ZenPolicy policy = builder.allowMessages(ZenPolicy.PEOPLE_TYPE_NONE).build();
    147         assertEquals(ZenPolicy.PEOPLE_TYPE_NONE, policy.getPriorityMessageSenders());
    148         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryMessages());
    149         assertAllPriorityCategoriesUnsetExcept(policy,
    150                 NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES);
    151         assertAllVisualEffectsUnset(policy);
    152 
    153         policy = builder.allowMessages(ZenPolicy.PEOPLE_TYPE_ANYONE).build();
    154         assertEquals(ZenPolicy.PEOPLE_TYPE_ANYONE, policy.getPriorityMessageSenders());
    155         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryMessages());
    156         assertAllPriorityCategoriesUnsetExcept(policy,
    157                 NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES);
    158         assertAllVisualEffectsUnset(policy);
    159 
    160         policy = builder.allowMessages(ZenPolicy.PEOPLE_TYPE_CONTACTS).build();
    161         assertEquals(ZenPolicy.PEOPLE_TYPE_CONTACTS, policy.getPriorityMessageSenders());
    162         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryMessages());
    163         assertAllPriorityCategoriesUnsetExcept(policy,
    164                 NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES);
    165         assertAllVisualEffectsUnset(policy);
    166 
    167         policy = builder.allowMessages(ZenPolicy.PEOPLE_TYPE_STARRED).build();
    168         assertEquals(ZenPolicy.PEOPLE_TYPE_STARRED, policy.getPriorityMessageSenders());
    169         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryMessages());
    170         assertAllPriorityCategoriesUnsetExcept(policy,
    171                 NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES);
    172         assertAllVisualEffectsUnset(policy);
    173     }
    174 
    175     @Test
    176     public void testCalls() {
    177         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    178         ZenPolicy policy = builder.allowCalls(ZenPolicy.PEOPLE_TYPE_NONE).build();
    179         assertEquals(ZenPolicy.PEOPLE_TYPE_NONE, policy.getPriorityCallSenders());
    180         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryCalls());
    181         assertAllPriorityCategoriesUnsetExcept(policy,
    182                 NotificationManager.Policy.PRIORITY_CATEGORY_CALLS);
    183         assertAllVisualEffectsUnset(policy);
    184 
    185         policy = builder.allowCalls(ZenPolicy.PEOPLE_TYPE_ANYONE).build();
    186         assertEquals(ZenPolicy.PEOPLE_TYPE_ANYONE, policy.getPriorityCallSenders());
    187         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryCalls());
    188         assertAllPriorityCategoriesUnsetExcept(policy,
    189                 NotificationManager.Policy.PRIORITY_CATEGORY_CALLS);
    190         assertAllVisualEffectsUnset(policy);
    191 
    192         policy = builder.allowCalls(ZenPolicy.PEOPLE_TYPE_CONTACTS).build();
    193         assertEquals(ZenPolicy.PEOPLE_TYPE_CONTACTS, policy.getPriorityCallSenders());
    194         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryCalls());
    195         assertAllPriorityCategoriesUnsetExcept(policy,
    196                 NotificationManager.Policy.PRIORITY_CATEGORY_CALLS);
    197         assertAllVisualEffectsUnset(policy);
    198 
    199         policy = builder.allowCalls(ZenPolicy.PEOPLE_TYPE_STARRED).build();
    200         assertEquals(ZenPolicy.PEOPLE_TYPE_STARRED, policy.getPriorityCallSenders());
    201         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryCalls());
    202         assertAllPriorityCategoriesUnsetExcept(policy,
    203                 NotificationManager.Policy.PRIORITY_CATEGORY_CALLS);
    204         assertAllVisualEffectsUnset(policy);
    205     }
    206 
    207     @Test
    208     public void testFullScreenIntent() {
    209         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    210         ZenPolicy policy = builder.showFullScreenIntent(true).build();
    211         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectFullScreenIntent());
    212         assertAllPriorityCategoriesUnset(policy);
    213         assertAllVisualEffectsUnsetExcept(policy,
    214                 NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT);
    215 
    216         policy = builder.showFullScreenIntent(false).build();
    217         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectFullScreenIntent());
    218         assertAllPriorityCategoriesUnset(policy);
    219         assertAllVisualEffectsUnsetExcept(policy,
    220                 NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT);
    221     }
    222 
    223     @Test
    224     public void testLights() {
    225         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    226         ZenPolicy policy = builder.showLights(true).build();
    227         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectLights());
    228         assertAllPriorityCategoriesUnset(policy);
    229         assertAllVisualEffectsUnsetExcept(policy,
    230                 NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS);
    231 
    232         policy = builder.showLights(false).build();
    233         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectLights());
    234         assertAllPriorityCategoriesUnset(policy);
    235         assertAllVisualEffectsUnsetExcept(policy,
    236                 NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS);
    237     }
    238 
    239     @Test
    240     public void testPeek() {
    241         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    242         ZenPolicy policy = builder.showPeeking(true).build();
    243         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectPeek());
    244         assertAllPriorityCategoriesUnset(policy);
    245         assertAllVisualEffectsUnsetExcept(policy,
    246                 NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK);
    247 
    248         policy = builder.showPeeking(false).build();
    249         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectPeek());
    250         assertAllPriorityCategoriesUnset(policy);
    251         assertAllVisualEffectsUnsetExcept(policy,
    252                 NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK);
    253     }
    254 
    255     @Test
    256     public void testStatusBar() {
    257         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    258         ZenPolicy policy = builder.showStatusBarIcons(true).build();
    259         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectStatusBar());
    260         assertAllPriorityCategoriesUnset(policy);
    261         assertAllVisualEffectsUnsetExcept(policy,
    262                 NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR);
    263 
    264         policy = builder.showStatusBarIcons(false).build();
    265         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectStatusBar());
    266         assertAllPriorityCategoriesUnset(policy);
    267         assertAllVisualEffectsUnsetExcept(policy,
    268                 NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR);
    269     }
    270 
    271     @Test
    272     public void testBadge() {
    273         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    274         ZenPolicy policy = builder.showBadges(true).build();
    275         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectBadge());
    276         assertAllPriorityCategoriesUnset(policy);
    277         assertAllVisualEffectsUnsetExcept(policy,
    278                 NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE);
    279 
    280         policy = builder.showBadges(false).build();
    281         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectBadge());
    282         assertAllPriorityCategoriesUnset(policy);
    283         assertAllVisualEffectsUnsetExcept(policy,
    284                 NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE);
    285     }
    286 
    287     @Test
    288     public void testAmbient() {
    289         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    290         ZenPolicy policy = builder.showInAmbientDisplay(true).build();
    291         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectAmbient());
    292         assertAllPriorityCategoriesUnset(policy);
    293         assertAllVisualEffectsUnsetExcept(policy,
    294                 NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT);
    295 
    296         policy = builder.showInAmbientDisplay(false).build();
    297         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectAmbient());
    298         assertAllPriorityCategoriesUnset(policy);
    299         assertAllVisualEffectsUnsetExcept(policy,
    300                 NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT);
    301     }
    302 
    303     @Test
    304     public void testNotificationList() {
    305         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    306         ZenPolicy policy = builder.showInNotificationList(true).build();
    307         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectNotificationList());
    308         assertAllPriorityCategoriesUnset(policy);
    309         assertAllVisualEffectsUnsetExcept(policy,
    310                 NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST);
    311 
    312         policy = builder.showInNotificationList(false).build();
    313         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectNotificationList());
    314         assertAllPriorityCategoriesUnset(policy);
    315         assertAllVisualEffectsUnsetExcept(policy,
    316                 NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST);
    317     }
    318 
    319     @Test
    320     public void testDisallowAllSounds() {
    321         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    322         ZenPolicy policy = builder.disallowAllSounds().build();
    323 
    324         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryAlarms());
    325         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryMedia());
    326         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategorySystem());
    327         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryReminders());
    328         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryEvents());
    329         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryMessages());
    330         assertEquals(ZenPolicy.PEOPLE_TYPE_NONE, policy.getPriorityMessageSenders());
    331         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryCalls());
    332         assertEquals(ZenPolicy.PEOPLE_TYPE_NONE, policy.getPriorityCallSenders());
    333         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getPriorityCategoryRepeatCallers());
    334         assertAllVisualEffectsUnset(policy);
    335     }
    336 
    337     @Test
    338     public void testAllowAllSounds() {
    339         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    340         ZenPolicy policy = builder.allowAllSounds().build();
    341 
    342         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryAlarms());
    343         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryMedia());
    344         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategorySystem());
    345         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryReminders());
    346         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryEvents());
    347         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryMessages());
    348         assertEquals(ZenPolicy.PEOPLE_TYPE_ANYONE, policy.getPriorityMessageSenders());
    349         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryCalls());
    350         assertEquals(ZenPolicy.PEOPLE_TYPE_ANYONE, policy.getPriorityCallSenders());
    351         assertEquals(ZenPolicy.STATE_ALLOW, policy.getPriorityCategoryRepeatCallers());
    352         assertAllVisualEffectsUnset(policy);
    353     }
    354 
    355     @Test
    356     public void testAllowAllVisualEffects() {
    357         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    358         ZenPolicy policy = builder.showAllVisualEffects().build();
    359 
    360         assertAllPriorityCategoriesUnset(policy);
    361         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectFullScreenIntent());
    362         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectLights());
    363         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectPeek());
    364         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectStatusBar());
    365         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectBadge());
    366         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectAmbient());
    367         assertEquals(ZenPolicy.STATE_ALLOW, policy.getVisualEffectNotificationList());
    368     }
    369 
    370     @Test
    371     public void testDisallowAllVisualEffects() {
    372         ZenPolicy.Builder builder = new ZenPolicy.Builder();
    373         ZenPolicy policy = builder.hideAllVisualEffects().build();
    374 
    375         assertAllPriorityCategoriesUnset(policy);
    376         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectFullScreenIntent());
    377         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectLights());
    378         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectPeek());
    379         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectStatusBar());
    380         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectBadge());
    381         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectAmbient());
    382         assertEquals(ZenPolicy.STATE_DISALLOW, policy.getVisualEffectNotificationList());
    383     }
    384 
    385     private void assertAllPriorityCategoriesUnsetExcept(ZenPolicy policy, int except) {
    386         if (except != NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS) {
    387             assertEquals(ZenPolicy.STATE_UNSET, policy.getPriorityCategoryReminders());
    388         }
    389 
    390         if (except != NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS) {
    391             assertEquals(ZenPolicy.STATE_UNSET, policy.getPriorityCategoryEvents());
    392         }
    393 
    394         if (except != NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES) {
    395             assertEquals(ZenPolicy.STATE_UNSET, policy.getPriorityCategoryMessages());
    396         }
    397 
    398         if (except != NotificationManager.Policy.PRIORITY_CATEGORY_CALLS) {
    399             assertEquals(ZenPolicy.STATE_UNSET, policy.getPriorityCategoryCalls());
    400         }
    401 
    402         if (except != NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS) {
    403             assertEquals(ZenPolicy.STATE_UNSET, policy.getPriorityCategoryRepeatCallers());
    404         }
    405 
    406         if (except != NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS) {
    407             assertEquals(ZenPolicy.STATE_UNSET, policy.getPriorityCategoryAlarms());
    408         }
    409 
    410         if (except != NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA) {
    411             assertEquals(ZenPolicy.STATE_UNSET, policy.getPriorityCategoryMedia());
    412         }
    413 
    414         if (except != NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM) {
    415             assertEquals(ZenPolicy.STATE_UNSET, policy.getPriorityCategorySystem());
    416         }
    417     }
    418 
    419     private void assertAllVisualEffectsUnsetExcept(ZenPolicy policy, int except) {
    420         if (except != NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT) {
    421             assertEquals(ZenPolicy.STATE_UNSET, policy.getVisualEffectFullScreenIntent());
    422         }
    423 
    424         if (except != NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS) {
    425             assertEquals(ZenPolicy.STATE_UNSET, policy.getVisualEffectLights());
    426         }
    427 
    428         if (except != NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK) {
    429             assertEquals(ZenPolicy.STATE_UNSET, policy.getVisualEffectPeek());
    430         }
    431 
    432         if (except != NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR) {
    433             assertEquals(ZenPolicy.STATE_UNSET, policy.getVisualEffectStatusBar());
    434         }
    435 
    436         if (except != NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE) {
    437             assertEquals(ZenPolicy.STATE_UNSET, policy.getVisualEffectBadge());
    438         }
    439 
    440         if (except != NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT) {
    441             assertEquals(ZenPolicy.STATE_UNSET, policy.getVisualEffectAmbient());
    442         }
    443 
    444         if (except != NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST) {
    445             assertEquals(ZenPolicy.STATE_UNSET, policy.getVisualEffectNotificationList());
    446         }
    447     }
    448 
    449     private void assertAllPriorityCategoriesUnset(ZenPolicy policy) {
    450         assertAllPriorityCategoriesUnsetExcept(policy, -1);
    451     }
    452 
    453     private void assertAllVisualEffectsUnset(ZenPolicy policy) {
    454         assertAllVisualEffectsUnsetExcept(policy, -1);
    455     }
    456 }
    457