Search in sources :

Example 36 with RestrictedSwitchPreference

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

the class LightsPreferenceControllerTest 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(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
    mController.displayPreference(mScreen);
    mController.updateState(pref);
    mController.onPreferenceChange(pref, false);
    assertFalse(channel.shouldShowLights());
    verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 37 with RestrictedSwitchPreference

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

the class HighImportancePreferenceControllerTest method testUpdateState_default.

@Test
public void testUpdateState_default() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
    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 38 with RestrictedSwitchPreference

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

the class HighImportancePreferenceControllerTest method testUpdateState_disabledByAdmin.

@Test
public void testUpdateState_disabledByAdmin() {
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
    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 39 with RestrictedSwitchPreference

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

the class DndPreferenceControllerTest method testOnPreferenceChange_on.

@Test
public void testOnPreferenceChange_on() {
    NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
    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, true);
    assertTrue(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 40 with RestrictedSwitchPreference

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

the class DndPreferenceControllerTest method testUpdateState_bypassDnd.

@Test
public void testUpdateState_bypassDnd() {
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.canBypassDnd()).thenReturn(true);
    mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
    mController.updateState(pref);
    assertTrue(pref.isChecked());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) 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