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

Commit 3da8e0f8 authored by Chalard Jean's avatar Chalard Jean
Browse files

Fix TestNetworkAgentWrapper flakiness

The underlying issue here is that before aosp/986824 the call to
waitForIdle is the local ConnectivityServiceTest function, but
after that patch TestNetworkAgentWrapper has an identically
named member that only wait for its own handler.

Bug: 141341704
Test: ConnectivityServiceTest --generate-new-metrics 100
Change-Id: I38709cc69ec7a261c1c6e008abe03d2882e2083d
parent 6265eea8
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -504,6 +504,8 @@ public class ConnectivityServiceTest {
            // Waits for the NetworkAgent to be registered, which includes the creation of the
            // NetworkMonitor.
            waitForIdle(TIMEOUT_MS);
            HandlerUtilsKt.waitForIdle(mCsHandlerThread, TIMEOUT_MS);
            HandlerUtilsKt.waitForIdle(ConnectivityThread.get(), TIMEOUT_MS);
        }

        @Override
@@ -4315,16 +4317,16 @@ public class ConnectivityServiceTest {
        assertFalse(mCm.isNetworkSupported(TYPE_NONE));

        assertThrows(IllegalArgumentException.class,
                () -> { mCm.networkCapabilitiesForType(TYPE_NONE); });
                () -> mCm.networkCapabilitiesForType(TYPE_NONE));

        Class<UnsupportedOperationException> unsupported = UnsupportedOperationException.class;
        assertThrows(unsupported, () -> { mCm.startUsingNetworkFeature(TYPE_WIFI, ""); });
        assertThrows(unsupported, () -> { mCm.stopUsingNetworkFeature(TYPE_WIFI, ""); });
        assertThrows(unsupported, () -> mCm.startUsingNetworkFeature(TYPE_WIFI, ""));
        assertThrows(unsupported, () -> mCm.stopUsingNetworkFeature(TYPE_WIFI, ""));
        // TODO: let test context have configuration application target sdk version
        // and test that pre-M requesting for TYPE_NONE sends back APN_REQUEST_FAILED
        assertThrows(unsupported, () -> { mCm.startUsingNetworkFeature(TYPE_NONE, ""); });
        assertThrows(unsupported, () -> { mCm.stopUsingNetworkFeature(TYPE_NONE, ""); });
        assertThrows(unsupported, () -> { mCm.requestRouteToHostAddress(TYPE_NONE, null); });
        assertThrows(unsupported, () -> mCm.startUsingNetworkFeature(TYPE_NONE, ""));
        assertThrows(unsupported, () -> mCm.stopUsingNetworkFeature(TYPE_NONE, ""));
        assertThrows(unsupported, () -> mCm.requestRouteToHostAddress(TYPE_NONE, null));
    }

    @Test