use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class UsbDetailsFunctionsControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mLifecycle = new Lifecycle(() -> mLifecycle);
mPreferenceManager = new PreferenceManager(mContext);
mScreen = mPreferenceManager.createPreferenceScreen(mContext);
when(mFragment.getActivity()).thenReturn(mActivity);
when(mActivity.getApplicationContext()).thenReturn(mContext);
when(mFragment.getContext()).thenReturn(mContext);
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
mDetailsFunctionsController = new UsbDetailsFunctionsController(mContext, mFragment, mUsbBackend);
mPreferenceCategory = new PreferenceCategory(mContext);
mPreferenceCategory.setKey(mDetailsFunctionsController.getPreferenceKey());
mScreen.addPreference(mPreferenceCategory);
mDetailsFunctionsController.displayPreference(mScreen);
mRadioButtonPreference = new RadioButtonPreference(mContext);
}
use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
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.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class UsbDetailsDataRoleControllerTest method onClickDeviceAndRefresh_failed_shouldShowFailureText.
@Test
public void onClickDeviceAndRefresh_failed_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);
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_HOST);
assertThat(devicePref.getSummary()).isEqualTo(mContext.getString(R.string.usb_switching_failed));
}
use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class ZenModePriorityConversationsPreferenceControllerTest method clickNoConversations.
@Test
public void clickNoConversations() {
RadioButtonPreference noConversationsRb = getButton(KEY_NONE);
noConversationsRb.onClick();
verify(mZenBackend).saveConversationSenders(CONVERSATION_SENDERS_NONE);
}
use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class ZenModePriorityConversationsPreferenceControllerTest method clickAllConversations.
@Test
public void clickAllConversations() {
RadioButtonPreference allConversationsRb = getButton(KEY_ALL);
allConversationsRb.onClick();
verify(mZenBackend).saveConversationSenders(CONVERSATION_SENDERS_ANYONE);
}
Aggregations