Search in sources :

Example 11 with RestrictedListPreference

use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VisibilityPreferenceControllerTest method testUpdateState_noPrivateLockScreenNotificationsGlobally.

@Test
public void testUpdateState_noPrivateLockScreenNotificationsGlobally() {
    Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
    Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    mController.onResume(appRow, channel, null, null);
    RestrictedListPreference pref = mock(RestrictedListPreference.class);
    mController.updateState(pref);
    ArgumentCaptor<CharSequence[]> argumentCaptor = ArgumentCaptor.forClass(CharSequence[].class);
    verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
    assertEquals(2, toStringList(argumentCaptor.getValue()).size());
    assertFalse(toStringList(argumentCaptor.getValue()).contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedListPreference(com.android.settings.RestrictedListPreference) Test(org.junit.Test)

Example 12 with RestrictedListPreference

use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VisibilityPreferenceControllerTest method testUpdateState_noLockScreenNotificationsGloballyInProfile.

@Test
public void testUpdateState_noLockScreenNotificationsGloballyInProfile() {
    final int primaryUserId = 2;
    final UserInfo primaryUserInfo = new UserInfo(primaryUserId, "user 2", 0);
    when(mUm.getProfileParent(anyInt())).thenReturn(primaryUserInfo);
    Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, primaryUserId);
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    mController.onResume(appRow, channel, null, null);
    RestrictedListPreference pref = mock(RestrictedListPreference.class);
    mController.updateState(pref);
    ArgumentCaptor<CharSequence[]> argumentCaptor = ArgumentCaptor.forClass(CharSequence[].class);
    verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
    assertFalse(toStringList(argumentCaptor.getValue()).contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
    assertFalse(toStringList(argumentCaptor.getValue()).contains(String.valueOf(VISIBILITY_PRIVATE)));
}
Also used : NotificationChannel(android.app.NotificationChannel) UserInfo(android.content.pm.UserInfo) RestrictedListPreference(com.android.settings.RestrictedListPreference) Test(org.junit.Test)

Example 13 with RestrictedListPreference

use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VisibilityPreferenceControllerTest method testUpdateState_channelOverride.

@Test
public void testUpdateState_channelOverride() {
    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(Notification.VISIBILITY_SECRET);
    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(Notification.VISIBILITY_SECRET), argumentCaptor.getValue());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedListPreference(com.android.settings.RestrictedListPreference) Test(org.junit.Test)

Example 14 with RestrictedListPreference

use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VisibilityPreferenceControllerTest method testUpdateState_noLockScreenNotificationsGlobally.

@Test
public void testUpdateState_noLockScreenNotificationsGlobally() {
    Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    mController.onResume(appRow, channel, null, null);
    RestrictedListPreference pref = mock(RestrictedListPreference.class);
    mController.updateState(pref);
    ArgumentCaptor<CharSequence[]> argumentCaptor = ArgumentCaptor.forClass(CharSequence[].class);
    verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
    assertFalse(toStringList(argumentCaptor.getValue()).contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
    assertFalse(toStringList(argumentCaptor.getValue()).contains(String.valueOf(VISIBILITY_PRIVATE)));
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedListPreference(com.android.settings.RestrictedListPreference) Test(org.junit.Test)

Aggregations

RestrictedListPreference (com.android.settings.RestrictedListPreference)14 NotificationChannel (android.app.NotificationChannel)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)4 UserInfo (android.content.pm.UserInfo)3 ComponentName (android.content.ComponentName)2 Before (org.junit.Before)1