Search in sources :

Example 91 with RestrictedSwitchPreference

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

the class AddUserWhenLockedPreferenceControllerTest method updateState_preferenceSetUncheckedWhenSettingIsOff.

@Test
public void updateState_preferenceSetUncheckedWhenSettingIsOff() {
    final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
    Global.putInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 0);
    mController.updateState(preference);
    verify(preference).setChecked(false);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 92 with RestrictedSwitchPreference

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

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)

Example 93 with RestrictedSwitchPreference

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

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 94 with RestrictedSwitchPreference

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

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 95 with RestrictedSwitchPreference

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

the class AutoTimePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = ShadowApplication.getInstance().getApplicationContext();
    mPreference = new RestrictedSwitchPreference(mContext);
    mController = new AutoTimePreferenceController(mContext, mCallback);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Before(org.junit.Before)

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