• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 com.google.common.truth.Truth.assertThat;
20 
21 import android.platform.test.flag.junit.SetFlagsRule;
22 
23 import com.android.server.notification.Flags;
24 import com.android.settings.core.BasePreferenceController;
25 
26 import org.junit.Before;
27 import org.junit.Rule;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.mockito.MockitoAnnotations;
31 import org.robolectric.RobolectricTestRunner;
32 import org.robolectric.RuntimeEnvironment;
33 
34 // TODO(b/367455695): remove test when feature flag is cleaned
35 @RunWith(RobolectricTestRunner.class)
36 public class LockScreenNotificationsPreferencePageControllerTest {
37 
38     @Rule
39     public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
40 
41     private static final String PREFERENCE_KEY = "lock_screen_notifications_page";
42 
43     private LockScreenNotificationsPreferencePageController mController;
44 
45     @Before
setUp()46     public void setUp() {
47         MockitoAnnotations.initMocks(this);
48         mController = new LockScreenNotificationsPreferencePageController(
49                 RuntimeEnvironment.application,
50                 PREFERENCE_KEY);
51     }
52 
53     @Test
isAvailable_flagEnabled_shouldReturnTrue()54     public void isAvailable_flagEnabled_shouldReturnTrue() {
55         mSetFlagsRule.enableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS);
56         assertThat(mController.isAvailable()).isTrue();
57         assertThat(mController.getAvailabilityStatus()).isEqualTo(
58                 BasePreferenceController.AVAILABLE);
59     }
60 
61     @Test
isAvailable_flagDisabled_shouldReturnFalse()62     public void isAvailable_flagDisabled_shouldReturnFalse() {
63         mSetFlagsRule.disableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS);
64         assertThat(mController.isAvailable()).isFalse();
65         assertThat(mController.getAvailabilityStatus()).isEqualTo(
66                 BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
67     }
68 
69 }
70