summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2016-09-12 13:39:16 -0700
committerRoshan Pius <rpius@google.com>2016-09-16 15:34:21 -0700
commit5c6da02cf7736d4ba9fc388151177f5277464c89 (patch)
tree8e6b101252becbd1735252271dce24175cbb3846 /tests
parentfec788327369ade5d0bfb9fba080c368e8471827 (diff)
WifiConfigManagerNew: Hidden network list retrieval
Add a method to retrieve the hidden saved networks and sort this list similar to PNO scans. We want to prioritize recently/most often connected hidden networks over the others since the driver supports limited number of such networks per scan. BUG: 29503772 TEST: Added unit test. Change-Id: I86d55501edf23501552453cb3bed25654b31756a
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 4edf324df..e6132c166 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -2045,6 +2045,54 @@ public class WifiConfigManagerTest {
assertFalse(dumpString.contains(eapNetwork.enterpriseConfig.getPassword()));
}
+ /**
+ * Verifies the ordering of network list generated using
+ * {@link WifiConfigManager#retrieveHiddenNetworkList()}.
+ */
+ @Test
+ public void testRetrieveHiddenList() {
+ // Create and add 3 networks.
+ WifiConfiguration network1 = WifiConfigurationTestUtil.createWepHiddenNetwork();
+ WifiConfiguration network2 = WifiConfigurationTestUtil.createPskHiddenNetwork();
+ WifiConfiguration network3 = WifiConfigurationTestUtil.createOpenHiddenNetwork();
+ verifyAddNetworkToWifiConfigManager(network1);
+ verifyAddNetworkToWifiConfigManager(network2);
+ verifyAddNetworkToWifiConfigManager(network3);
+
+ // Enable all of them.
+ assertTrue(mWifiConfigManager.enableNetwork(network1.networkId, false, TEST_CREATOR_UID));
+ assertTrue(mWifiConfigManager.enableNetwork(network2.networkId, false, TEST_CREATOR_UID));
+ assertTrue(mWifiConfigManager.enableNetwork(network3.networkId, false, TEST_CREATOR_UID));
+
+ // Now set scan results in 2 of them to set the corresponding
+ // {@link NetworkSelectionStatus#mSeenInLastQualifiedNetworkSelection} field.
+ assertTrue(mWifiConfigManager.setNetworkCandidateScanResult(
+ network1.networkId, createScanDetailForNetwork(network1).getScanResult(), 54));
+ assertTrue(mWifiConfigManager.setNetworkCandidateScanResult(
+ network3.networkId, createScanDetailForNetwork(network3).getScanResult(), 54));
+
+ // Now increment |network3|'s association count. This should ensure that this network
+ // is preferred over |network1|.
+ assertTrue(mWifiConfigManager.updateNetworkAfterConnect(network3.networkId));
+
+ // Retrieve the hidden network list & verify the order of the networks returned.
+ List<WifiScanner.ScanSettings.HiddenNetwork> hiddenNetworks =
+ mWifiConfigManager.retrieveHiddenNetworkList();
+ assertEquals(3, hiddenNetworks.size());
+ assertEquals(network3.SSID, hiddenNetworks.get(0).ssid);
+ assertEquals(network1.SSID, hiddenNetworks.get(1).ssid);
+ assertEquals(network2.SSID, hiddenNetworks.get(2).ssid);
+
+ // Now permanently disable |network3|. This should remove network 3 from the list.
+ assertTrue(mWifiConfigManager.disableNetwork(network3.networkId, TEST_CREATOR_UID));
+
+ // Retrieve the hidden network list again & verify the order of the networks returned.
+ hiddenNetworks = mWifiConfigManager.retrieveHiddenNetworkList();
+ assertEquals(2, hiddenNetworks.size());
+ assertEquals(network1.SSID, hiddenNetworks.get(0).ssid);
+ assertEquals(network2.SSID, hiddenNetworks.get(1).ssid);
+ }
+
private void createWifiConfigManager() {
mWifiConfigManager =
new WifiConfigManager(