summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-08-08 14:28:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-08-08 14:28:29 +0000
commitd6dcaece660e8e80e9d561c6e530190e9674fded (patch)
treeb4f5edebbccee25f1de54cb7341a8777a911cbd6 /tests
parentece7e1bb352a57ed82124173449b7d5b6d479e8e (diff)
parent840cdc08391ef0f24adf2f46fa1ea017d3d5eac4 (diff)
Merge "WifiService: Ignore wifi state change API in crypt debounce state" into qt-qpr1-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java67
1 files changed, 66 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 33e8c29d6..af624da11 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -637,6 +637,20 @@ public class WifiServiceImplTest {
}
/**
+ * Verify that wifi is not enabled when wificontroller is not started.
+ */
+ @Test
+ public void testSetWifiEnabledFailureWhenInCryptDebounce() throws Exception {
+ when(mFrameworkFacade.inStorageManagerCryptKeeperBounce()).thenReturn(true);
+ when(mContext.checkPermission(eq(android.Manifest.permission.NETWORK_SETTINGS),
+ anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED);
+ when(mSettingsStore.handleWifiToggled(eq(true))).thenReturn(true);
+ when(mSettingsStore.isAirplaneModeOn()).thenReturn(false);
+ assertFalse(mWifiServiceImpl.setWifiEnabled(TEST_PACKAGE_NAME, true));
+ verifyZeroInteractions(mWifiController);
+ }
+
+ /**
* Verify that wifi cannot be enabled by the apps targeting Q SDK.
*/
@Test
@@ -869,6 +883,20 @@ public class WifiServiceImplTest {
}
/**
+ * Verify that wifi is not disabled when wificontroller is not started.
+ */
+ @Test
+ public void testSetWifiDisabledFailureWhenInCryptDebounce() throws Exception {
+ when(mFrameworkFacade.inStorageManagerCryptKeeperBounce()).thenReturn(true);
+ when(mContext.checkPermission(eq(android.Manifest.permission.NETWORK_SETTINGS),
+ anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED);
+ when(mSettingsStore.handleWifiToggled(eq(false))).thenReturn(false);
+ when(mSettingsStore.isAirplaneModeOn()).thenReturn(false);
+ assertFalse(mWifiServiceImpl.setWifiEnabled(TEST_PACKAGE_NAME, false));
+ verifyZeroInteractions(mWifiController);
+ }
+
+ /**
* Verify that wifi cannot be disabled by the apps targeting Q SDK.
*/
@Test
@@ -1125,6 +1153,19 @@ public class WifiServiceImplTest {
}
/**
+ * Verify does not start softap when wificontroller is not started.
+ */
+ @Test
+ public void testStartSoftApWhenInCryptDebounce() {
+ when(mFrameworkFacade.inStorageManagerCryptKeeperBounce()).thenReturn(true);
+
+ WifiConfiguration config = createValidSoftApConfiguration();
+ boolean result = mWifiServiceImpl.startSoftAp(config);
+ assertFalse(result);
+ verifyZeroInteractions(mWifiController);
+ }
+
+ /**
* Verify a SecurityException is thrown when a caller without the correct permission attempts to
* start softap.
*/
@@ -1148,6 +1189,18 @@ public class WifiServiceImplTest {
}
/**
+ * Verify does not stop softap when wificontroller is not started.
+ */
+ @Test
+ public void testStopSoftApWhenInCryptDebounce() {
+ when(mFrameworkFacade.inStorageManagerCryptKeeperBounce()).thenReturn(true);
+
+ boolean result = mWifiServiceImpl.stopSoftAp();
+ assertFalse(result);
+ verifyZeroInteractions(mWifiController);
+ }
+
+ /**
* Verify SecurityException is thrown when a caller without the correct permission attempts to
* stop softap.
*/
@@ -1502,6 +1555,19 @@ public class WifiServiceImplTest {
}
/**
+ * Only start LocalOnlyHotspot if device is in crypt debounce mode.
+ */
+ @Test
+ public void testStartLocalOnlyHotspotFailsIfInCryptDebounce() throws Exception {
+ when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(true);
+ when(mFrameworkFacade.isAppForeground(anyInt())).thenReturn(true);
+ when(mFrameworkFacade.inStorageManagerCryptKeeperBounce()).thenReturn(true);
+ int result = mWifiServiceImpl.startLocalOnlyHotspot(mAppMessenger, mAppBinder,
+ TEST_PACKAGE_NAME);
+ assertEquals(LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE, result);
+ }
+
+ /**
* Only start LocalOnlyHotspot if we are not tethering.
*/
@Test
@@ -1519,7 +1585,6 @@ public class WifiServiceImplTest {
// Start another session without a stop, that should fail.
assertFalse(mWifiServiceImpl.startSoftAp(createValidSoftApConfiguration()));
-
verifyNoMoreInteractions(mWifiController);
}