Search in sources :

Example 1 with SwitchPreference

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

the class BluetoothDetailsProfilesControllerTest method pbapProfileStartsDisabled.

@Test
public void pbapProfileStartsDisabled() {
    setupDevice(makeDefaultDeviceConfig());
    mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
    PbapServerProfile psp = mock(PbapServerProfile.class);
    when(psp.getNameResource(mDevice)).thenReturn(R.string.bluetooth_profile_pbap);
    when(psp.toString()).thenReturn(PbapServerProfile.NAME);
    when(psp.isProfileReady()).thenReturn(true);
    when(mProfileManager.getPbapProfile()).thenReturn(psp);
    showScreen(mController);
    List<SwitchPreference> switches = getProfileSwitches(false);
    assertThat(switches.size()).isEqualTo(1);
    SwitchPreference pref = switches.get(0);
    assertThat(pref.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_profile_pbap));
    assertThat(pref.isChecked()).isFalse();
    pref.performClick();
    assertThat(mProfiles.getPreferenceCount()).isEqualTo(1);
    assertThat(mDevice.getPhonebookAccessPermission()).isEqualTo(BluetoothDevice.ACCESS_ALLOWED);
}
Also used : PbapServerProfile(com.android.settingslib.bluetooth.PbapServerProfile) SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 2 with SwitchPreference

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

the class BluetoothDetailsProfilesControllerTest method highQualityAudio_prefIsAbsentWhenNotSupported.

@Test
public void highQualityAudio_prefIsAbsentWhenNotSupported() {
    setupDevice(makeDefaultDeviceConfig());
    addMockA2dpProfile(true, false, false);
    showScreen(mController);
    assertThat(mProfiles.getPreferenceCount()).isEqualTo(1);
    SwitchPreference pref = (SwitchPreference) mProfiles.getPreference(0);
    assertThat(pref.getKey()).isNotEqualTo(BluetoothDetailsProfilesController.HIGH_QUALITY_AUDIO_PREF_TAG);
    assertThat(pref.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_profile_a2dp));
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 3 with SwitchPreference

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

the class BluetoothDetailsProfilesControllerTest method mapProfile.

@Test
public void mapProfile() {
    setupDevice(makeDefaultDeviceConfig());
    MapProfile mapProfile = mock(MapProfile.class);
    when(mapProfile.getNameResource(mDevice)).thenReturn(R.string.bluetooth_profile_map);
    when(mapProfile.isProfileReady()).thenReturn(true);
    when(mProfileManager.getMapProfile()).thenReturn(mapProfile);
    when(mProfileManager.getProfileByName(eq(mapProfile.toString()))).thenReturn(mapProfile);
    mDevice.setMessageAccessPermission(BluetoothDevice.ACCESS_REJECTED);
    showScreen(mController);
    List<SwitchPreference> switches = getProfileSwitches(false);
    assertThat(switches.size()).isEqualTo(1);
    SwitchPreference pref = switches.get(0);
    assertThat(pref.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_profile_map));
    assertThat(pref.isChecked()).isFalse();
    pref.performClick();
    assertThat(mProfiles.getPreferenceCount()).isEqualTo(1);
    assertThat(mDevice.getMessageAccessPermission()).isEqualTo(BluetoothDevice.ACCESS_ALLOWED);
}
Also used : MapProfile(com.android.settingslib.bluetooth.MapProfile) SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 4 with SwitchPreference

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

the class TimeFormatPreferenceControllerTest method updateState_12HourSet_shouldNotCheckPreference.

@Test
public void updateState_12HourSet_shouldNotCheckPreference() {
    mController = new TimeFormatPreferenceController(mContext, mCallback, false);
    mPreference = new SwitchPreference(mContext);
    mPreference.setKey(mController.getPreferenceKey());
    Settings.System.putString(mContext.getContentResolver(), Settings.System.TIME_12_24, TimeFormatPreferenceController.HOURS_12);
    mController.updateState(mPreference);
    assertThat(mPreference.isChecked()).isFalse();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 5 with SwitchPreference

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

the class AutoTimeFormatPreferenceControllerTest method updatePreference_autoSet_shouldSendIntent_12HourLocale.

@Test
public void updatePreference_autoSet_shouldSendIntent_12HourLocale() {
    mController = new TestAutoTimeFormatPreferenceController(mContext, mCallback);
    mPreference = new SwitchPreference(mContext);
    mPreference.setKey(mController.getPreferenceKey());
    mPreference.setChecked(false);
    boolean result = mController.handlePreferenceTreeClick(mPreference);
    assertThat(result).isTrue();
    List<Intent> intentsFired = mApplication.getBroadcastIntents();
    assertThat(intentsFired.size()).isEqualTo(1);
    Intent intentFired = intentsFired.get(0);
    assertThat(intentFired.getAction()).isEqualTo(Intent.ACTION_TIME_CHANGED);
    assertThat(intentFired.getIntExtra(Intent.EXTRA_TIME_PREF_24_HOUR_FORMAT, -1)).isEqualTo(Intent.EXTRA_TIME_PREF_VALUE_USE_12_HOUR);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Intent(android.content.Intent) 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