From dc676e6881881c8d37d0d6a2dee270b9d63c07a9 Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Wed, 19 Apr 2023 21:32:41 +0200 Subject: [PATCH] Use ActivityTestRule as a Rule Rules are rules, and the rules are that @Rule rules go through ActivityStatement.evaluate, which among other things synchronously finishes the activity under test even if it was manually started. Bug: 276843259 Test: atest --iterations 100 ActivityThreadTest Change-Id: I6fd1bb00b587250192e84bcb70771eda1259d36b --- .../src/android/app/activity/ActivityThreadTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java b/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java index 4f91e7a3545a9..fb0f3d419002e 100644 --- a/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java +++ b/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java @@ -71,6 +71,7 @@ import androidx.test.runner.AndroidJUnit4; import com.android.internal.content.ReferrerIntent; import org.junit.After; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -95,7 +96,8 @@ public class ActivityThreadTest { // few sequence numbers the framework used to launch the test activity. private static final int BASE_SEQ = 10000; - private final ActivityTestRule mActivityTestRule = + @Rule + public final ActivityTestRule mActivityTestRule = new ActivityTestRule<>(TestActivity.class, true /* initialTouchMode */, false /* launchActivity */);