Search in sources :

Example 56 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ImportancePreferenceControllerTest 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 ImportancePreference(mContext, null);
    mController.updateState(pref);
    assertFalse(pref.isEnabled());
}
Also used : NotificationChannel(android.app.NotificationChannel) Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 57 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ImportancePreferenceControllerTest method testUpdateState_systemButConfigurable.

@Test
public void testUpdateState_systemButConfigurable() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.systemApp = true;
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.isImportanceLockedByOEM()).thenReturn(false);
    when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
    mController.onResume(appRow, channel, null, null);
    Preference pref = new ImportancePreference(mContext, null);
    mController.updateState(pref);
    assertTrue(pref.isEnabled());
}
Also used : NotificationChannel(android.app.NotificationChannel) Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 58 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LightsPreferenceControllerTest 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(mContext);
    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 59 with Preference

use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class GentleNotificationsPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mController = new GentleNotificationsPreferenceController(mContext, KEY);
    mController.setBackend(mBackend);
    mPreference = new Preference(mContext);
}
Also used : Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 60 with Preference

use of androidx.preference.Preference 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)

Aggregations

Preference (androidx.preference.Preference)863 Test (org.junit.Test)343 Before (org.junit.Before)164 Intent (android.content.Intent)81 PreferenceScreen (androidx.preference.PreferenceScreen)81 NotificationChannel (android.app.NotificationChannel)77 SwitchPreference (androidx.preference.SwitchPreference)75 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)69 Context (android.content.Context)60 ArrayList (java.util.ArrayList)50 NotificationBackend (com.android.settings.notification.NotificationBackend)45 ListPreference (androidx.preference.ListPreference)43 PreferenceCategory (androidx.preference.PreferenceCategory)40 Tile (com.android.settingslib.drawer.Tile)40 PreferenceManager (androidx.preference.PreferenceManager)39 Activity (android.app.Activity)27 UserHandle (android.os.UserHandle)27 FooterPreference (com.android.settingslib.widget.FooterPreference)27 PackageManager (android.content.pm.PackageManager)26 Bundle (android.os.Bundle)24