use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by crdroidandroid.
the class NetworkScorerPickerPreferenceControllerTest method updateState_scorersAvailable_noActiveScorer_preferenceSetSummaryToNone.
@Test
public void updateState_scorersAvailable_noActiveScorer_preferenceSetSummaryToNone() {
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE, TEST_SCORER_CLASS);
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(0, scorer, TEST_SCORER_LABEL, null, /* enableUseOpenWifiActivity */
null);
when(mNetworkScorer.getAllValidScorers()).thenReturn(Collections.singletonList(scorerAppData));
when(mNetworkScorer.getActiveScorer()).thenReturn(null);
Preference preference = mock(Preference.class);
mController.updateState(preference);
verify(preference).setSummary(mContext.getString(R.string.network_scorer_picker_none_preference));
}
use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by crdroidandroid.
the class NetworkScorerPickerPreferenceControllerTest method updateState_scorersAvailable_preferenceEnabled.
@Test
public void updateState_scorersAvailable_preferenceEnabled() {
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE, TEST_SCORER_CLASS);
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(0, scorer, TEST_SCORER_LABEL, null, /* enableUseOpenWifiActivity */
null);
when(mNetworkScorer.getAllValidScorers()).thenReturn(Collections.singletonList(scorerAppData));
Preference preference = mock(Preference.class);
mController.updateState(preference);
verify(preference).setEnabled(true);
}
use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by crdroidandroid.
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 android.net.NetworkScorerAppData in project android_packages_apps_Settings by crdroidandroid.
the class NetworkScorerPicker method updateCandidates.
@VisibleForTesting
public void updateCandidates() {
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
final List<NetworkScorerAppData> scorers = mNetworkScoreManager.getAllValidScorers();
final String defaultAppKey = getActiveScorerPackage();
final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
nonePref.setTitle(R.string.network_scorer_picker_none_preference);
if (scorers.isEmpty()) {
nonePref.setChecked(true);
} else {
nonePref.setKey(null);
nonePref.setChecked(TextUtils.isEmpty(defaultAppKey));
nonePref.setOnClickListener(this);
}
screen.addPreference(nonePref);
final int numScorers = scorers.size();
for (int i = 0; i < numScorers; i++) {
final RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
final NetworkScorerAppData appData = scorers.get(i);
final String appKey = appData.getRecommendationServicePackageName();
pref.setTitle(appData.getRecommendationServiceLabel());
pref.setKey(appKey);
pref.setChecked(TextUtils.equals(defaultAppKey, appKey));
pref.setOnClickListener(this);
screen.addPreference(pref);
}
}
use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by SudaMod.
the class NetworkScorerPickerPreferenceControllerTest method updateState_scorersAvailable_noActiveScorer_preferenceSetSummaryToNone.
@Test
public void updateState_scorersAvailable_noActiveScorer_preferenceSetSummaryToNone() {
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE, TEST_SCORER_CLASS);
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(0, scorer, TEST_SCORER_LABEL, null, /* enableUseOpenWifiActivity */
null);
when(mNetworkScorer.getAllValidScorers()).thenReturn(Collections.singletonList(scorerAppData));
when(mNetworkScorer.getActiveScorer()).thenReturn(null);
Preference preference = mock(Preference.class);
mController.updateState(preference);
verify(preference).setSummary(mContext.getString(R.string.network_scorer_picker_none_preference));
}
Aggregations