Merge "WifiManagerTest: test for startLOHS return code" into oc-dev

This commit is contained in:
Rebecca Silberstein
2017-05-05 16:06:50 +00:00
committed by Android (Google) Code Review

View File

@@ -22,6 +22,7 @@ import static android.net.wifi.WifiManager.HOTSPOT_STOPPED;
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.ERROR_GENERIC;
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE;
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.ERROR_NO_CHANNEL;
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED;
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.REQUEST_REGISTERED;
import static org.junit.Assert.assertEquals;
@@ -464,11 +465,10 @@ public class WifiManagerTest {
}
/**
* Verify the handler passed in to startLocalOnlyHotspot is correctly used for callbacks when a
* null WifiConfig is returned.
* Verify callback triggered from startLocalOnlyHotspot with an incompatible mode failure.
*/
@Test
public void testLocalOnlyHotspotCallbackFullOnNullConfig() throws Exception {
public void testLocalOnlyHotspotCallbackFullOnIncompatibleMode() throws Exception {
TestLocalOnlyHotspotCallback callback = new TestLocalOnlyHotspotCallback();
when(mWifiService.startLocalOnlyHotspot(any(Messenger.class), any(IBinder.class)))
.thenReturn(ERROR_INCOMPATIBLE_MODE);
@@ -480,6 +480,22 @@ public class WifiManagerTest {
assertEquals(null, callback.mRes);
}
/**
* Verify callback triggered from startLocalOnlyHotspot with a tethering disallowed failure.
*/
@Test
public void testLocalOnlyHotspotCallbackFullOnTetheringDisallowed() throws Exception {
TestLocalOnlyHotspotCallback callback = new TestLocalOnlyHotspotCallback();
when(mWifiService.startLocalOnlyHotspot(any(Messenger.class), any(IBinder.class)))
.thenReturn(ERROR_TETHERING_DISALLOWED);
mWifiManager.startLocalOnlyHotspot(callback, mHandler);
mLooper.dispatchAll();
assertEquals(ERROR_TETHERING_DISALLOWED, callback.mFailureReason);
assertFalse(callback.mOnStartedCalled);
assertFalse(callback.mOnStoppedCalled);
assertEquals(null, callback.mRes);
}
/**
* Verify a SecurityException resulting from an application without necessary permissions will
* bubble up through the call to start LocalOnlyHotspot and will not trigger other callbacks.