summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-05-24 05:58:48 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-05-24 05:58:48 -0700
commita5c0213748bbc421c1d181fb208dc1d67067d96b (patch)
tree769e00fd50a58ed7d41d279fd592306b5171ed54 /tests
parent171703f4aea6e1053cb6f059f518e2e0b6b7b18b (diff)
parent78692bc45d5aa39d1cf299ccd5b7635c351ed48a (diff)
Merge "WifiNetworkSelector: Clear all configured network status" into qt-dev am: 080083b69d am: 101541ac8a
am: 78692bc45d Change-Id: I928e91c06b6fbf5982c2fbb3362268921664645f
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java52
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java4
2 files changed, 47 insertions, 9 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
index cda5d626b..53dae5229 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
@@ -167,13 +167,19 @@ public class WifiNetworkSelectorTest {
if (!mEvaluatorShouldSelectCandidate) {
return null;
}
- ScanDetail scanDetail = scanDetails.get(mNetworkIndexToReturn);
- mWifiConfigManager.setNetworkCandidateScanResult(0, scanDetail.getScanResult(), 100);
- WifiConfiguration config =
- mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(scanDetail);
- assertNotNull("Saved network must not be null", config);
- onConnectableListener.onConnectable(scanDetail, config, 100);
- return config;
+ for (ScanDetail scanDetail : scanDetails) {
+ WifiConfiguration config =
+ mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(scanDetail);
+ mWifiConfigManager.setNetworkCandidateScanResult(
+ config.networkId, scanDetail.getScanResult(), 100);
+ }
+ ScanDetail scanDetailToReturn = scanDetails.get(mNetworkIndexToReturn);
+ WifiConfiguration configToReturn =
+ mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(
+ scanDetailToReturn);
+ assertNotNull("Saved network must not be null", configToReturn);
+ onConnectableListener.onConnectable(scanDetailToReturn, configToReturn, 100);
+ return configToReturn;
}
}
@@ -540,6 +546,38 @@ public class WifiNetworkSelectorTest {
}
/**
+ * Ensure that network selector update's network selection status for all configured
+ * networks before performing network selection.
+ *
+ * Expected behavior: the first network is recommended by Network Selector
+ */
+ @Test
+ public void updateConfiguredNetworks() {
+ String[] ssids = {"\"test1\"", "\"test2\""};
+ String[] bssids = {"6c:f3:7f:ae:8c:f3", "6c:f3:7f:ae:8c:f4"};
+ int[] freqs = {2437, 2457};
+ String[] caps = {"[WPA2-EAP-CCMP][ESS]", "[WPA2-PSK][ESS]"};
+ int[] levels = {mThresholdMinimumRssi2G + 20, mThresholdMinimumRssi2G + RSSI_BUMP};
+ int[] securities = {SECURITY_EAP, SECURITY_PSK};
+
+ ScanDetailsAndWifiConfigs scanDetailsAndConfigs =
+ WifiNetworkSelectorTestUtil.setupScanDetailsAndConfigStore(ssids, bssids,
+ freqs, caps, levels, securities, mWifiConfigManager, mClock);
+ List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails();
+ HashSet<String> blacklist = new HashSet<String>();
+ WifiConfiguration[] savedConfigs = scanDetailsAndConfigs.getWifiConfigs();
+
+ // Do network selection.
+ mWifiNetworkSelector.selectNetwork(scanDetails,
+ blacklist, mWifiInfo, true, false, false);
+
+ verify(mWifiConfigManager).getConfiguredNetworks();
+ verify(mWifiConfigManager, times(savedConfigs.length)).tryEnableNetwork(anyInt());
+ verify(mWifiConfigManager, times(savedConfigs.length))
+ .clearNetworkCandidateScanResult(anyInt());
+ }
+
+ /**
* Blacklisted BSSID is filtered out for network selection.
*
* ClientModeImpl is disconnected.
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java
index 4f795ad03..74d6cb747 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java
@@ -218,9 +218,9 @@ public class WifiNetworkSelectorTestUtil {
return null;
}
});
- when(wifiConfigManager.getSavedNetworks(anyInt()))
+ when(wifiConfigManager.getConfiguredNetworks())
.then(new AnswerWithArguments() {
- public List<WifiConfiguration> answer(int uid) {
+ public List<WifiConfiguration> answer() {
List<WifiConfiguration> savedNetworks = new ArrayList<>();
for (int netId = 0; netId < configs.length; netId++) {
savedNetworks.add(new WifiConfiguration(configs[netId]));