use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class NetworkScorerPickerTest method testUpdateCandidates_validScorers_noActiveScorer.
@Test
public void testUpdateCandidates_validScorers_noActiveScorer() {
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(null);
ArgumentCaptor<RadioButtonPreference> arg = ArgumentCaptor.forClass(RadioButtonPreference.class);
mFragment.updateCandidates();
verify(mPreferenceScreen, times(2)).addPreference(arg.capture());
final RadioButtonPreference nonePref = arg.getAllValues().get(0);
assertThat(nonePref.getKey()).isNull();
assertThat(nonePref.isChecked()).isTrue();
final RadioButtonPreference testScorerPref = arg.getAllValues().get(1);
assertThat(testScorerPref.getTitle()).isEqualTo(TEST_SCORER_LABEL_1);
assertThat(testScorerPref.isChecked()).isFalse();
}
use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
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 omnirom.
the class ChannelImportanceSettings method createPreferenceHierarchy.
private PreferenceScreen createPreferenceHierarchy() {
PreferenceScreen root = getPreferenceScreen();
if (root != null) {
root.removeAll();
}
addPreferencesFromResource(R.xml.notification_importance);
root = getPreferenceScreen();
for (int i = 0; i < root.getPreferenceCount(); i++) {
Preference pref = root.getPreference(i);
if (pref instanceof RadioButtonPreference) {
RadioButtonPreference radioPref = (RadioButtonPreference) pref;
radioPref.setOnClickListener(this);
mImportances.add(radioPref);
}
}
switch(mChannel.getImportance()) {
case IMPORTANCE_MIN:
updateRadioButtons(KEY_IMPORTANCE_MIN);
break;
case IMPORTANCE_LOW:
updateRadioButtons(KEY_IMPORTANCE_LOW);
break;
case IMPORTANCE_DEFAULT:
updateRadioButtons(KEY_IMPORTANCE_DEFAULT);
break;
case IMPORTANCE_HIGH:
case IMPORTANCE_MAX:
updateRadioButtons(KEY_IMPORTANCE_HIGH);
break;
}
return root;
}
use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class WebViewAppPickerTest method testEnabledPackageShowsEmptySummary.
@Test
public void testEnabledPackageShowsEmptySummary() {
String disabledReason = null;
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, never()).setSummary(any());
}
use of com.android.settings.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
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());
}
Aggregations