Search in sources :

Example 16 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by crdroidandroid.

the class AddUserWhenLockedPreferenceControllerTest method displayPref_NotAdmin_shouldNotDisplay.

@Test
public void displayPref_NotAdmin_shouldNotDisplay() {
    when(mUserManager.getUserInfo(anyInt())).thenReturn(mUserInfo);
    when(mUserInfo.isAdmin()).thenReturn(false);
    final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
    when(mScreen.getPreferenceCount()).thenReturn(1);
    when(mScreen.getPreference(0)).thenReturn(preference);
    when(preference.getKey()).thenReturn(mController.getPreferenceKey());
    mController.displayPreference(mScreen);
    verify(mScreen).removePreference(any(Preference.class));
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) Test(org.junit.Test)

Example 17 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by crdroidandroid.

the class AddUserWhenLockedPreferenceControllerTest method onPreferenceChange_SettingIsOnWhenPreferenceChecked.

@Test
public void onPreferenceChange_SettingIsOnWhenPreferenceChecked() {
    final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
    preference.setChecked(true);
    mController.onPreferenceChange(preference, Boolean.TRUE);
    assertThat(Global.getInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 0)).isEqualTo(1);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 18 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by SudaMod.

the class AddUserWhenLockedPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    RestrictedSwitchPreference restrictedSwitchPreference = (RestrictedSwitchPreference) preference;
    int value = Global.getInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 0);
    restrictedSwitchPreference.setChecked(value == 1);
    restrictedSwitchPreference.setDisabledByAdmin(mUserCaps.disallowAddUser() ? mUserCaps.getEnforcedAdmin() : null);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference)

Example 19 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by SudaMod.

the class AddUserWhenLockedPreferenceControllerTest method onPreferenceChange_SettingIsOffWhenPreferenceNotChecked.

@Test
public void onPreferenceChange_SettingIsOffWhenPreferenceNotChecked() {
    final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
    preference.setChecked(false);
    mController.onPreferenceChange(preference, Boolean.FALSE);
    assertThat(Global.getInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 0)).isEqualTo(0);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 20 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by SudaMod.

the class AddUserWhenLockedPreferenceControllerTest method updateState_preferenceSetCheckedWhenSettingIsOn.

@Test
public void updateState_preferenceSetCheckedWhenSettingIsOn() {
    final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
    Global.putInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 1);
    mController.updateState(preference);
    verify(preference).setChecked(true);
}
Also used : 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