Search in sources :

Example 16 with RadioButtonPreference

use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.

the class UsbDetailsDataRoleControllerTest method displayRefresh_hostRole_shouldCheckHost.

@Test
public void displayRefresh_hostRole_shouldCheckHost() {
    mDetailsDataRoleController.displayPreference(mScreen);
    mDetailsDataRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK, DATA_ROLE_HOST);
    final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
    final RadioButtonPreference hostPref = getRadioPreference(DATA_ROLE_HOST);
    assertThat(devicePref.isChecked()).isFalse();
    assertThat(hostPref.isChecked()).isTrue();
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Example 17 with RadioButtonPreference

use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.

the class UsbDetailsDataRoleControllerTest method onClickDevice_hostEnabled_shouldSetDevice.

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

Example 18 with RadioButtonPreference

use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.

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

Example 19 with RadioButtonPreference

use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.

the class UsbDetailsFunctionsControllerTest method displayRefresh_allAllowed_shouldCreatePrefs.

@Test
public void displayRefresh_allAllowed_shouldCreatePrefs() {
    when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
    mDetailsFunctionsController.displayPreference(mScreen);
    mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
    List<RadioButtonPreference> prefs = getRadioPreferences();
    Iterator<Long> iter = UsbDetailsFunctionsController.FUNCTIONS_MAP.keySet().iterator();
    for (RadioButtonPreference pref : prefs) {
        assertThat(pref.getKey()).isEqualTo(UsbBackend.usbFunctionsToString(iter.next()));
    }
}
Also used : ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Example 20 with RadioButtonPreference

use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.

the class RestrictedPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mController = new RestrictedPreferenceController(RuntimeEnvironment.application, UID, PACKAGE_NAME);
    mPreference = new RadioButtonPreference(RuntimeEnvironment.application);
    mController.mBatteryOptimizeUtils = mockBatteryOptimizeUtils;
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Before(org.junit.Before)

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