Merge "WifiManagerTest: test for startLOHS return code" into oc-dev
am: f8d909c14a
Change-Id: I0f43de95419ba442d53b676f1129f0782d2aac71
This commit is contained in:
@@ -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_GENERIC;
|
||||||
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE;
|
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_NO_CHANNEL;
|
||||||
|
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED;
|
||||||
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.REQUEST_REGISTERED;
|
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.REQUEST_REGISTERED;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
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
|
* Verify callback triggered from startLocalOnlyHotspot with an incompatible mode failure.
|
||||||
* null WifiConfig is returned.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLocalOnlyHotspotCallbackFullOnNullConfig() throws Exception {
|
public void testLocalOnlyHotspotCallbackFullOnIncompatibleMode() throws Exception {
|
||||||
TestLocalOnlyHotspotCallback callback = new TestLocalOnlyHotspotCallback();
|
TestLocalOnlyHotspotCallback callback = new TestLocalOnlyHotspotCallback();
|
||||||
when(mWifiService.startLocalOnlyHotspot(any(Messenger.class), any(IBinder.class)))
|
when(mWifiService.startLocalOnlyHotspot(any(Messenger.class), any(IBinder.class)))
|
||||||
.thenReturn(ERROR_INCOMPATIBLE_MODE);
|
.thenReturn(ERROR_INCOMPATIBLE_MODE);
|
||||||
@@ -480,6 +480,22 @@ public class WifiManagerTest {
|
|||||||
assertEquals(null, callback.mRes);
|
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
|
* 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.
|
* bubble up through the call to start LocalOnlyHotspot and will not trigger other callbacks.
|
||||||
|
|||||||
Reference in New Issue
Block a user