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

Commit c5482b12 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Attempt to reduce race of WmTests

WmTests contains both e2e and mocked unit tests. The mocked tests
are sensitive to concurrent issue. Such as if the activity is still
destroying on main thread, then when the next test starts to establish
mocked environment, it may throw ConcurrentModificationException
when iterating invocation records because there is additional access
from other thread.

This change waits until the test activities are destroyed, that avoids
overlapping with the next test.

Bug: 293549565
Bug: 254268165
Test: TaskStackChangedListenerTest
Change-Id: I1b2eb77585ba0a1ee936ee921af95e9c2113ec63
parent 89563b52
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@
        <activity android:name="com.android.server.wm.TaskStackChangedListenerTest$ActivityInVirtualDisplay"
                  android:resizeableActivity="true" />
        <activity android:name="com.android.server.wm.TaskStackChangedListenerTest$LandscapeActivity"
                  android:configChanges="screenLayout|screenSize|smallestScreenSize|orientation"
                  android:screenOrientation="sensorLandscape"
                  android:showWhenLocked="true"
                  android:turnScreenOn="true" />
+6 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import android.os.StrictMode;
import android.os.strictmode.InstanceCountViolation;
import android.util.Log;

import com.android.server.wm.utils.CommonUtils;

import org.junit.After;
import org.junit.Test;

@@ -63,6 +65,10 @@ public class ActivityLeakTests {
                activity.finish();
            }
        }
        if (!mStartedActivityList.isEmpty()) {
            CommonUtils.waitUntilActivityRemoved(
                    mStartedActivityList.get(mStartedActivityList.size() - 1));
        }
        mStartedActivityList.clear();
    }

+3 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ import android.window.TaskOrganizer;

import androidx.test.filters.MediumTest;

import com.android.server.wm.utils.CommonUtils;

import org.junit.Test;
import org.mockito.ArgumentCaptor;

@@ -172,6 +174,7 @@ public class ActivityOptionsTest {
            instrumentation.removeMonitor(monitor);
            if (mainActivity != null) {
                mainActivity.finish();
                CommonUtils.waitUntilActivityRemoved(mainActivity);
            }
        }
    }
+8 −0
Original line number Diff line number Diff line
@@ -56,6 +56,9 @@ import androidx.annotation.Nullable;
import androidx.test.filters.SmallTest;
import androidx.test.rule.ActivityTestRule;

import com.android.server.wm.utils.CommonUtils;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -90,6 +93,11 @@ public class ScreenshotTests {
        mInstrumentation.waitForIdleSync();
    }

    @After
    public void tearDown() {
        CommonUtils.waitUntilActivityRemoved(mActivity);
    }

    @Test
    public void testScreenshotSecureLayers() throws InterruptedException {
        SurfaceControl secureSC = new SurfaceControl.Builder()
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;

import com.android.server.wm.utils.CommonUtils;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -87,6 +89,7 @@ public class SurfaceControlViewHostTests {
    @After
    public void tearDown() {
        mInstrumentation.getUiAutomation().dropShellPermissionIdentity();
        CommonUtils.waitUntilActivityRemoved(mActivity);
    }

    @Test
Loading