summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@google.com>2017-05-01 22:38:52 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-05-01 22:38:52 +0000
commitff7ae7581d2eefd94882a7f56d1b408afc470ada (patch)
tree223471954870e47c275904db143ded9f41e26532 /tests
parent909ad15e03f4145c444310498dcaf453bebf7f1f (diff)
parent8472ba80953fbbb0227eff5faac497e1bca067b0 (diff)
Merge changes from topic 'LOHSapi' into oc-dev
am: 8472ba8095 Change-Id: Iab5c3b50745b614423d1a249f47da8746dcd8e12
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index 3c8c9f03a..b1f035450 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -16,6 +16,8 @@
package com.android.server.wifi;
+import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE;
+import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED;
import static android.net.wifi.WifiManager.WIFI_STATE_DISABLED;
import static android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY;
import static android.provider.Settings.Secure.LOCATION_MODE_OFF;
@@ -25,7 +27,6 @@ import static com.android.server.wifi.WifiController.CMD_WIFI_TOGGLED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
@@ -702,6 +703,8 @@ public class WifiServiceImplTest {
// allow test to proceed without a permission check failure
when(mSettingsStore.getLocationModeSetting(mContext))
.thenReturn(LOCATION_MODE_HIGH_ACCURACY);
+ when(mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING))
+ .thenReturn(false);
when(mWifiStateMachine.syncGetWifiApState()).thenReturn(WifiManager.WIFI_AP_STATE_DISABLED);
mWifiServiceImpl.startLocalOnlyHotspot(mAppMessenger, mAppBinder);
}
@@ -749,9 +752,22 @@ public class WifiServiceImplTest {
when(mSettingsStore.getLocationModeSetting(mContext))
.thenReturn(LOCATION_MODE_HIGH_ACCURACY);
when(mWifiStateMachine.syncGetWifiApState()).thenReturn(WifiManager.WIFI_AP_STATE_ENABLED);
- WifiConfiguration hotspotConfig =
- mWifiServiceImpl.startLocalOnlyHotspot(mAppMessenger, mAppBinder);
- assertNull(hotspotConfig);
+ int returnCode = mWifiServiceImpl.startLocalOnlyHotspot(mAppMessenger, mAppBinder);
+ assertEquals(ERROR_INCOMPATIBLE_MODE, returnCode);
+ }
+
+ /**
+ * Only start LocalOnlyHotspot if admin setting does not disallow tethering.
+ */
+ @Test
+ public void testHotspotDoesNotStartWhenTetheringDisallowed() {
+ when(mSettingsStore.getLocationModeSetting(mContext))
+ .thenReturn(LOCATION_MODE_HIGH_ACCURACY);
+ when(mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING))
+ .thenReturn(true);
+ when(mWifiStateMachine.syncGetWifiApState()).thenReturn(WifiManager.WIFI_AP_STATE_ENABLED);
+ int returnCode = mWifiServiceImpl.startLocalOnlyHotspot(mAppMessenger, mAppBinder);
+ assertEquals(ERROR_TETHERING_DISALLOWED, returnCode);
}
/**