Search in sources :

Example 16 with RadioButtonPreference

use of com.android.settings.widget.RadioButtonPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 17 with RadioButtonPreference

use of com.android.settings.widget.RadioButtonPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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(ConnectivityManager.class)).thenReturn(mConnectivityManager);
    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.settings.widget.RadioButtonPreference) Before(org.junit.Before)

Example 18 with RadioButtonPreference

use of com.android.settings.widget.RadioButtonPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WebViewAppPickerTest method testDisabledPackageShowsDisabledReasonSummary.

@Test
public void testDisabledPackageShowsDisabledReasonSummary() {
    String disabledReason = "disabled";
    DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), disabledReason);
    RadioButtonPreference preference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(preference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(preference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(preference, times(1)).setSummary(eq(disabledReason));
    // Ensure we haven't called setSummary several times.
    verify(preference, times(1)).setSummary(any());
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 19 with RadioButtonPreference

use of com.android.settings.widget.RadioButtonPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WebViewAppPickerTest method testEnabledPackageShowsEmptySummary.

@Test
public void testEnabledPackageShowsEmptySummary() {
    DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), null);
    RadioButtonPreference preference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(preference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(preference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(preference, never()).setSummary(any());
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 20 with RadioButtonPreference

use of com.android.settings.widget.RadioButtonPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WebViewAppPickerTest method testDisabledPackageShownAsDisabled.

@Test
public void testDisabledPackageShownAsDisabled() {
    DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), "disabled");
    RadioButtonPreference preference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(preference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(preference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(preference, times(1)).setEnabled(eq(false));
    verify(preference, never()).setEnabled(eq(true));
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) 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