Search in sources :

Example 51 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 52 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 53 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 54 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 55 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)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