diff options
author | Randy Pan <zpan@google.com> | 2016-10-03 13:41:25 -0700 |
---|---|---|
committer | Randy Pan <zpan@google.com> | 2016-10-06 11:28:44 -0700 |
commit | 2dfadf313b3e5194d56d2fa24b9270086cda165a (patch) | |
tree | c5eef0e5a1bbfe4c66600e9c391dd4159a4dd904 /tests | |
parent | 2e4c946e15dff5a207816ea21c0c3e8d5de01f08 (diff) |
Move WifiNetworkSelector to WifiInjector
While there, move WifiInfo to be an input parameter of
WifiNetworkSelector#selectNetwork and make WifiInfo the
sole source for obtaining information of the currently
connected network.
Bug: 31383992
Test: Wifi framework unit tests
Change-Id: I107ba600165b008079cebf230865f8b2082740a8
Diffstat (limited to 'tests')
3 files changed, 19 insertions, 19 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index c952f65ff..2d3e4ce2a 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -208,7 +208,7 @@ public class WifiConnectivityManagerTest { candidateScanResult.BSSID = CANDIDATE_BSSID; candidate.getNetworkSelectionStatus().setCandidate(candidateScanResult); - when(ns.selectNetwork(anyObject(), anyBoolean(), anyBoolean(), + when(ns.selectNetwork(anyObject(), anyObject(), anyBoolean(), anyBoolean(), anyBoolean())).thenReturn(candidate); return ns; } @@ -491,7 +491,7 @@ public class WifiConnectivityManagerTest { */ @Test public void pnoRetryForLowRssiNetwork() { - when(mWifiNS.selectNetwork(anyObject(), anyBoolean(), anyBoolean(), + when(mWifiNS.selectNetwork(anyObject(), anyObject(), anyBoolean(), anyBoolean(), anyBoolean())).thenReturn(null); // Set screen to off @@ -546,7 +546,7 @@ public class WifiConnectivityManagerTest { @Test public void watchdogBitePnoGoodIncrementsMetrics() { // Qns returns no candidate after watchdog single scan. - when(mWifiNS.selectNetwork(anyObject(), anyBoolean(), anyBoolean(), + when(mWifiNS.selectNetwork(anyObject(), anyObject(), anyBoolean(), anyBoolean(), anyBoolean())).thenReturn(null); // Set screen to off diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java index a03e17457..5a1645915 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java @@ -55,8 +55,7 @@ public class WifiNetworkSelectorTest { mWifiConfigManager = getWifiConfigManager(); mWifiInfo = getWifiInfo(); - mWifiNetworkSelector = new WifiNetworkSelector(mContext, mWifiConfigManager, - mWifiInfo, mClock); + mWifiNetworkSelector = new WifiNetworkSelector(mContext, mWifiConfigManager, mClock); mWifiNetworkSelector.registerNetworkEvaluator(mDummyEvaluator, 1); when(mClock.getElapsedSinceBootMillis()).thenReturn(SystemClock.elapsedRealtime()); @@ -199,7 +198,7 @@ public class WifiNetworkSelectorTest { freqs, caps, levels, securities, mWifiConfigManager, mClock); List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails(); WifiConfiguration candidate = mWifiNetworkSelector.selectNetwork(scanDetails, - false, true, false); + mWifiInfo, false, true, false); assertEquals("Expect null configuration", null, candidate); } @@ -227,7 +226,7 @@ public class WifiNetworkSelectorTest { freqs, caps, levels, securities, mWifiConfigManager, mClock); List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails(); WifiConfiguration candidate = mWifiNetworkSelector.selectNetwork(scanDetails, - false, true, false); + mWifiInfo, false, true, false); assertEquals("Expect null configuration", null, candidate); } @@ -256,14 +255,14 @@ public class WifiNetworkSelectorTest { freqs, caps, levels, securities, mWifiConfigManager, mClock); List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails(); WifiConfiguration candidate = mWifiNetworkSelector.selectNetwork(scanDetails, - false, true, false); + mWifiInfo, false, true, false); when(mClock.getElapsedSinceBootMillis()).thenReturn(SystemClock.elapsedRealtime() + WifiNetworkSelector.MINIMUM_NETWORK_SELECTION_INTERVAL_MS - 2000); // Do another network selection with WSM in CONNECTED state. candidate = mWifiNetworkSelector.selectNetwork(scanDetails, - true, false, false); + mWifiInfo, true, false, false); assertEquals("Expect null configuration", null, candidate); } @@ -294,14 +293,14 @@ public class WifiNetworkSelectorTest { List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails(); WifiConfiguration[] savedConfigs = scanDetailsAndConfigs.getWifiConfigs(); WifiConfiguration candidate = mWifiNetworkSelector.selectNetwork(scanDetails, - false, true, false); + mWifiInfo, false, true, false); when(mClock.getElapsedSinceBootMillis()).thenReturn(SystemClock.elapsedRealtime() + WifiNetworkSelector.MINIMUM_NETWORK_SELECTION_INTERVAL_MS - 2000); // Do another network selection with WSM in DISCONNECTED state. candidate = mWifiNetworkSelector.selectNetwork(scanDetails, - false, true, false); + mWifiInfo, false, true, false); ScanResult chosenScanResult = scanDetails.get(0).getScanResult(); WifiConfigurationTestUtil.assertConfigurationEqual(savedConfigs[0], candidate); @@ -333,7 +332,7 @@ public class WifiNetworkSelectorTest { List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails(); // connect to test1 - mWifiNetworkSelector.selectNetwork(scanDetails, false, true, false); + mWifiNetworkSelector.selectNetwork(scanDetails, mWifiInfo, false, true, false); when(mWifiInfo.getNetworkId()).thenReturn(0); when(mWifiInfo.getBSSID()).thenReturn(bssids[0]); when(mWifiInfo.is24GHz()).thenReturn(false); @@ -348,7 +347,7 @@ public class WifiNetworkSelectorTest { scanDetails = scanDetailsAndConfigs.getScanDetails(); WifiConfiguration candidate = mWifiNetworkSelector.selectNetwork(scanDetails, - true, false, false); + mWifiInfo, true, false, false); assertEquals("Expect null configuration", null, candidate); } @@ -379,7 +378,7 @@ public class WifiNetworkSelectorTest { WifiConfiguration[] savedConfigs = scanDetailsAndConfigs.getWifiConfigs(); // connect to test1 - mWifiNetworkSelector.selectNetwork(scanDetails, false, true, false); + mWifiNetworkSelector.selectNetwork(scanDetails, mWifiInfo, false, true, false); when(mWifiInfo.getNetworkId()).thenReturn(0); when(mWifiInfo.getBSSID()).thenReturn(bssids[0]); when(mWifiInfo.is24GHz()).thenReturn(true); @@ -389,7 +388,7 @@ public class WifiNetworkSelectorTest { // Do another network selection. WifiConfiguration candidate = mWifiNetworkSelector.selectNetwork(scanDetails, - true, false, false); + mWifiInfo, true, false, false); ScanResult chosenScanResult = scanDetails.get(0).getScanResult(); WifiConfigurationTestUtil.assertConfigurationEqual(savedConfigs[0], candidate); @@ -424,7 +423,7 @@ public class WifiNetworkSelectorTest { WifiConfiguration[] savedConfigs = scanDetailsAndConfigs.getWifiConfigs(); // connect to test1 - mWifiNetworkSelector.selectNetwork(scanDetails, false, true, false); + mWifiNetworkSelector.selectNetwork(scanDetails, mWifiInfo, false, true, false); when(mWifiInfo.getNetworkId()).thenReturn(0); when(mWifiInfo.getBSSID()).thenReturn(bssids[0]); when(mWifiInfo.is24GHz()).thenReturn(false); @@ -435,7 +434,7 @@ public class WifiNetworkSelectorTest { // Do another network selection. WifiConfiguration candidate = mWifiNetworkSelector.selectNetwork(scanDetails, - true, false, false); + mWifiInfo, true, false, false); ScanResult chosenScanResult = scanDetails.get(0).getScanResult(); WifiConfigurationTestUtil.assertConfigurationEqual(savedConfigs[0], candidate); @@ -469,7 +468,7 @@ public class WifiNetworkSelectorTest { WifiConfiguration[] savedConfigs = scanDetailsAndConfigs.getWifiConfigs(); // connect to test1 - mWifiNetworkSelector.selectNetwork(scanDetails, false, true, false); + mWifiNetworkSelector.selectNetwork(scanDetails, mWifiInfo, false, true, false); when(mWifiInfo.getNetworkId()).thenReturn(0); when(mWifiInfo.getBSSID()).thenReturn(bssids[0]); when(mWifiInfo.is24GHz()).thenReturn(false); @@ -481,7 +480,7 @@ public class WifiNetworkSelectorTest { // Do another network selection. WifiConfiguration candidate = mWifiNetworkSelector.selectNetwork(scanDetails, - true, false, false); + mWifiInfo, true, false, false); ScanResult chosenScanResult = scanDetails.get(0).getScanResult(); WifiConfigurationTestUtil.assertConfigurationEqual(savedConfigs[0], candidate); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 24f383a1d..9de360812 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -340,6 +340,7 @@ public class WifiStateMachineTest { when(mWifiInjector.getWifiConfigManager()).thenReturn(mWifiConfigManager); when(mWifiInjector.getWifiSupplicantControl()).thenReturn(mWifiSupplicantControl); when(mWifiInjector.getWifiScanner()).thenReturn(mWifiScanner); + when(mWifiInjector.getWifiNetworkSelector()).thenReturn(mock(WifiNetworkSelector.class)); when(mWifiNative.getInterfaceName()).thenReturn("mockWlan"); when(mWifiSupplicantControl.getFrameworkNetworkId(anyInt())).thenReturn(0); |