Search in sources :

Example 11 with SwitchPreference

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

the class DockingSoundPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    when(mSetting.getActivity()).thenReturn(mActivity);
    when(mActivity.getContentResolver()).thenReturn(mContentResolver);
    mPreference = new SwitchPreference(RuntimeEnvironment.application);
    when(mActivity.getResources().getBoolean(com.android.settings.R.bool.has_dock_settings)).thenReturn(true);
    mController = new DockingSoundPreferenceController(mContext, mSetting, null);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Before(org.junit.Before)

Example 12 with SwitchPreference

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

the class LockdownButtonPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mPreference = new SwitchPreference(mContext);
    mController = spy(new LockdownButtonPreferenceController(mContext, "TestKey"));
    ReflectionHelpers.setField(mController, "mLockPatternUtils", mLockPatternUtils);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Before(org.junit.Before)

Example 13 with SwitchPreference

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

the class NotifyOpenNetworkPreferenceControllerTest method updateState_preferenceSetCheckedWhenSettingsAreEnabled.

@Test
public void updateState_preferenceSetCheckedWhenSettingsAreEnabled() {
    final SwitchPreference preference = mock(SwitchPreference.class);
    Settings.Global.putInt(mContext.getContentResolver(), WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1);
    mController.updateState(preference);
    verify(preference).setChecked(true);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 14 with SwitchPreference

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

the class WifiWakeupPreferenceControllerTest method updateState_preferenceSetCheckedWhenWakeupSettingEnabled.

@Test
public void updateState_preferenceSetCheckedWhenWakeupSettingEnabled() {
    final SwitchPreference preference = new SwitchPreference(mContext);
    Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
    Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 1);
    mController.updateState(preference);
    assertThat(preference.isChecked()).isTrue();
    assertThat(preference.getSummary()).isEqualTo(mContext.getString(R.string.wifi_wakeup_summary));
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 15 with SwitchPreference

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

the class WifiWakeupPreferenceControllerTest method updateState_preferenceSetUncheckedWhenWifiScanningDisabledLocationEnabled.

@Test
public void updateState_preferenceSetUncheckedWhenWifiScanningDisabledLocationEnabled() {
    final SwitchPreference preference = new SwitchPreference(mContext);
    Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
    Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
    doReturn(false).when(mLocationManager).isLocationEnabled();
    mController.updateState(preference);
    assertThat(preference.isChecked()).isFalse();
    assertThat(TextUtils.equals(preference.getSummary(), mController.getNoLocationSummary())).isTrue();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Aggregations

SwitchPreference (androidx.preference.SwitchPreference)139 Test (org.junit.Test)61 Before (org.junit.Before)29 Intent (android.content.Intent)9 Preference (androidx.preference.Preference)6 ComponentName (android.content.ComponentName)5 A2dpProfile (com.android.settingslib.bluetooth.A2dpProfile)5 ListPreference (androidx.preference.ListPreference)4 PreferenceScreen (androidx.preference.PreferenceScreen)4 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)4 BluetoothDevice (android.bluetooth.BluetoothDevice)2 Context (android.content.Context)2 ServiceInfo (android.content.pm.ServiceInfo)2 KeyboardLayout (android.hardware.input.KeyboardLayout)2 Parcel (android.os.Parcel)2 PersistableBundle (android.os.PersistableBundle)2 RemoteException (android.os.RemoteException)2 TelephonyManager (android.telephony.TelephonyManager)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)2