summaryrefslogtreecommitdiff
path: root/ravenwood/junit-src
diff options
context:
space:
mode:
author John Wu <topjohnwu@google.com> 2024-10-26 02:39:21 +0000
committer John Wu <topjohnwu@google.com> 2024-10-26 02:39:21 +0000
commitcd90e326c2855d2bc3447b4c16b7b08d8502f0e1 (patch)
treeb79be969f2ecd3777e3f37d2d64bac5c4831ab3b /ravenwood/junit-src
parent768fc687a818cde61fde6f34c0c750fd13d2db77 (diff)
[Ravenwood] Update RATR to setup environment ASAP
- Remove the workaround to record constructor exceptions and throw later, runner errors are handled properly after aosp/3310766 - Initialize Ravenwood's environment as soon as the real inner runner is instantiated, as in some cases getDescription() itself needs env setup - Make the entire environment tied to a RATR instance - Add new tests to make sure the early environment setup is working Flag: EXEMPT host test change only Bug: 356918135 Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh Change-Id: I301607fd6602649172f16991d6d5ae1b577c47cd
Diffstat (limited to 'ravenwood/junit-src')
-rw-r--r--ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerBase.java2
-rw-r--r--ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java8
2 files changed, 5 insertions, 5 deletions
diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerBase.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerBase.java
index 7c72f6bd8619..31a14164bd51 100644
--- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerBase.java
+++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerBase.java
@@ -74,7 +74,7 @@ abstract class RavenwoodAwareTestRunnerBase extends Runner implements Filterable
}
@Override
- public Description getDescription() {
+ public final Description getDescription() {
return getRealRunner().getDescription();
}
diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
index 773dba1b4620..3d6ac0f37050 100644
--- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
+++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
@@ -24,6 +24,8 @@ import android.app.Instrumentation;
import android.content.Context;
import android.platform.test.annotations.DisabledOnRavenwood;
+import androidx.test.platform.app.InstrumentationRegistry;
+
import com.android.ravenwood.common.RavenwoodCommonUtils;
import org.junit.rules.TestRule;
@@ -219,8 +221,7 @@ public final class RavenwoodRule implements TestRule {
*/
@Deprecated
public Context getContext() {
- return Objects.requireNonNull(mConfiguration.mInstContext,
- "Context is only available during @Test execution");
+ return InstrumentationRegistry.getInstrumentation().getContext();
}
/**
@@ -230,8 +231,7 @@ public final class RavenwoodRule implements TestRule {
*/
@Deprecated
public Instrumentation getInstrumentation() {
- return Objects.requireNonNull(mConfiguration.mInstrumentation,
- "Instrumentation is only available during @Test execution");
+ return InstrumentationRegistry.getInstrumentation();
}
@Override