Search in sources :

Example 31 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project platform_packages_apps_Settings by BlissRoms.

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

use of com.android.settingslib.RestrictedSwitchPreference in project platform_packages_apps_Settings by BlissRoms.

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

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AutoTimePreferenceControllerTest method setUp.

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

Example 34 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AirplaneModePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    FakeFeatureFactory.setupForTest();
    mContext = spy(RuntimeEnvironment.application);
    mResolver = RuntimeEnvironment.application.getContentResolver();
    doReturn(mPackageManager).when(mContext).getPackageManager();
    mController = new AirplaneModePreferenceController(mContext, SettingsSlicesContract.KEY_AIRPLANE_MODE);
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreference = new RestrictedSwitchPreference(mContext);
    mPreference.setKey(SettingsSlicesContract.KEY_AIRPLANE_MODE);
    mScreen.addPreference(mPreference);
    mController.setFragment(null);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mLifecycle.addObserver(mController);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 35 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference 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)

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