diff options
author | Roshan Pius <rpius@google.com> | 2017-02-17 13:27:55 -0800 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2017-02-21 09:23:36 -0800 |
commit | 5317e7c11c99d5cc8417c65cc73cf548f8f52b87 (patch) | |
tree | 017ab41cc6bfdbf03d584b5422346ed2ade15acd /tests | |
parent | bcf35be52f93d09a3f2ac8d4272a6d66467309b9 (diff) |
SupplicantStaIface: Handle wpa_supplicant death
Trigger the existing WifiMonitor events to indicate
establishment/loss of contact with wpa_supplicant.
Bug: 33383725
Test: Unit tests
Change-Id: I394a3ed7dad4f201456e2aaa53ba380c7a130f33
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java | 19 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java | 29 |
2 files changed, 46 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java index 8b267a955..2b0f4306e 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java @@ -900,6 +900,17 @@ public class SupplicantStaIfaceHalTest { verify(mWifiMonitor).broadcastWpsOverlapEvent(eq(WLAN_IFACE_NAME)); } + /** + * Tests the handling of supplicant death notification. + */ + @Test + public void testSupplicantDeathCallback() throws Exception { + executeAndValidateInitializationSequence(); + assertNotNull(mDeathRecipientCaptor.getValue()); + + mDeathRecipientCaptor.getValue().serviceDied(5L); + verify(mWifiMonitor).broadcastSupplicantDisconnectionEvent(eq(WLAN_IFACE_NAME)); + } private void executeAndValidateHs20DeauthImminentCallback(boolean isEss) throws Exception { executeAndValidateInitializationSequence(); @@ -1015,11 +1026,12 @@ public class SupplicantStaIfaceHalTest { .registerCallback(any(ISupplicantStaIfaceCallback.class)); } - mInOrder = inOrder(mServiceManagerMock, mISupplicantMock, mISupplicantStaIfaceMock); + mInOrder = inOrder(mServiceManagerMock, mISupplicantMock, mISupplicantStaIfaceMock, + mWifiMonitor); // Initialize SupplicantStaIfaceHal, should call serviceManager.registerForNotifications assertTrue(mDut.initialize()); // verify: service manager initialization sequence - mInOrder.verify(mServiceManagerMock).linkToDeath(any(IHwBinder.DeathRecipient.class), + mInOrder.verify(mServiceManagerMock).linkToDeath(mDeathRecipientCaptor.capture(), anyLong()); mInOrder.verify(mServiceManagerMock).registerForNotifications( eq(ISupplicant.kInterfaceName), eq(""), mServiceNotificationCaptor.capture()); @@ -1035,6 +1047,9 @@ public class SupplicantStaIfaceHalTest { .getInterface(any(ISupplicant.IfaceInfo.class), any(ISupplicant.getInterfaceCallback.class)); } + if (causeRemoteException) { + mInOrder.verify(mWifiMonitor).broadcastSupplicantDisconnectionEvent(eq(null)); + } if (!causeRemoteException && !getZeroInterfaces && !getNullInterface) { mInOrder.verify(mISupplicantStaIfaceMock) .registerCallback(any(ISupplicantStaIfaceCallback.class)); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java index 8c4021fda..451852a7c 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java @@ -411,4 +411,33 @@ public class WifiMonitorTest { assertEquals(bssid, result.BSSID); assertEquals(newState, result.state); } + + /** + * Broadcast supplicant connection test. + */ + @Test + public void testBroadcastSupplicantConnectionEvent() { + mWifiMonitor.registerHandler( + WLAN_IFACE_NAME, WifiMonitor.SUP_CONNECTION_EVENT, mHandlerSpy); + mWifiMonitor.broadcastSupplicantConnectionEvent(WLAN_IFACE_NAME); + mLooper.dispatchAll(); + + ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class); + verify(mHandlerSpy).handleMessage(messageCaptor.capture()); + assertEquals(WifiMonitor.SUP_CONNECTION_EVENT, messageCaptor.getValue().what); + } + /** + * Broadcast supplicant disconnection test. + */ + @Test + public void testBroadcastSupplicantDisconnectionEvent() { + mWifiMonitor.registerHandler( + WLAN_IFACE_NAME, WifiMonitor.SUP_DISCONNECTION_EVENT, mHandlerSpy); + mWifiMonitor.broadcastSupplicantDisconnectionEvent(WLAN_IFACE_NAME); + mLooper.dispatchAll(); + + ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class); + verify(mHandlerSpy).handleMessage(messageCaptor.capture()); + assertEquals(WifiMonitor.SUP_DISCONNECTION_EVENT, messageCaptor.getValue().what); + } } |