Search in sources :

Example 41 with NetworkScorerAppData

use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by DirtyUnicorns.

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));
}
Also used : Preference(android.support.v7.preference.Preference) ComponentName(android.content.ComponentName) NetworkScorerAppData(android.net.NetworkScorerAppData) Test(org.junit.Test)

Example 42 with NetworkScorerAppData

use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by DirtyUnicorns.

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();
}
Also used : ComponentName(android.content.ComponentName) NetworkScorerAppData(android.net.NetworkScorerAppData) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 43 with NetworkScorerAppData

use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by DirtyUnicorns.

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();
}
Also used : ComponentName(android.content.ComponentName) NetworkScorerAppData(android.net.NetworkScorerAppData) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 44 with NetworkScorerAppData

use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by DirtyUnicorns.

the class UseOpenWifiPreferenceController method checkForFeatureSupportedScorers.

private void checkForFeatureSupportedScorers() {
    if (mEnableUseWifiComponentName != null) {
        mDoFeatureSupportedScorersExist = true;
        return;
    }
    List<NetworkScorerAppData> scorers = mNetworkScoreManagerWrapper.getAllValidScorers();
    for (NetworkScorerAppData scorer : scorers) {
        if (scorer.getEnableUseOpenWifiActivity() != null) {
            mDoFeatureSupportedScorersExist = true;
            return;
        }
    }
    mDoFeatureSupportedScorersExist = false;
}
Also used : NetworkScorerAppData(android.net.NetworkScorerAppData)

Example 45 with NetworkScorerAppData

use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by crdroidandroid.

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();
}
Also used : ComponentName(android.content.ComponentName) NetworkScorerAppData(android.net.NetworkScorerAppData) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Aggregations

NetworkScorerAppData (android.net.NetworkScorerAppData)64 ComponentName (android.content.ComponentName)36 Test (org.junit.Test)35 RadioButtonPreference (com.android.settings.widget.RadioButtonPreference)21 Preference (android.support.v7.preference.Preference)18 VisibleForTesting (android.support.annotation.VisibleForTesting)6 PreferenceScreen (android.support.v7.preference.PreferenceScreen)6 Preference (androidx.preference.Preference)3 VisibleForTesting (androidx.annotation.VisibleForTesting)1 PreferenceScreen (androidx.preference.PreferenceScreen)1 BeforeClass (org.junit.BeforeClass)1