summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-07-17 16:47:13 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-07-17 16:47:13 +0000
commit0b23b1445f2f45a4e1c2c466dfb9ec0788634715 (patch)
tree75edb830a867a10dcaf12673eb4ae0817e2e555d /tests
parent654ba3541b834d8e4d0516842dd0dc591b8344a7 (diff)
parentacf2243b213c160eeeed47e88a688f40f394417f (diff)
Merge "WifiConfigManager: Method to remove all transient networks" into oc-dr1-dev am: c9f254bcdf
am: acf2243b21 Change-Id: I69249e9f7f04c3664ef06be81a100e3cb50d4934
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java34
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java11
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();
+ }
}