Search in sources :

Example 61 with Preference

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

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

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

Example 64 with Preference

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

the class MinImportancePreferenceControllerTest method testUpdateState_defaultApp.

@Test
public void testUpdateState_defaultApp() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.systemApp = true;
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
    when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
    mController.onResume(appRow, channel, null, null);
    Preference pref = new RestrictedSwitchPreference(mContext, null);
    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 65 with Preference

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

the class SimLockPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    ShadowApplication shadowApplication = ShadowApplication.getInstance();
    shadowApplication.setSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE, mSubscriptionManager);
    shadowApplication.setSystemService(Context.CARRIER_CONFIG_SERVICE, mCarrierManager);
    shadowApplication.setSystemService(Context.USER_SERVICE, mUserManager);
    shadowApplication.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);
    mController = new SimLockPreferenceController(RuntimeEnvironment.application);
    mPreference = new Preference(RuntimeEnvironment.application);
    mPreference.setKey(mController.getPreferenceKey());
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}
Also used : Preference(androidx.preference.Preference) ShadowApplication(org.robolectric.shadows.ShadowApplication) Before(org.junit.Before)

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