Search in sources :

Example 66 with RestrictedSwitchPreference

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

the class VibrationPreferenceControllerTest method testUpdateState_notBlockable.

@Test
public void testUpdateState_notBlockable() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.isImportanceLockedByOEM()).thenReturn(true);
    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 67 with RestrictedSwitchPreference

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

the class VibrationPreferenceControllerTest method testUpdateState_vibrateOff.

@Test
public void testUpdateState_vibrateOff() {
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.shouldVibrate()).thenReturn(false);
    mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
    mController.updateState(pref);
    assertFalse(pref.isChecked());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 68 with RestrictedSwitchPreference

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

the class VibrationPreferenceControllerTest method testUpdateState_disabledByAdmin.

@Test
public void testUpdateState_disabledByAdmin() {
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getId()).thenReturn("something");
    mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
    Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
    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 69 with RestrictedSwitchPreference

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

the class VibrationPreferenceControllerTest method testUpdateState_vibrateOn.

@Test
public void testUpdateState_vibrateOn() {
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.shouldVibrate()).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)

Example 70 with RestrictedSwitchPreference

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

the class VibrationPreferenceControllerTest method testOnPreferenceChange_on.

@Test
public void testOnPreferenceChange_on() {
    NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_DEFAULT);
    mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
    mController.updateState(pref);
    mController.onPreferenceChange(pref, true);
    assertTrue(channel.shouldVibrate());
    verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Aggregations

RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)146 Test (org.junit.Test)101 NotificationChannel (android.app.NotificationChannel)52 Preference (androidx.preference.Preference)23 PreferenceGroup (android.support.v7.preference.PreferenceGroup)15 Preference (android.support.v7.preference.Preference)14 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)10 Before (org.junit.Before)10 SwitchPreference (android.support.v14.preference.SwitchPreference)8 Context (android.content.Context)7 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 ContentResolver (android.content.ContentResolver)2 ResolveInfo (android.content.pm.ResolveInfo)2 PersistableBundle (android.os.PersistableBundle)2