use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by LineageOS.
the class WebViewAppPickerTest method testDisabledPackageShownAsDisabled.
@Test
public void testDisabledPackageShownAsDisabled() {
String disabledReason = "disabled";
DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mPackageManager, createApplicationInfo(DEFAULT_PACKAGE_NAME), disabledReason);
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)).setEnabled(eq(false));
verify(mockPreference, never()).setEnabled(eq(true));
}
use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by LineageOS.
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();
}
use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by LineageOS.
the class NetworkScorerPickerTest method testUpdateCandidates_validScorer.
@Test
public void testUpdateCandidates_validScorer() {
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE_1, TEST_SCORER_CLASS_1);
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(0, scorer, TEST_SCORER_LABEL_1, null, /* enableUseOpenWifiActivity */
null);
when(mNetworkScoreManager.getAllValidScorers()).thenReturn(Lists.newArrayList(scorerAppData));
when(mNetworkScoreManager.getActiveScorerPackage()).thenReturn(TEST_SCORER_PACKAGE_1);
ArgumentCaptor<RadioButtonPreference> arg = ArgumentCaptor.forClass(RadioButtonPreference.class);
mFragment.updateCandidates();
// The first preference added is the "none" preference and the second is the
// pref for the test scorer.
verify(mPreferenceScreen, times(2)).addPreference(arg.capture());
// Returns the last captured value which is expected to be the test scorer pref.
RadioButtonPreference pref = arg.getValue();
assertThat(pref.getTitle()).isEqualTo(TEST_SCORER_LABEL_1);
assertThat(pref.isChecked()).isTrue();
}
use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
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 omnirom.
the class NetworkScorerPickerTest method testOnRadioButtonClicked_success.
@Test
public void testOnRadioButtonClicked_success() {
RadioButtonPreference pref = new RadioButtonPreference(mContext);
pref.setKey(TEST_SCORER_PACKAGE_1);
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_2);
mFragment.onRadioButtonClicked(pref);
verify(mNetworkScoreManager).setActiveScorer(TEST_SCORER_PACKAGE_1);
assertThat(pref.isChecked()).isTrue();
}
Aggregations