summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hugo Benichi <hugobenichi@google.com> 2017-10-12 23:09:25 +0900
committer Hugo Benichi <hugobenichi@google.com> 2017-10-12 23:15:14 +0900
commit1e5039e0e47eaca3bbe5452f8328c26756468e46 (patch)
treea9f75f66718e81142ee86fa87b59d025221f7076
parentda7edaff329e84ce7b9d3cb2b4699520aed21594 (diff)
Fix ConnectivityServiceTest#testNetworkCallbackMaximum
Although commit 893a762c2f7 fixed some flakyness issues in testNetworkCallbackMaximum so that it became stable when ran on its own, it introduced a new source of random failures because instead of registering callbacks after callbacks until a limit was reached, commit 893a762c2f7 changed the test logic to push the assertions right up to the theoretical limit. More precisely when registering and unregistering PendingIntents in a loop, not introducing some delay for checking that previous PendingIntents have been effectively unregistered can cause the test to fail. This patch fixes this issue. Bug: 32561414 Bug: 62918393 Test: runtest frameworks-net testNetworkCallbackMaximum now succeeds 100 in a row on sailfish Change-Id: I086817a738ab99fd53ba76ca8faada6151f46472
-rw-r--r--tests/net/java/com/android/server/ConnectivityServiceTest.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java
index d9586c2b31c5..c2cb66d5e60a 100644
--- a/tests/net/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java
@@ -3296,12 +3296,14 @@ public class ConnectivityServiceTest {
mCm.requestNetwork(networkRequest, networkCallback);
mCm.unregisterNetworkCallback(networkCallback);
}
+ waitForIdle();
for (int i = 0; i < MAX_REQUESTS; i++) {
NetworkCallback networkCallback = new NetworkCallback();
mCm.registerNetworkCallback(networkRequest, networkCallback);
mCm.unregisterNetworkCallback(networkCallback);
}
+ waitForIdle();
for (int i = 0; i < MAX_REQUESTS; i++) {
PendingIntent pendingIntent =
@@ -3309,6 +3311,7 @@ public class ConnectivityServiceTest {
mCm.requestNetwork(networkRequest, pendingIntent);
mCm.unregisterNetworkCallback(pendingIntent);
}
+ waitForIdle();
for (int i = 0; i < MAX_REQUESTS; i++) {
PendingIntent pendingIntent =