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

Commit f496502a authored by Robin Lee's avatar Robin Lee Committed by Android (Google) Code Review
Browse files

Merge "Make ShellTestCase try to delete TestableLooper" into main

parents 7c99f9bd 2a74011a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.platform.test.flag.junit.SetFlagsRule;
import android.testing.TestableContext;
import android.testing.TestableLooper;

import androidx.test.platform.app.InstrumentationRegistry;

@@ -80,6 +81,16 @@ public abstract class ShellTestCase {

    @After
    public void shellTearDown() {
        // In case someone set up a TestableLooper during the test, get rid of it because
        // TestableLooper intrinsically leaks all past test method member fields in a
        // big static list.
        //
        // TODO (b/261039202): don't use TestableLooper in WmShell tests at all.
        if (TestableLooper.get(this) != null) {
            TestableLooper.get(this).processAllMessages();
            TestableLooper.remove(this);
        }

        InstrumentationRegistry
                .getInstrumentation()
                .getUiAutomation()