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
This commit is contained in:
Robin Lee
2023-04-19 21:32:41 +02:00
parent de95bc0b31
commit dc676e6881

View File

@@ -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<TestActivity> mActivityTestRule =
@Rule
public final ActivityTestRule<TestActivity> mActivityTestRule =
new ActivityTestRule<>(TestActivity.class, true /* initialTouchMode */,
false /* launchActivity */);