summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2016-08-26 17:00:34 -0700
committerRoshan Pius <rpius@google.com>2016-09-01 15:02:22 -0700
commit65245230dda9f9892af4d9b6afe82ae2e46aeb96 (patch)
treea9603fe909761344fdace2366ada4ff8f2c070e8 /tests
parent96241bee619ff7073635f680a36869f61a11a225 (diff)
WifiConfigManagerNew: Integrate to WSM (Part 2)
Add methods to remove all networks for a specific user/app to be used when the either the user or app is deleted. While there, Add a bunch of setters to set various WifiConfiguration parameters in the internal configuration objects. BUG: 31009287 Change-Id: I6e159b9dd5bdcf6a18ee76db23603f42bcb7acb6 TEST: Unit tests TEST: Integrated with WSM and verified wifi connectivity.
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerNewTest.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerNewTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerNewTest.java
index a1aa158b1..119f6c744 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerNewTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerNewTest.java
@@ -19,9 +19,11 @@ package com.android.server.wifi;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
+import android.app.Application;
import android.app.test.MockAnswerUtil.AnswerWithArguments;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.net.IpConfiguration;
@@ -1879,12 +1881,52 @@ public class WifiConfigManagerNewTest {
assertTrue(mWifiConfigManager.enableNetwork(
result.getNetworkId(), true, TEST_CREATOR_UID));
assertEquals(result.getNetworkId(), mWifiConfigManager.getLastSelectedNetwork());
+ assertEquals(openNetwork.configKey(), mWifiConfigManager.getLastSelectedNetworkConfigKey());
assertTrue(mWifiConfigManager.removeNetwork(result.getNetworkId(), TEST_CREATOR_UID));
assertEquals(
WifiConfiguration.INVALID_NETWORK_ID, mWifiConfigManager.getLastSelectedNetwork());
}
+ /**
+ * Verifies that all the networks for the provided app is removed when
+ * {@link WifiConfigManagerNew#removeNetworksForApp(ApplicationInfo)} is invoked.
+ */
+ @Test
+ public void testRemoveNetworksForApp() throws Exception {
+ verifyAddNetworkToWifiConfigManager(WifiConfigurationTestUtil.createOpenNetwork());
+ verifyAddNetworkToWifiConfigManager(WifiConfigurationTestUtil.createPskNetwork());
+ verifyAddNetworkToWifiConfigManager(WifiConfigurationTestUtil.createWepNetwork());
+
+ assertFalse(mWifiConfigManager.getConfiguredNetworks().isEmpty());
+
+ ApplicationInfo app = new ApplicationInfo();
+ app.uid = TEST_CREATOR_UID;
+ app.packageName = TEST_CREATOR_NAME;
+ assertTrue(mWifiConfigManager.removeNetworksForApp(app));
+
+ // Ensure all the networks are removed now.
+ assertTrue(mWifiConfigManager.getConfiguredNetworks().isEmpty());
+ }
+
+ /**
+ * Verifies that all the networks for the provided user is removed when
+ * {@link WifiConfigManagerNew#removeNetworksForUser(int)} is invoked.
+ */
+ @Test
+ public void testRemoveNetworksForUser() throws Exception {
+ verifyAddNetworkToWifiConfigManager(WifiConfigurationTestUtil.createOpenNetwork());
+ verifyAddNetworkToWifiConfigManager(WifiConfigurationTestUtil.createPskNetwork());
+ verifyAddNetworkToWifiConfigManager(WifiConfigurationTestUtil.createWepNetwork());
+
+ assertFalse(mWifiConfigManager.getConfiguredNetworks().isEmpty());
+
+ assertTrue(mWifiConfigManager.removeNetworksForUser(TEST_DEFAULT_USER));
+
+ // Ensure all the networks are removed now.
+ assertTrue(mWifiConfigManager.getConfiguredNetworks().isEmpty());
+ }
+
private void createWifiConfigManager() {
mWifiConfigManager =
new WifiConfigManagerNew(