diff options
author | Etan Cohen <etancohen@google.com> | 2017-07-17 16:31:44 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-07-17 16:31:44 +0000 |
commit | 3ce12580c2b867253e5188595be254e4f840649e (patch) | |
tree | 17340d06e7c35bde1ae45dbe09f3664757144e35 /tests | |
parent | 0eb389dd4a9bf3d8a5c72ffb2aa893aa91f981a6 (diff) | |
parent | 40ebe8cecf9eda79c986386e3bfbc4ee83a17cbd (diff) |
Merge "[AWARE] Abort data-path setup if there are no data-interfaces" into oc-dr1-dev am: f44c3b64d5
am: 40ebe8cecf
Change-Id: I25f1c3569e7849307bd5b43203a447c72f919449
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java index f3927357f..806300423 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java @@ -26,6 +26,7 @@ import static org.mockito.ArgumentMatchers.anyByte; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyShort; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; @@ -290,6 +291,60 @@ public class WifiAwareDataPathStateManagerTest { verifyNoMoreInteractions(mMockNative, mMockCm, mAwareMetricsMock); } + /** + * Validate that if the data-interfaces are deleted while a data-path is being created, the + * process will terminate. + */ + @Test + public void testDestroyNdiDuringNdpSetupResponder() throws Exception { + final int clientId = 123; + final byte pubSubId = 55; + final int requestorId = 1341234; + final byte[] peerDiscoveryMac = HexEncoding.decode("000102030405".toCharArray(), false); + final int ndpId = 3; + + InOrder inOrder = inOrder(mMockNative, mMockCm, mMockCallback, mMockSessionCallback); + InOrder inOrderM = inOrder(mAwareMetricsMock); + + ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); + + // (0) initialize + DataPathEndPointInfo res = initDataPathEndPoint(clientId, pubSubId, requestorId, + peerDiscoveryMac, inOrder, inOrderM, true); + + // (1) request network + NetworkRequest nr = getSessionNetworkRequest(clientId, res.mSessionId, res.mPeerHandle, + null, null, true); + + Message reqNetworkMsg = Message.obtain(); + reqNetworkMsg.what = NetworkFactory.CMD_REQUEST_NETWORK; + reqNetworkMsg.obj = nr; + reqNetworkMsg.arg1 = 0; + res.mMessenger.send(reqNetworkMsg); + mMockLooper.dispatchAll(); + + // (2) delete interface(s) + mDut.deleteAllDataPathInterfaces(); + mMockLooper.dispatchAll(); + inOrder.verify(mMockNative).deleteAwareNetworkInterface(transactionId.capture(), + anyString()); + mDut.onDeleteDataPathInterfaceResponse(transactionId.getValue(), true, 0); + mMockLooper.dispatchAll(); + + // (3) have responder receive request + mDut.onDataPathRequestNotification(pubSubId, peerDiscoveryMac, ndpId); + mMockLooper.dispatchAll(); + + // (4) verify that responder aborts (i.e. refuses request) + inOrder.verify(mMockNative).respondToDataPathRequest(transactionId.capture(), eq(false), + eq(ndpId), eq(""), eq(null), eq(null), eq(false), any()); + mDut.onRespondToDataPathSetupRequestResponse(transactionId.getValue(), true, 0); + mMockLooper.dispatchAll(); + + // failure if there's further activity + verifyNoMoreInteractions(mMockNative, mMockCm, mAwareMetricsMock); + } + /* * Initiator tests */ |