use of com.android.settings.widget.RadioButtonPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NetworkScorerPickerTest method testOnRadioButtonClicked_currentScorer_doNothing.
@Test
public void testOnRadioButtonClicked_currentScorer_doNothing() {
RadioButtonPreference pref = new RadioButtonPreference(mContext);
pref.setKey(TEST_SCORER_PACKAGE_1);
pref.setChecked(true);
when(mPreferenceScreen.getPreference(anyInt())).thenReturn(pref);
when(mPreferenceScreen.getPreferenceCount()).thenReturn(1);
when(mNetworkScoreManager.setActiveScorer(TEST_SCORER_PACKAGE_1)).thenReturn(true);
when(mNetworkScoreManager.getActiveScorerPackage()).thenReturn(TEST_SCORER_PACKAGE_1);
mFragment.onRadioButtonClicked(pref);
verify(mNetworkScoreManager, never()).setActiveScorer(any());
assertThat(pref.isChecked()).isTrue();
}
use of com.android.settings.widget.RadioButtonPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UsbDetailsDataRoleControllerTest method displayRefresh_deviceRole_shouldCheckDevice.
@Test
public void displayRefresh_deviceRole_shouldCheckDevice() {
mDetailsDataRoleController.displayPreference(mScreen);
mDetailsDataRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
final RadioButtonPreference hostPref = getRadioPreference(DATA_ROLE_HOST);
assertThat(devicePref.isChecked()).isTrue();
assertThat(hostPref.isChecked()).isFalse();
}
use of com.android.settings.widget.RadioButtonPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UsbDetailsDataRoleControllerTest method onClickDeviceAndRefresh_success_shouldClearSubtext.
@Test
public void onClickDeviceAndRefresh_success_shouldClearSubtext() {
mDetailsDataRoleController.displayPreference(mScreen);
when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
devicePref.performClick();
verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
assertThat(devicePref.getSummary()).isEqualTo(mContext.getString(R.string.usb_switching));
mDetailsDataRoleController.refresh(false, /* connected */
UsbManager.FUNCTION_NONE, POWER_ROLE_NONE, DATA_ROLE_NONE);
mDetailsDataRoleController.refresh(true, /* connected */
UsbManager.FUNCTION_NONE, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
assertThat(devicePref.getSummary()).isEqualTo("");
}
use of com.android.settings.widget.RadioButtonPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UsbDetailsDataRoleControllerTest method onClickDevice_timedOut_shouldShowFailureText.
@Test
public void onClickDevice_timedOut_shouldShowFailureText() {
mDetailsDataRoleController.displayPreference(mScreen);
when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
devicePref.performClick();
verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(mHandler).postDelayed(captor.capture(), anyLong());
assertThat(devicePref.getSummary()).isEqualTo(mContext.getString(R.string.usb_switching));
mDetailsDataRoleController.refresh(false, /* connected */
UsbManager.FUNCTION_NONE, POWER_ROLE_NONE, DATA_ROLE_NONE);
captor.getValue().run();
assertThat(devicePref.getSummary()).isEqualTo(mContext.getString(R.string.usb_switching_failed));
}
use of com.android.settings.widget.RadioButtonPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UsbDetailsDataRoleControllerTest method onClickDeviceTwice_hostEnabled_shouldSetDeviceOnce.
@Test
public void onClickDeviceTwice_hostEnabled_shouldSetDeviceOnce() {
mDetailsDataRoleController.displayPreference(mScreen);
when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
devicePref.performClick();
assertThat(devicePref.getSummary()).isEqualTo(mContext.getString(R.string.usb_switching));
devicePref.performClick();
verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
}
Aggregations