diff options
author | Roshan Pius <rpius@google.com> | 2017-07-17 16:29:47 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-07-17 16:29:47 +0000 |
commit | c9f254bcdf9a1f2b535626a85b416de56a615610 (patch) | |
tree | 6d7c779120c6f9639138914231bc7d7d68ea0c55 /tests | |
parent | 77315558f37f2ddc71ed029e262deffe0de52b70 (diff) | |
parent | e9d6e6722d8e4724b42f4c1dffa02bed05ee8b0a (diff) |
Merge "WifiConfigManager: Method to remove all transient networks" into oc-dr1-dev
Diffstat (limited to 'tests')
3 files changed, 51 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 961d9d676..aa858c822 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -2744,6 +2744,40 @@ public class WifiConfigManagerTest { } /** + * Verifies that all the ephemeral and passpoint networks are removed when + * {@link WifiConfigManager#removeAllEphemeralOrPasspointConfiguredNetworks()} is invoked. + */ + @Test + public void testRemoveAllEphemeralOrPasspointConfiguredNetworks() throws Exception { + WifiConfiguration savedOpenNetwork = WifiConfigurationTestUtil.createOpenNetwork(); + WifiConfiguration ephemeralNetwork = WifiConfigurationTestUtil.createEphemeralNetwork(); + WifiConfiguration passpointNetwork = WifiConfigurationTestUtil.createPasspointNetwork(); + + verifyAddNetworkToWifiConfigManager(savedOpenNetwork); + verifyAddEphemeralNetworkToWifiConfigManager(ephemeralNetwork); + verifyAddPasspointNetworkToWifiConfigManager(passpointNetwork); + + List<WifiConfiguration> expectedConfigsBeforeRemove = new ArrayList<WifiConfiguration>() {{ + add(savedOpenNetwork); + add(ephemeralNetwork); + add(passpointNetwork); + }}; + WifiConfigurationTestUtil.assertConfigurationsEqualForConfigManagerAddOrUpdate( + expectedConfigsBeforeRemove, mWifiConfigManager.getConfiguredNetworks()); + + assertTrue(mWifiConfigManager.removeAllEphemeralOrPasspointConfiguredNetworks()); + + List<WifiConfiguration> expectedConfigsAfterRemove = new ArrayList<WifiConfiguration>() {{ + add(savedOpenNetwork); + }}; + WifiConfigurationTestUtil.assertConfigurationsEqualForConfigManagerAddOrUpdate( + expectedConfigsAfterRemove, mWifiConfigManager.getConfiguredNetworks()); + + // No more ephemeral or passpoint networks to remove now. + assertFalse(mWifiConfigManager.removeAllEphemeralOrPasspointConfiguredNetworks()); + } + + /** * Verifies that the modification of a single network using * {@link WifiConfigManager#addOrUpdateNetwork(WifiConfiguration, int)} and ensures that any * updates to the network config in diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java index b9afce47f..62a68d47b 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java @@ -229,6 +229,12 @@ public class WifiConfigurationTestUtil { null, SECURITY_NONE); } + public static WifiConfiguration createEphemeralNetwork() { + WifiConfiguration configuration = createOpenNetwork(); + configuration.ephemeral = true; + return configuration; + } + public static WifiConfiguration createOpenHiddenNetwork() { WifiConfiguration configuration = createOpenNetwork(); configuration.hiddenSSID = true; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 52b4d3687..c91f937fe 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -2020,4 +2020,15 @@ public class WifiStateMachineTest { mLooper.dispatchAll(); verify(mWifiNative, never()).resetTxPowerLimit(); } + + /* + * Verifies that a network disconnection event will result in WifiStateMachine invoking + * {@link WifiConfigManager#removeAllEphemeralOrPasspointConfiguredNetworks()} to remove + * any ephemeral or passpoint networks from it's internal database. + */ + @Test + public void testDisconnectionRemovesEphemeralAndPasspointNetworks() throws Exception { + disconnect(); + verify(mWifiConfigManager).removeAllEphemeralOrPasspointConfiguredNetworks(); + } } |