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);
}
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());
}
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);
}
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;
}
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);
}
Aggregations