summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-04-17 17:30:11 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-04-17 17:30:11 +0000
commit43cf52a0f4408aaee9c9c11efb26034e8ada46f2 (patch)
treeafb2b0d2419fa09716f86c58b88c0ab1b845e4b2 /tests
parentd13cd95984bc71dae7989d64dde1b4f5269d029b (diff)
parentd5805c08f661113c04a0fa55bdea6c3b304427a3 (diff)
WifiServiceImpl: add new methods to start softap am: b7c333ba6d
am: d5805c08f6 Change-Id: I4f16bb72e25e071a3401f5d1261c9947fcdbb7d5
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java68
1 files changed, 67 insertions, 1 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index ed0e9c486..be597b9f4 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -467,7 +467,7 @@ public class WifiServiceImplTest {
* setWifiApEnabled should fail if the provided config is not valid.
*/
@Test
- public void testSetWIfiApEnabledWithProperPermissionInvalidConfigFails() {
+ public void testSetWifiApEnabledWithProperPermissionInvalidConfigFails() {
when(mWifiPermissionsUtil.checkConfigOverridePermission(anyInt())).thenReturn(true);
when(mUserManager.hasUserRestriction(eq(UserManager.DISALLOW_CONFIG_TETHERING)))
.thenReturn(false);
@@ -501,5 +501,71 @@ public class WifiServiceImplTest {
when(mUserManager.hasUserRestriction(eq(UserManager.DISALLOW_CONFIG_TETHERING)))
.thenReturn(true);
mWifiServiceImpl.setWifiApEnabled(null, true);
+
+ }
+
+ /**
+ * Verify caller with proper permission can call startSoftAp.
+ */
+ @Test
+ public void testStartSoftApWithPermissionsAndNullConfig() {
+ boolean result = mWifiServiceImpl.startSoftAp(null);
+ assertTrue(result);
+ verify(mWifiController).sendMessage(eq(CMD_SET_AP), eq(1), eq(0), eq(null));
+ }
+
+ /**
+ * Verify caller with proper permissions but an invalid config does not start softap.
+ */
+ @Test
+ public void testStartSoftApWithPermissionsAndInvalidConfig() {
+ boolean result = mWifiServiceImpl.startSoftAp(mApConfig);
+ assertFalse(result);
+ verifyZeroInteractions(mWifiController);
+ }
+
+ /**
+ * Verify caller with proper permission and valid config does start softap.
+ */
+ @Test
+ public void testStartSoftApWithPermissionsAndValidConfig() {
+ WifiConfiguration config = new WifiConfiguration();
+ boolean result = mWifiServiceImpl.startSoftAp(config);
+ assertTrue(result);
+ verify(mWifiController).sendMessage(eq(CMD_SET_AP), eq(1), eq(0), eq(config));
+ }
+
+ /**
+ * Verify a SecurityException is thrown when a caller without the correct permission attempts to
+ * start softap.
+ */
+ @Test(expected = SecurityException.class)
+ public void testStartSoftApWithoutPermissionThrowsException() throws Exception {
+ doThrow(new SecurityException()).when(mContext)
+ .enforceCallingOrSelfPermission(eq(android.Manifest.permission.NETWORK_STACK),
+ eq("WifiService"));
+ mWifiServiceImpl.startSoftAp(null);
+ }
+
+ /**
+ * Verify caller with proper permission can call stopSoftAp.
+ */
+ @Test
+ public void testStopSoftApWithPermissions() {
+ boolean result = mWifiServiceImpl.stopSoftAp();
+ assertTrue(result);
+ verify(mWifiController).sendMessage(eq(CMD_SET_AP), eq(0), eq(0));
+ }
+
+ /**
+ * Verify SecurityException is thrown when a caller without the correct permission attempts to
+ * stop softap.
+ */
+ @Test(expected = SecurityException.class)
+ public void testStopSoftApWithoutPermissionThrowsException() throws Exception {
+ doThrow(new SecurityException()).when(mContext)
+ .enforceCallingOrSelfPermission(eq(android.Manifest.permission.NETWORK_STACK),
+ eq("WifiService"));
+ mWifiServiceImpl.stopSoftAp();
}
}