use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by DirtyUnicorns.
the class DefaultAppPickerFragmentTest method clickPreference_hasConfirmation_shouldShowConfirmation.
@Test
public void clickPreference_hasConfirmation_shouldShowConfirmation() {
mFragment.onAttach((Context) mActivity);
final RadioButtonPreference pref = new RadioButtonPreference(RuntimeEnvironment.application);
pref.setKey("TEST");
doReturn("confirmation_text").when(mFragment).getConfirmationMessage(any(DefaultAppInfo.class));
doReturn(mActivity).when(mFragment).getActivity();
mFragment.onRadioButtonClicked(pref);
}
use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by DirtyUnicorns.
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() throws PackageManager.NameNotFoundException {
PackageItemInfo mockPackageItemInfo = mock(PackageItemInfo.class);
mockPackageItemInfo.packageName = DEFAULT_PACKAGE_NAME;
when(mockPackageItemInfo.loadLabel(any())).thenReturn("myPackage");
DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mPackageManager, mockPackageItemInfo, "");
PackageInfo packageInfo = new PackageInfo();
packageInfo.versionName = "myVersionName";
PackageManager pm = mock(PackageManager.class);
when(pm.getPackageInfo(eq(DEFAULT_PACKAGE_NAME), anyInt())).thenReturn(packageInfo);
when(mPackageManager.getPackageManager()).thenReturn(pm);
RadioButtonPreference mockPreference = mock(RadioButtonPreference.class);
mPicker.bindPreference(mockPreference, DEFAULT_PACKAGE_NAME, webviewAppInfo, null);
mPicker.bindPreferenceExtra(mockPreference, DEFAULT_PACKAGE_NAME, webviewAppInfo, null, null);
verify(mockPreference, times(1)).setTitle(eq("myPackage myVersionName"));
verify(mockPreference, times(1)).setTitle(any());
}
use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by DirtyUnicorns.
the class WebViewAppPickerTest method testFailingClickUpdatesSetting.
private void testFailingClickUpdatesSetting() {
when(mWvusWrapper.getValidWebViewApplicationInfos(any())).thenReturn(Arrays.asList(createApplicationInfo(DEFAULT_PACKAGE_NAME)));
when(mWvusWrapper.setWebViewProvider(eq(DEFAULT_PACKAGE_NAME))).thenReturn(false);
RadioButtonPreference defaultPackagePref = mock(RadioButtonPreference.class);
when(defaultPackagePref.getKey()).thenReturn(DEFAULT_PACKAGE_NAME);
mPicker.onRadioButtonClicked(defaultPackagePref);
verify(mWvusWrapper, times(1)).setWebViewProvider(eq(DEFAULT_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());
}
use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by DirtyUnicorns.
the class WebViewAppPickerTest method testSuccessfulClickChangesProvider.
private void testSuccessfulClickChangesProvider() {
when(mWvusWrapper.getValidWebViewApplicationInfos(any())).thenReturn(Arrays.asList(createApplicationInfo(DEFAULT_PACKAGE_NAME)));
when(mWvusWrapper.setWebViewProvider(eq(DEFAULT_PACKAGE_NAME))).thenReturn(true);
RadioButtonPreference defaultPackagePref = mock(RadioButtonPreference.class);
when(defaultPackagePref.getKey()).thenReturn(DEFAULT_PACKAGE_NAME);
mPicker.onRadioButtonClicked(defaultPackagePref);
verify(mWvusWrapper, times(1)).setWebViewProvider(eq(DEFAULT_PACKAGE_NAME));
verify(mPicker, times(1)).updateCheckedState(DEFAULT_PACKAGE_NAME);
verify(mWvusWrapper, never()).showInvalidChoiceToast(any());
}
use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by crdroidandroid.
the class DefaultAppPickerFragmentTest method clickPreference_hasConfirmation_shouldShowConfirmation.
@Test
public void clickPreference_hasConfirmation_shouldShowConfirmation() {
mFragment.onAttach((Context) mActivity);
final RadioButtonPreference pref = new RadioButtonPreference(RuntimeEnvironment.application);
pref.setKey("TEST");
doReturn("confirmation_text").when(mFragment).getConfirmationMessage(any(DefaultAppInfo.class));
doReturn(mActivity).when(mFragment).getActivity();
mFragment.onRadioButtonClicked(pref);
}
Aggregations