Search in sources :

Example 46 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 47 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 48 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 49 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 50 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)122 Test (org.junit.Test)80 DefaultAppInfo (com.android.settings.applications.defaultapps.DefaultAppInfo)30 NetworkScorerAppData (android.net.NetworkScorerAppData)21 PreferenceScreen (android.support.v7.preference.PreferenceScreen)18 ComponentName (android.content.ComponentName)14 Preference (android.support.v7.preference.Preference)12 PackageInfo (android.content.pm.PackageInfo)6 PackageItemInfo (android.content.pm.PackageItemInfo)6 PackageManager (android.content.pm.PackageManager)6 VisibleForTesting (android.support.annotation.VisibleForTesting)6 DefaultAppInfo (com.android.settingslib.applications.DefaultAppInfo)6 PreferenceCategory (androidx.preference.PreferenceCategory)2 PreferenceScreen (androidx.preference.PreferenceScreen)2 Before (org.junit.Before)2 Resources (android.content.res.Resources)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 Preference (androidx.preference.Preference)1 PreferenceManager (androidx.preference.PreferenceManager)1 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)1