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

Commit 07284915 authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Tear down VD in test to ensure it doesn't interfere with other tests

If the VD is not torn down, it can still be executing code using the
same StubTransaction. The tests assert things on the StubTransaction so
other VD running on the same StubTransaction can interfere with the
test.

Test: ContentRecorderTests
Fixes: 242115683
Change-Id: I353659c17e9b84661d6437144b980ab3aaacae3f
parent 864e6a79
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -78,6 +78,8 @@ public class ContentRecorderTests extends WindowTestsBase {
    private ConfigListener mConfigListener;
    private CountDownLatch mLatch;

    private VirtualDisplay mVirtualDisplay;

    @Before public void setUp() {
        // GIVEN SurfaceControl can successfully mirror the provided surface.
        sSurfaceSize = new Point(
@@ -86,10 +88,10 @@ public class ContentRecorderTests extends WindowTestsBase {
        mRecordedSurface = surfaceControlMirrors(sSurfaceSize);

        // GIVEN the VirtualDisplay associated with the session (so the display has state ON).
        VirtualDisplay virtualDisplay = mWm.mDisplayManager.createVirtualDisplay("VirtualDisplay",
        mVirtualDisplay = mWm.mDisplayManager.createVirtualDisplay("VirtualDisplay",
                sSurfaceSize.x, sSurfaceSize.y,
                DisplayMetrics.DENSITY_140, new Surface(), VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR);
        final int displayId = virtualDisplay.getDisplay().getDisplayId();
        final int displayId = mVirtualDisplay.getDisplay().getDisplayId();
        mWm.mRoot.onDisplayAdded(displayId);
        final DisplayContent virtualDisplayContent = mWm.mRoot.getDisplayContent(displayId);
        mContentRecorder = new ContentRecorder(virtualDisplayContent);
@@ -116,6 +118,8 @@ public class ContentRecorderTests extends WindowTestsBase {
    @After
    public void teardown() {
        DeviceConfig.removeOnPropertiesChangedListener(mConfigListener);
        mVirtualDisplay.release();
        mWm.mRoot.onDisplayRemoved(mVirtualDisplay.getDisplay().getDisplayId());
    }

    @Test