Search in sources :

Example 61 with RestrictedSwitchPreference

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

the class BadgePreferenceControllerTest method testUpdateState_channelNotBlockable.

@Test
public void testUpdateState_channelNotBlockable() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getId()).thenReturn("");
    when(channel.isImportanceLockedByOEM()).thenReturn(true);
    mController.onResume(appRow, channel, null, null);
    Preference pref = new RestrictedSwitchPreference(mContext);
    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 62 with RestrictedSwitchPreference

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

the class BadgePreferenceControllerTest method testUpdateState_app.

@Test
public void testUpdateState_app() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.showBadge = true;
    mController.onResume(appRow, null, null, null);
    RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
    mController.updateState(pref);
    assertTrue(pref.isChecked());
    appRow.showBadge = false;
    mController.onResume(appRow, null, null, null);
    mController.updateState(pref);
    assertFalse(pref.isChecked());
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 63 with RestrictedSwitchPreference

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

the class BadgePreferenceControllerTest method testOnPreferenceChange_off_channel.

@Test
public void testOnPreferenceChange_off_channel() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.showBadge = true;
    NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
    channel.setShowBadge(true);
    mController.onResume(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);
    verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
    assertFalse(channel.canShowBadge());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 64 with RestrictedSwitchPreference

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

the class BadgePreferenceControllerTest method testOnPreferenceChange_off_app.

@Test
public void testOnPreferenceChange_off_app() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.showBadge = true;
    mController.onResume(appRow, null, 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(appRow.showBadge);
    verify(mBackend, times(1)).setShowBadge(any(), anyInt(), eq(false));
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 65 with RestrictedSwitchPreference

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

the class VibrationPreferenceControllerTest 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)

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