Search in sources :

Example 41 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DndPreferenceControllerTest method testUpdateState_configurable.

@Test
public void testUpdateState_configurable() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getId()).thenReturn("something");
    mController.onResume(appRow, channel, null, null);
    Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
    mController.updateState(pref);
    assertTrue(pref.isEnabled());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 42 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DndPreferenceControllerTest method testOnPreferenceChange_off.

@Test
public void testOnPreferenceChange_off() {
    NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
    mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
    mController.displayPreference(mScreen);
    mController.updateState(pref);
    mController.onPreferenceChange(pref, false);
    assertFalse(channel.canBypassDnd());
    verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 43 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MinImportancePreferenceControllerTest method testUpdateState_disabledByAdmin.

@Test
public void testUpdateState_disabledByAdmin() {
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
    mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
    Preference pref = new RestrictedSwitchPreference(mContext, null);
    mController.updateState(pref);
    assertFalse(pref.isEnabled());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 44 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MinImportancePreferenceControllerTest method testUpdateState_low.

@Test
public void testUpdateState_low() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
    mController.onResume(appRow, channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    mController.updateState(pref);
    assertFalse(pref.isChecked());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 45 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MinImportancePreferenceControllerTest method testUpdateState_notConfigurable.

@Test
public void testUpdateState_notConfigurable() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.isImportanceLockedByOEM()).thenReturn(true);
    when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
    mController.onResume(appRow, channel, null, null);
    Preference pref = new RestrictedSwitchPreference(mContext, null);
    mController.updateState(pref);
    assertFalse(pref.isEnabled());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(androidx.preference.Preference) Test(org.junit.Test)

Aggregations

RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)250 Test (org.junit.Test)181 NotificationChannel (android.app.NotificationChannel)105 NotificationBackend (com.android.settings.notification.NotificationBackend)60 Preference (androidx.preference.Preference)48 Before (org.junit.Before)16 PreferenceGroup (android.support.v7.preference.PreferenceGroup)15 Preference (android.support.v7.preference.Preference)14 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)13 Context (android.content.Context)8 SwitchPreference (android.support.v14.preference.SwitchPreference)8 IBinder (android.os.IBinder)7 RemoteException (android.os.RemoteException)7 ListPreference (android.support.v7.preference.ListPreference)7 LockPatternUtils (com.android.internal.widget.LockPatternUtils)7 IStorageManager (android.os.storage.IStorageManager)6 WebViewAppPreferenceController (com.android.settings.webview.WebViewAppPreferenceController)6 AbstractEnableAdbPreferenceController (com.android.settingslib.development.AbstractEnableAdbPreferenceController)6 Intent (android.content.Intent)5 BroadcastReceiver (android.content.BroadcastReceiver)4