Search in sources :

Example 26 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class WifiNetworkListFragmentTest method onSavedWifiEntriesChanged_openSavedWifiEntry_onlyAddNetworkPreference.

@Test
public void onSavedWifiEntriesChanged_openSavedWifiEntry_onlyAddNetworkPreference() {
    final WifiEntry wifiEntry = mock(WifiEntry.class);
    when(wifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_NONE);
    when(mWifiNetworkListFragment.mSavedNetworkTracker.getSavedWifiEntries()).thenReturn(Arrays.asList(wifiEntry));
    mWifiNetworkListFragment.onSavedWifiEntriesChanged();
    verify(mWifiNetworkListFragment.mPreferenceGroup).addPreference(mWifiNetworkListFragment.mAddPreference);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Test(org.junit.Test)

Example 27 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class WifiNetworkListFragmentTest method onSavedWifiEntriesChanged_pskSavedWifiEntry_add2Preferences.

@Test
public void onSavedWifiEntriesChanged_pskSavedWifiEntry_add2Preferences() {
    final WifiEntry wifiEntry = mock(WifiEntry.class);
    when(wifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_PSK);
    when(mWifiNetworkListFragment.mSavedNetworkTracker.getSavedWifiEntries()).thenReturn(Arrays.asList(wifiEntry));
    mWifiNetworkListFragment.onSavedWifiEntriesChanged();
    verify(mWifiNetworkListFragment.mPreferenceGroup, times(2)).addPreference(any());
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Test(org.junit.Test)

Example 28 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class NetworkRequestDialogFragmentTest method onMatchManyResult_showNeutralButton.

@Test
public void onMatchManyResult_showNeutralButton() {
    networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */
    null);
    final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    List<WifiEntry> wifiEntryList = createWifiEntryList();
    final WifiPickerTracker wifiPickerTracker = mock(WifiPickerTracker.class);
    when(wifiPickerTracker.getWifiEntries()).thenReturn(wifiEntryList);
    networkRequestDialogFragment.mWifiPickerTracker = wifiPickerTracker;
    final String ssidAp = "Test AP ";
    final List<ScanResult> scanResults = new ArrayList<>();
    for (int i = 0; i < 7; i++) {
        ScanResult scanResult = mock(ScanResult.class);
        scanResult.SSID = ssidAp + i;
        scanResult.capabilities = "WEP";
        scanResults.add(scanResult);
    }
    networkRequestDialogFragment.onMatch(scanResults);
    final Button button = alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
    assertThat(button).isNotNull();
    assertThat(button.getVisibility()).isEqualTo(View.VISIBLE);
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ScanResult(android.net.wifi.ScanResult) Button(android.widget.Button) WifiPickerTracker(com.android.wifitrackerlib.WifiPickerTracker) WifiEntry(com.android.wifitrackerlib.WifiEntry) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 29 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class NetworkRequestDialogFragmentTest method createWifiEntryList.

private List<WifiEntry> createWifiEntryList() {
    List<WifiEntry> wifiEntryList = spy(new ArrayList<>());
    final WifiEntry wifiEntry1 = mock(WifiEntry.class);
    when(wifiEntry1.getSsid()).thenReturn("Test AP 1");
    when(wifiEntry1.getSecurity()).thenReturn(WifiEntry.SECURITY_WEP);
    wifiEntryList.add(wifiEntry1);
    final WifiEntry wifiEntry2 = mock(WifiEntry.class);
    when(wifiEntry2.getSsid()).thenReturn("Test AP 2");
    when(wifiEntry2.getSecurity()).thenReturn(WifiEntry.SECURITY_WEP);
    wifiEntryList.add(wifiEntry2);
    final WifiEntry wifiEntry3 = mock(WifiEntry.class);
    when(wifiEntry3.getSsid()).thenReturn("Test AP 3");
    when(wifiEntry3.getSecurity()).thenReturn(WifiEntry.SECURITY_WEP);
    wifiEntryList.add(wifiEntry3);
    final WifiEntry wifiEntry4 = mock(WifiEntry.class);
    when(wifiEntry4.getSsid()).thenReturn("Test AP 4");
    when(wifiEntry4.getSecurity()).thenReturn(WifiEntry.SECURITY_NONE);
    wifiEntryList.add(wifiEntry4);
    final WifiEntry wifiEntry5 = mock(WifiEntry.class);
    when(wifiEntry5.getSsid()).thenReturn("Test AP 5");
    when(wifiEntry5.getSecurity()).thenReturn(WifiEntry.SECURITY_WEP);
    wifiEntryList.add(wifiEntry5);
    final WifiEntry wifiEntry6 = mock(WifiEntry.class);
    when(wifiEntry6.getSsid()).thenReturn("Test AP 6");
    when(wifiEntry6.getSecurity()).thenReturn(WifiEntry.SECURITY_WEP);
    wifiEntryList.add(wifiEntry6);
    return wifiEntryList;
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry)

Example 30 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class WifiScanWorker method updateResults.

@VisibleForTesting
void updateResults() {
    if (mWifiPickerTracker.getWifiState() != WifiManager.WIFI_STATE_ENABLED || mLifecycleRegistry.getCurrentState() != Lifecycle.State.RESUMED) {
        super.updateResults(null);
        return;
    }
    final List<WifiSliceItem> resultList = new ArrayList<>();
    final WifiEntry connectedWifiEntry = mWifiPickerTracker.getConnectedWifiEntry();
    if (connectedWifiEntry != null) {
        connectedWifiEntry.setListener(this);
        resultList.add(new WifiSliceItem(getContext(), connectedWifiEntry));
    }
    for (WifiEntry wifiEntry : mWifiPickerTracker.getWifiEntries()) {
        if (resultList.size() >= getApRowCount()) {
            break;
        }
        if (wifiEntry.getLevel() != WifiEntry.WIFI_LEVEL_UNREACHABLE) {
            wifiEntry.setListener(this);
            resultList.add(new WifiSliceItem(getContext(), wifiEntry));
        }
    }
    super.updateResults(resultList);
}
Also used : ArrayList(java.util.ArrayList) WifiEntry(com.android.wifitrackerlib.WifiEntry) VisibleForTesting(androidx.annotation.VisibleForTesting)

Aggregations

WifiEntry (com.android.wifitrackerlib.WifiEntry)54 Test (org.junit.Test)28 WifiConfiguration (android.net.wifi.WifiConfiguration)10 WifiEntryPreference (com.android.settingslib.wifi.WifiEntryPreference)10 LongPressWifiEntryPreference (com.android.settingslib.wifi.LongPressWifiEntryPreference)8 Intent (android.content.Intent)7 Preference (androidx.preference.Preference)5 Context (android.content.Context)4 Bundle (android.os.Bundle)4 DataUsagePreference (com.android.settings.datausage.DataUsagePreference)4 WifiManager (android.net.wifi.WifiManager)3 Handler (android.os.Handler)3 View (android.view.View)3 FragmentActivity (androidx.fragment.app.FragmentActivity)3 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)3 AddWifiNetworkPreference (com.android.settings.wifi.AddWifiNetworkPreference)3 ConnectedWifiEntryPreference (com.android.settings.wifi.ConnectedWifiEntryPreference)3 FooterPreference (com.android.settingslib.widget.FooterPreference)3 LayoutPreference (com.android.settingslib.widget.LayoutPreference)3 ArrayList (java.util.ArrayList)3