Search in sources :

Example 21 with RadioButtonPreference

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

the class UnrestrictedPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mController = new UnrestrictedPreferenceController(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)

Example 22 with RadioButtonPreference

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

the class WebViewAppPickerTest method testWebViewVersionAddedAfterLabel.

/**
 * Ensure that the version name of a WebView package is displayed after its name in the
 * preference title.
 */
@Test
public void testWebViewVersionAddedAfterLabel() {
    final DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), "");
    final RadioButtonPreference mockPreference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(mockPreference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(mockPreference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(mockPreference).setTitle(eq(PACKAGE_NAME + " " + PACKAGE_VERSION));
    verify(mockPreference).setTitle(any());
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Example 23 with RadioButtonPreference

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

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

Example 24 with RadioButtonPreference

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

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

Example 25 with RadioButtonPreference

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

the class WebViewAppPickerTest method testFailingClickUpdatesSetting.

private void testFailingClickUpdatesSetting() {
    when(mWvusWrapper.getValidWebViewApplicationInfos(any())).thenReturn(Collections.singletonList(createApplicationInfo(PACKAGE_NAME)));
    when(mWvusWrapper.setWebViewProvider(eq(PACKAGE_NAME))).thenReturn(false);
    RadioButtonPreference defaultPackagePref = mock(RadioButtonPreference.class);
    when(defaultPackagePref.getKey()).thenReturn(PACKAGE_NAME);
    mPicker.onRadioButtonClicked(defaultPackagePref);
    verify(mWvusWrapper, times(1)).setWebViewProvider(eq(PACKAGE_NAME));
    // Ensure we update the list of packages when we click a non-valid package - the list must
    // have changed, otherwise this click wouldn't fail.
    verify(mPicker, times(1)).updateCandidates();
    verify(mWvusWrapper, times(1)).showInvalidChoiceToast(any());
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference)

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