use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VisibilityPreferenceControllerTest method testUpdateState_disabledByAdmin_disableUnredacted.
@Test
public void testUpdateState_disabledByAdmin_disableUnredacted() {
ShadowRestrictionUtils.setRestricted(true);
UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
when(mUm.getUserInfo(anyInt())).thenReturn(userInfo);
List<ComponentName> components = new ArrayList<>();
components.add(new ComponentName("", ""));
when(mDm.getActiveAdminsAsUser(anyInt())).thenReturn(components);
when(mDm.getKeyguardDisabledFeatures(any(), anyInt())).thenReturn(KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
verify(pref, times(1)).addRestrictedItem(any());
}
use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VisibilityPreferenceControllerTest method testOnPreferenceChange_override.
@Test
public void testOnPreferenceChange_override() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", 4);
channel.setLockscreenVisibility(VISIBILITY_NO_OVERRIDE);
mController.onResume(appRow, channel, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
mController.onPreferenceChange(pref, String.valueOf(Notification.VISIBILITY_SECRET));
assertEquals(Notification.VISIBILITY_SECRET, channel.getLockscreenVisibility());
verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
}
use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VisibilityPreferenceControllerTest method testUpdateState_disabledByAdmin_disableSecure.
@Test
public void testUpdateState_disabledByAdmin_disableSecure() {
ShadowRestrictionUtils.setRestricted(true);
UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
when(mUm.getUserInfo(anyInt())).thenReturn(userInfo);
List<ComponentName> components = new ArrayList<>();
components.add(new ComponentName("", ""));
when(mDm.getActiveAdminsAsUser(anyInt())).thenReturn(components);
when(mDm.getKeyguardDisabledFeatures(any(), anyInt())).thenReturn(KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
verify(pref, times(2)).addRestrictedItem(any());
}
use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VisibilityPreferenceControllerTest method testUpdateState_noChannelOverride.
@Test
public void testUpdateState_noChannelOverride() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getLockscreenVisibility()).thenReturn(VISIBILITY_NO_OVERRIDE);
mController.onResume(appRow, channel, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
verify(pref, times(1)).setValue(argumentCaptor.capture());
assertEquals(String.valueOf(VISIBILITY_PRIVATE), argumentCaptor.getValue());
}
use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ShowOnLockscreenNotificationPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = new ShowOnLockScreenNotificationPreferenceController(mContext, KEY);
mPreference = new RestrictedListPreference(mContext, Robolectric.buildAttributeSet().build());
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
mController.setDpm(mDpm);
}
Aggregations