diff options
author | Roshan Pius <rpius@google.com> | 2016-02-08 16:58:11 -0800 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2016-02-23 10:54:15 -0800 |
commit | 9d7489491984e86915b2cf4fac38a882de1c8cdb (patch) | |
tree | 054380225527faf7ae029612ed26c2e609484a99 /tests | |
parent | f3e16ca77eb3fce92ef9040de577d64103cb8b7d (diff) |
Disable all networks in supplicant
Temporary changes to test if we can disable all the networks in
supplicant conf file except the one we want to connect to.
Changes:
1. Remove all existing native enableNetwork invocations and replace
it with a single selectNetwork call in |WifiConfigStore.selectNetwork|.
selectNetwork enables the provided network and disables all others in
wpa_supplicant.
2. Enable all networks in wpa_supplicant before enabling PNO. These will
be disabled when we come out of PNO and decide to conneect to one of
them via selectNetwork.
3. Save the network status in networkHistory.txt and ignore the status
stored in wpa_supplicant.conf.
4. Some other cleanups:
a. Remove |enableNetworkWithoutBroadcast| definition/usages and
replace with |selectNetworkWithoutBroadcast|.
b. Add enableAllNetworksNative/disableAllNetworksNative methods to
just enable the network in wpa_supplicant.
c. Move all wpa_supplicant network enable/disable to a common API.
d. Fixed all the unit-test expectations.
BUG:26984166
TEST: `mmma frameworks/opt/net/wifi/tests && runtest frameworks-wifi`
Change-Id: Ib5a089f054557071ece6be25aad03b6458c0217c
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 15 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | 12 |
2 files changed, 13 insertions, 14 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index e690d6091..96790f78c 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -23,7 +23,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.anyObject; import static org.mockito.Mockito.anyString; @@ -363,7 +362,6 @@ public class WifiConfigManagerTest { @Test public void testEnableAllNetworks() throws Exception { addNetworks(); - when(mWifiNative.enableNetwork(anyInt(), anyBoolean())).thenReturn(true); for (int userId : USER_IDS) { switchUser(userId); @@ -406,6 +404,7 @@ public class WifiConfigManagerTest { // Try to select a network configuration. final WifiNative wifiNative = createNewWifiNativeMock(); + when(wifiNative.selectNetwork(config.networkId)).thenReturn(true); final boolean success = mConfigStore.selectNetwork(config, false, config.creatorUid); if (!WifiConfigurationUtil.isVisibleToAnyProfile(config, @@ -414,7 +413,7 @@ public class WifiConfigManagerTest { // nothing changed. assertFalse(success); verify(wifiNative, never()).selectNetwork(anyInt()); - verify(wifiNative, never()).enableNetwork(anyInt(), anyBoolean()); + verify(wifiNative, never()).enableNetwork(anyInt()); for (WifiConfiguration config2 : mConfiguredNetworks.valuesForAllUsers()) { assertEquals(WifiConfiguration.Status.ENABLED, config2.status); } @@ -425,10 +424,8 @@ public class WifiConfigManagerTest { assertTrue(success); verify(wifiNative).selectNetwork(config.networkId); verify(wifiNative, never()).selectNetwork(intThat(not(config.networkId))); - verify(wifiNative).enableNetwork(config.networkId, true); - verify(wifiNative, never()).enableNetwork(config.networkId, false); - verify(wifiNative, never()).enableNetwork(intThat(not(config.networkId)), - anyBoolean()); + verify(wifiNative, never()).enableNetwork(config.networkId); + verify(wifiNative, never()).enableNetwork(intThat(not(config.networkId))); for (WifiConfiguration config2 : mConfiguredNetworks.valuesForAllUsers()) { if (WifiConfigurationUtil.isVisibleToAnyProfile(config2, USER_PROFILES.get(userId)) @@ -739,8 +736,10 @@ public class WifiConfigManagerTest { if (neitherUserConfigs.contains(config)) { assertEquals(WifiConfiguration.Status.DISABLED, config.status); } else { - assertEquals(WifiConfiguration.Status.ENABLED, config.status); + // Only enabled in networkSelection. + assertTrue(config.getNetworkSelectionStatus().isNetworkEnabled()); } + } } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index c50e1da9b..332a3a3ef 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -616,13 +616,13 @@ public class WifiStateMachineTest { } private void enableNetworkAndVerifySuccess() throws Exception { - when(mWifiNative.enableNetwork(0, true)).thenReturn(true); + when(mWifiNative.selectNetwork(0)).thenReturn(true); mLooper.startAutoDispatch(); assertTrue(mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true)); mLooper.stopAutoDispatch(); - verify(mWifiNative).enableNetwork(0, true); + verify(mWifiNative).selectNetwork(0); } private void enableNetworkAndVerifyFailure() throws Exception { @@ -630,7 +630,7 @@ public class WifiStateMachineTest { assertFalse(mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true)); mLooper.stopAutoDispatch(); - verify(mWifiNative, never()).enableNetwork(anyInt(), anyBoolean()); + verify(mWifiNative, never()).selectNetwork(anyInt()); } /** @@ -748,7 +748,7 @@ public class WifiStateMachineTest { mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true); mLooper.stopAutoDispatch(); - verify(mWifiNative).enableNetwork(0, true); + verify(mWifiNative).selectNetwork(0); mWsm.sendMessage(WifiMonitor.NETWORK_CONNECTION_EVENT, 0, 0, sBSSID); mLooper.dispatchAll(); @@ -783,7 +783,7 @@ public class WifiStateMachineTest { mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true); mLooper.stopAutoDispatch(); - verify(mWifiNative).enableNetwork(0, true); + verify(mWifiNative).selectNetwork(0); mWsm.sendMessage(WifiMonitor.NETWORK_CONNECTION_EVENT, 0, 0, sBSSID); mLooper.dispatchAll(); @@ -812,7 +812,7 @@ public class WifiStateMachineTest { mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true); mLooper.stopAutoDispatch(); - verify(mWifiNative).enableNetwork(0, true); + verify(mWifiNative).selectNetwork(0); mWsm.sendMessage(WifiMonitor.NETWORK_DISCONNECTION_EVENT, 0, 0, sBSSID); mLooper.dispatchAll(); |