Search in sources :

Example 11 with RadioButtonPreference

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

Example 12 with RadioButtonPreference

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

Example 13 with RadioButtonPreference

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

Example 14 with RadioButtonPreference

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

Example 15 with RadioButtonPreference

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

Aggregations

RadioButtonPreference (com.android.settings.widget.RadioButtonPreference)109 Test (org.junit.Test)68 NetworkScorerAppData (android.net.NetworkScorerAppData)18 PreferenceScreen (android.support.v7.preference.PreferenceScreen)14 ComponentName (android.content.ComponentName)12 DefaultAppInfo (com.android.settingslib.applications.DefaultAppInfo)12 Preference (android.support.v7.preference.Preference)10 DefaultAppInfo (com.android.settings.applications.defaultapps.DefaultAppInfo)10 VisibleForTesting (android.support.annotation.VisibleForTesting)4 PreferenceCategory (androidx.preference.PreferenceCategory)4 PreferenceScreen (androidx.preference.PreferenceScreen)4 Before (org.junit.Before)4 PackageInfo (android.content.pm.PackageInfo)2 PackageItemInfo (android.content.pm.PackageItemInfo)2 PackageManager (android.content.pm.PackageManager)2 Resources (android.content.res.Resources)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 Preference (androidx.preference.Preference)2 PreferenceManager (androidx.preference.PreferenceManager)2 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)2