summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-05-29 21:21:36 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-05-29 21:21:36 +0000
commit6230ee509760f2351d5ec99547522e79de0c5f8a (patch)
treeb53bfbae94dbacb30d6cb0ef134d7990fe6bfe57 /tests
parente1273d71ef5e5b4615e02aabad0b770c90b4ba15 (diff)
parent0f37ecb31e0cc3367a897920ea121bc0870e5738 (diff)
Merge "[AWARE] Loop retry to get valid IPv6 address and verify usablity" into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java34
1 files changed, 23 insertions, 11 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 df7417338..f496b1c95 100644
--- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
@@ -1394,9 +1394,15 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest {
mMockLooper.dispatchAll();
// (2) get confirmation OR timeout
+ boolean timeout = false;
if (getConfirmation) {
+ int numConfigureAgentPropertiesFail = 0;
if (numAddrValidationRetries > 0) {
when(mMockNetworkInterface.isAddressUsable(any())).thenReturn(false);
+ when(mMockNetworkInterface.configureAgentProperties(any(), any(), anyInt(),
+ any(), any())).thenReturn(false);
+ // First retry will be ConfigureAgentProperties failure.
+ numConfigureAgentPropertiesFail = 1;
}
when(mClock.getElapsedSinceBootMillis()).thenReturn(0L);
@@ -1406,35 +1412,41 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest {
inOrder.verify(mMockNetdWrapper).enableIpv6(anyString());
inOrder.verify(mMockNetworkInterface).configureAgentProperties(any(), any(), anyInt(),
any(), any());
- inOrder.verify(mMockCm).registerNetworkAgent(messengerCaptor.capture(), any(), any(),
- netCapCaptor.capture(), anyInt(), any(), anyInt());
-
- inOrder.verify(mMockNetworkInterface).isAddressUsable(any());
- boolean timedout = false;
+ if (numAddrValidationRetries <= 0) {
+ inOrder.verify(mMockNetworkInterface).isAddressUsable(any());
+ }
for (int i = 0; i < numAddrValidationRetries; ++i) {
+ if (i == numConfigureAgentPropertiesFail) {
+ when(mMockNetworkInterface.configureAgentProperties(any(), any(), anyInt(),
+ any(), any())).thenReturn(true);
+ }
if (i == numAddrValidationRetries - 1) {
when(mMockNetworkInterface.isAddressUsable(any())).thenReturn(true);
}
-
long currentTime = (i + 1L)
* WifiAwareDataPathStateManager.ADDRESS_VALIDATION_RETRY_INTERVAL_MS;
when(mClock.getElapsedSinceBootMillis()).thenReturn(currentTime);
mMockLooper.moveTimeForward(
WifiAwareDataPathStateManager.ADDRESS_VALIDATION_RETRY_INTERVAL_MS + 1);
mMockLooper.dispatchAll();
+ inOrder.verify(mMockNetworkInterface).configureAgentProperties(any(), any(),
+ anyInt(), any(), any());
+ if (i < numConfigureAgentPropertiesFail) {
+ continue;
+ }
inOrder.verify(mMockNetworkInterface).isAddressUsable(any());
-
if (currentTime > WifiAwareDataPathStateManager.ADDRESS_VALIDATION_TIMEOUT_MS) {
- timedout = true;
+ timeout = true;
break;
}
}
-
- if (timedout) {
+ if (timeout) {
verifyRequestDeclaredUnfullfillable(nr);
inOrder.verify(mMockNative).endDataPath(transactionId.capture(), eq(ndpId));
mDut.onEndDataPathResponse(transactionId.getValue(), true, 0);
} else {
+ inOrder.verify(mMockCm).registerNetworkAgent(messengerCaptor.capture(), any(),
+ any(), netCapCaptor.capture(), anyInt(), any(), anyInt());
inOrder.verify(mMockNetworkInterface).setConnected(any());
inOrderM.verify(mAwareMetricsMock).recordNdpStatus(eq(NanStatusType.SUCCESS),
eq(useDirect), anyLong());
@@ -1458,7 +1470,7 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest {
}
// (3) end data-path (unless didn't get confirmation)
- if (getConfirmation) {
+ if (getConfirmation && !timeout) {
Message endNetworkReqMsg = Message.obtain();
endNetworkReqMsg.what = NetworkFactory.CMD_CANCEL_REQUEST;
endNetworkReqMsg.obj = nr;