summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-05-17 23:19:10 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-05-17 23:19:10 +0000
commit58f2ade07f35ccdbfb2a97367e329447271f6706 (patch)
treeae59220057dd161e13b8864d8c64bce4a165184b /tests
parent13e373e9b0c5a870f9e7b05c7973f8c372b35e23 (diff)
parent0c96f88c6d9f031ab76392cdb1255bd249212ad3 (diff)
WifiServiceImpl: add binder death callback impl
am: 0c96f88c6d Change-Id: Idc4f6a6c79411d64f31437a4ca5be1658ddf5e52
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index 0c9366f7c..09160f9d3 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -57,9 +57,11 @@ import android.provider.Settings;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.internal.util.AsyncChannel;
+import com.android.server.wifi.WifiServiceImpl.LocalOnlyRequestorCallback;
import com.android.server.wifi.util.WifiAsyncChannel;
import com.android.server.wifi.util.WifiPermissionsUtil;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -87,12 +89,14 @@ public class WifiServiceImplTest {
private static final String TEST_PACKAGE_NAME = "TestPackage";
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
private static final String SYSUI_PACKAGE_NAME = "com.android.systemui";
+ private static final int TEST_UID = 6789;
private WifiServiceImpl mWifiServiceImpl;
private TestLooper mLooper;
private PowerManager mPowerManager;
private Handler mHandler;
private Messenger mAppMessenger;
+ private int mUid;
@Mock Context mContext;
@Mock WifiInjector mWifiInjector;
@@ -118,6 +122,7 @@ public class WifiServiceImplTest {
@Mock AppOpsManager mAppOpsManager;
@Mock IBinder mAppBinder;
@Mock WifiNotificationController mWifiNotificationController;
+ @Mock LocalOnlyHotspotRequestInfo mRequestInfo;
@Spy FakeWifiLog mLog;
@@ -180,6 +185,7 @@ public class WifiServiceImplTest {
mHandler = new Handler(mLooper.getLooper());
mAppMessenger = new Messenger(mHandler);
+ when(mRequestInfo.getUid()).thenReturn(mUid);
when(mWifiInjector.getUserManager()).thenReturn(mUserManager);
when(mWifiInjector.getWifiController()).thenReturn(mWifiController);
when(mWifiInjector.getWifiMetrics()).thenReturn(mWifiMetrics);
@@ -803,6 +809,22 @@ public class WifiServiceImplTest {
}
/**
+ * Verify that WifiServiceImpl does not send the stop ap message if there were no
+ * pending LOHS requests upon a binder death callback.
+ *
+ * TODO: add a test verifying it is not called when there are remaining requests.
+ * TODO: add a test verifying it is called when the last request was removed.
+ */
+ @Test
+ public void testServiceImplNotCalledWhenBinderDeathTriggeredNoRequests() {
+ LocalOnlyRequestorCallback binderDeathCallback =
+ mWifiServiceImpl.new LocalOnlyRequestorCallback();
+
+ binderDeathCallback.onLocalOnlyHotspotRequestorDeath(mRequestInfo);
+ verify(mWifiController, never()).sendMessage(eq(CMD_SET_AP), eq(0), eq(0));
+ }
+
+ /**
* Verify that the call to startWatchLocalOnlyHotspot throws the UnsupportedOperationException
* until the implementation is complete.
*/