summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-04-30 14:07:31 -0700
committerRebecca Silberstein <silberst@google.com>2017-05-01 11:51:28 -0700
commit0025465e311fe9504cd79610523a1b8171995acc (patch)
treebee866cfbe4c45d750c530000ee7f1f49a790553 /tests
parentb09edccf2056d1106da4b901e1e8b26841a02a61 (diff)
WifiServiceImpl: update API for LOHS
Add a return code for disallowed tethering for the user. Since this needs to be a new failure mode, the return type for starting LOHS needed to change. Updated tests to reflect this as well. This CL will be part of a topic - there is a corresponding WifiManager change. Bug: 37073685 Test: frameworks/base/wifi/tests/runtests.sh Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: I22d1fcf755d1384d482bd03dbc9a6388dfa4d3db
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);
}
/**