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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations