summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-05-27 12:17:52 -0700
committerNate Jiang <qiangjiang@google.com>2020-05-28 23:21:37 -0700
commit0f37ecb31e0cc3367a897920ea121bc0870e5738 (patch)
tree3ef5b7ca06da5bdb5898bf67fb2b5e4e2510d878 /tests
parentc11cd31f25516662ea9a8d6b774d9e591a3fda91 (diff)
[AWARE] Loop retry to get valid IPv6 address and verify usablity
Bug: 155255680 Test: atest com.android.server.wifi Test: acts DataPathTest Change-Id: I20d62ac93298c1609a5edc18b369c31521076ccb
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;