• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.android.settings.notification;
18 
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertTrue;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.when;
23 
24 import android.app.NotificationManager;
25 import android.content.Context;
26 
27 import com.android.settings.testutils.SettingsRobolectricTestRunner;
28 import com.android.settingslib.core.lifecycle.Lifecycle;
29 
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.Mock;
34 import org.mockito.MockitoAnnotations;
35 import org.robolectric.RuntimeEnvironment;
36 import org.robolectric.shadows.ShadowApplication;
37 import org.robolectric.util.ReflectionHelpers;
38 
39 @RunWith(SettingsRobolectricTestRunner.class)
40 public final class ZenModeBlockedEffectsPreferenceControllerTest {
41 
42     private ZenModeBlockedEffectsPreferenceController mController;
43     @Mock
44     private NotificationManager mNotificationManager;
45     @Mock
46     private NotificationManager.Policy mPolicy;
47 
48     private Context mContext;
49     @Mock
50     private ZenModeBackend mBackend;
51 
52     @Before
setup()53     public void setup() {
54         MockitoAnnotations.initMocks(this);
55         ShadowApplication shadowApplication = ShadowApplication.getInstance();
56         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
57 
58         mContext = RuntimeEnvironment.application;
59         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
60 
61         mController = new ZenModeBlockedEffectsPreferenceController(
62                 mContext, mock(Lifecycle.class));
63         ReflectionHelpers.setField(mController, "mBackend", mBackend);
64     }
65 
66     @Test
testIsAvailable()67     public void testIsAvailable() {
68         assertTrue(mController.isAvailable());
69     }
70 
71     @Test
testHasSummary()72     public void testHasSummary() {
73         assertNotNull(mController.getSummary());
74     }
75 }
76