Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e5039e0 authored by Hugo Benichi's avatar Hugo Benichi
Browse files

Fix ConnectivityServiceTest#testNetworkCallbackMaximum

Although commit 893a762c 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
893a762c 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
parent da7edaff
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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 =