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