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

Commit fd4a90db authored by Michael Plass's avatar Michael Plass
Browse files

Fix WifiTrackerTest stopTrackingShouldRemove . . .

Fix a race condition in
com.android.settingslib.wifi.WifiTrackerTest#stopTrackingShouldRemoveWifiListenerCallbacks

Bug: 70171301
Test: runtest --path frameworks/base/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/WifiTrackerTest.java
Test: repeat the test lots of times - failure rate was < 1% before fix.
Change-Id: Ib9c9cb3dbfb3413484530be5fc0c2e20fd470b97
parent 1fa458fd
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -767,10 +767,12 @@ public class WifiTrackerTest {
        WifiTracker tracker = createMockedWifiTracker();
        startTracking(tracker);

        CountDownLatch ready = new CountDownLatch(1);
        CountDownLatch latch = new CountDownLatch(1);
        CountDownLatch lock = new CountDownLatch(1);
        tracker.mMainHandler.post(() -> {
            try {
                ready.countDown();
                lock.await();
                latch.countDown();
            } catch (InterruptedException e) {
@@ -786,6 +788,9 @@ public class WifiTrackerTest {
        tracker.mMainHandler.sendEmptyMessage(
                WifiTracker.MainHandler.MSG_WIFI_STATE_CHANGED);

        try {
            ready.await(); // Make sure we have entered the first message handler
        } catch (InterruptedException e) {}
        tracker.onStop();

        verify(mockWifiListener, atMost(1)).onAccessPointsChanged();