diff options
author | Randy Pan <zpan@google.com> | 2016-11-15 18:02:15 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-11-15 18:02:15 +0000 |
commit | 7fc06081539bbfdc51aee58698e73bf8cb933a5a (patch) | |
tree | 64e11edfb4ef5dd44d4014410a45b242bcb8bd00 /tests | |
parent | b98623f8491bc0690f8f7ea723b8df78e50dc499 (diff) | |
parent | 2c698ca1d1b0460f61c84373a5a1f96e07e6a28b (diff) |
Merge "WifiConfigManager: partial scan channel list"
am: 2c698ca1d1
Change-Id: I895d5a9bdf013122d1f4e750067b58672c86a20d
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 70 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java | 12 |
2 files changed, 57 insertions, 25 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index b96d4e954..e7364b36d 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -1459,9 +1459,9 @@ public class WifiConfigManagerTest { } } - /* + /** * Verifies the creation of channel list using - * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long)}. + * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long, int)}. */ @Test public void testFetchChannelSetForNetwork() { @@ -1479,14 +1479,44 @@ public class WifiConfigManagerTest { } assertEquals(new HashSet<Integer>(Arrays.asList(TEST_FREQ_LIST)), - mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(network.networkId, 1)); + mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(network.networkId, 1, + TEST_FREQ_LIST[4])); + } + + /** + * Verifies the creation of channel list using + * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long, int)} and + * ensures that the frequenecy of the currently connected network is in the returned + * channel set. + */ + @Test + public void testFetchChannelSetForNetworkIncludeCurrentNetwork() { + WifiConfiguration network = WifiConfigurationTestUtil.createPskNetwork(); + verifyAddNetworkToWifiConfigManager(network); + + // Create 5 scan results with different bssid's & frequencies. + String test_bssid_base = "af:89:56:34:56:6"; + for (int i = 0; i < TEST_FREQ_LIST.length; i++) { + ScanDetail networkScanDetail = + createScanDetailForNetwork( + network, test_bssid_base + Integer.toString(i), 0, TEST_FREQ_LIST[i]); + assertNotNull( + mWifiConfigManager.getSavedNetworkForScanDetailAndCache(networkScanDetail)); + + } + + // Currently connected network frequency 2427 is not in the TEST_FREQ_LIST + Set<Integer> freqs = mWifiConfigManager.fetchChannelSetForNetworkForPartialScan( + network.networkId, 1, 2427); + + assertEquals(true, freqs.contains(2427)); } /** * Verifies the creation of channel list using - * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long)} and ensures - * that scan results which have a timestamp beyond the provided age are not used in the - * channel list. + * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long, int)} and + * ensures that scan results which have a timestamp beyond the provided age are not used + * in the channel list. */ @Test public void testFetchChannelSetForNetworkIgnoresStaleScanResults() { @@ -1515,13 +1545,13 @@ public class WifiConfigManagerTest { TEST_FREQ_LIST, TEST_FREQ_LIST.length - ageInMillis, TEST_FREQ_LIST.length))), mWifiConfigManager.fetchChannelSetForNetworkForPartialScan( - network.networkId, ageInMillis)); + network.networkId, ageInMillis, TEST_FREQ_LIST[4])); } /** * Verifies the creation of channel list using - * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long)} and ensures - * that the list size does not exceed the max configured for the device. + * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long, int)} and + * ensures that the list size does not exceed the max configured for the device. */ @Test public void testFetchChannelSetForNetworkIsLimitedToConfiguredSize() { @@ -1549,13 +1579,13 @@ public class WifiConfigManagerTest { // Ensure that the fetched list size is limited. assertEquals(maxListSize, mWifiConfigManager.fetchChannelSetForNetworkForPartialScan( - network.networkId, 1).size()); + network.networkId, 1, TEST_FREQ_LIST[4]).size()); } /** * Verifies the creation of channel list using - * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long)} and ensures - * that scan results from linked networks are used in the channel list. + * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long, int)} and + * ensures that scan results from linked networks are used in the channel list. */ @Test public void testFetchChannelSetForNetworkIncludesLinkedNetworks() { @@ -1594,16 +1624,18 @@ public class WifiConfigManagerTest { // The channel list fetched should include scan results from both the linked networks. assertEquals(new HashSet<Integer>(Arrays.asList(TEST_FREQ_LIST)), - mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(network1.networkId, 1)); + mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(network1.networkId, 1, + TEST_FREQ_LIST[0])); assertEquals(new HashSet<Integer>(Arrays.asList(TEST_FREQ_LIST)), - mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(network2.networkId, 1)); + mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(network2.networkId, 1, + TEST_FREQ_LIST[0])); } /** * Verifies the creation of channel list using - * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long)} and ensures - * that scan results from linked networks are used in the channel list and that the list size - * does not exceed the max configured for the device. + * {@link WifiConfigManager#fetchChannelSetForNetworkForPartialScan(int, long, int)} and + * ensures that scan results from linked networks are used in the channel list and that the + * list size does not exceed the max configured for the device. */ @Test public void testFetchChannelSetForNetworkIncludesLinkedNetworksIsLimitedToConfiguredSize() { @@ -1651,10 +1683,10 @@ public class WifiConfigManagerTest { // Ensure that the fetched list size is limited. assertEquals(maxListSize, mWifiConfigManager.fetchChannelSetForNetworkForPartialScan( - network1.networkId, 1).size()); + network1.networkId, 1, TEST_FREQ_LIST[0]).size()); assertEquals(maxListSize, mWifiConfigManager.fetchChannelSetForNetworkForPartialScan( - network2.networkId, 1).size()); + network2.networkId, 1, TEST_FREQ_LIST[0]).size()); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index 887895c71..9e52eb229 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -804,8 +804,8 @@ public class WifiConnectivityManagerTest { when(mWifiStateMachine.getCurrentWifiConfiguration()) .thenReturn(new WifiConfiguration()); - when(mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(anyInt(), anyInt())) - .thenReturn(channelList); + when(mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(anyInt(), anyInt(), + anyInt())).thenReturn(channelList); doAnswer(new AnswerWithArguments() { public void answer(ScanSettings settings, ScanListener listener, @@ -843,8 +843,8 @@ public class WifiConnectivityManagerTest { when(mWifiStateMachine.getCurrentWifiConfiguration()) .thenReturn(new WifiConfiguration()); - when(mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(anyInt(), anyInt())) - .thenReturn(channelList); + when(mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(anyInt(), anyInt(), + anyInt())).thenReturn(channelList); doAnswer(new AnswerWithArguments() { public void answer(ScanSettings settings, ScanListener listener, @@ -882,8 +882,8 @@ public class WifiConnectivityManagerTest { when(mWifiStateMachine.getCurrentWifiConfiguration()) .thenReturn(new WifiConfiguration()); - when(mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(anyInt(), anyInt())) - .thenReturn(channelList); + when(mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(anyInt(), anyInt(), + anyInt())).thenReturn(channelList); doAnswer(new AnswerWithArguments() { public void answer(ScanSettings settings, ScanListener listener, |