Search in sources :

Example 41 with RadioButtonPreference

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);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Before(org.junit.Before)

Example 42 with RadioButtonPreference

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));
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Example 43 with RadioButtonPreference

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));
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Example 44 with RadioButtonPreference

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);
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Example 45 with RadioButtonPreference

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);
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Aggregations

RadioButtonPreference (com.android.settingslib.widget.RadioButtonPreference)52 Test (org.junit.Test)27 Before (org.junit.Before)8 DefaultAppInfo (com.android.settingslib.applications.DefaultAppInfo)6 PreferenceScreen (androidx.preference.PreferenceScreen)5 CandidateInfo (com.android.settingslib.widget.CandidateInfo)3 Preference (androidx.preference.Preference)2 PreferenceCategory (androidx.preference.PreferenceCategory)2 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)2 FooterPreference (com.android.settingslib.widget.FooterPreference)2 AppOpsManager (android.app.AppOpsManager)1 SettingsEnums (android.app.settings.SettingsEnums)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageManager (android.content.pm.PackageManager)1 Resources (android.content.res.Resources)1 Drawable (android.graphics.drawable.Drawable)1 BatteryStats (android.os.BatteryStats)1 Bundle (android.os.Bundle)1