diff options
Diffstat (limited to 'ravenwood/junit-src')
3 files changed, 20 insertions, 25 deletions
diff --git a/ravenwood/junit-src/android/platform/test/annotations/DisabledOnNonRavenwood.java b/ravenwood/junit-src/android/platform/test/annotations/DisabledOnNonRavenwood.java index 8ca34bafc2c6..9d47f3a6bc5d 100644 --- a/ravenwood/junit-src/android/platform/test/annotations/DisabledOnNonRavenwood.java +++ b/ravenwood/junit-src/android/platform/test/annotations/DisabledOnNonRavenwood.java @@ -31,13 +31,17 @@ import java.lang.annotation.Target; * which means if a test class has this annotation, you can't negate it in subclasses or * on a per-method basis. * + * THIS ANNOTATION CANNOT BE ADDED TO CLASSES AT THIS PONINT. + * See {@link com.android.platform.test.ravenwood.bivalenttest.RavenwoodClassRuleRavenwoodOnlyTest} + * for the reason. + * * The {@code RAVENWOOD_RUN_DISABLED_TESTS} environmental variable won't work because it won't be * propagated to the device. (We may support it in the future, possibly using a debug. sysprop.) * * @hide */ @Inherited -@Target({ElementType.METHOD, ElementType.TYPE}) +@Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface DisabledOnNonRavenwood { /** diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodClassRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodClassRule.java index 9a4d4886d6f0..f4b7ec360dbf 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodClassRule.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodClassRule.java @@ -25,6 +25,7 @@ import static android.platform.test.ravenwood.RavenwoodRule.shouldStillIgnoreInP import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.EnabledOnRavenwood; +import org.junit.Assert; import org.junit.Assume; import org.junit.rules.TestRule; import org.junit.runner.Description; @@ -41,27 +42,16 @@ import org.junit.runners.model.Statement; public class RavenwoodClassRule implements TestRule { @Override public Statement apply(Statement base, Description description) { - // No special treatment when running outside Ravenwood; run tests as-is if (!IS_ON_RAVENWOOD) { - Assume.assumeTrue(shouldEnableOnDevice(description)); - return base; - } - - if (ENABLE_PROBE_IGNORED) { + // This should be "Assume", not Assert, but if we use assume here, the device side + // test runner would complain. + // See the TODO comment in RavenwoodClassRuleRavenwoodOnlyTest. + Assert.assertTrue(shouldEnableOnDevice(description)); + } else if (ENABLE_PROBE_IGNORED) { Assume.assumeFalse(shouldStillIgnoreInProbeIgnoreMode(description)); - // Pass through to possible underlying RavenwoodRule for both environment - // configuration and handling method-level annotations - return base; } else { - return new Statement() { - @Override - public void evaluate() throws Throwable { - Assume.assumeTrue(shouldEnableOnRavenwood(description)); - // Pass through to possible underlying RavenwoodRule for both environment - // configuration and handling method-level annotations - base.evaluate(); - } - }; + Assume.assumeTrue(shouldEnableOnRavenwood(description)); } + return base; } } diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java index 52ea3402fa62..a2e8ec17bbf7 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java @@ -28,7 +28,6 @@ import android.platform.test.annotations.DisabledOnNonRavenwood; import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.EnabledOnRavenwood; import android.platform.test.annotations.IgnoreUnderRavenwood; -import android.util.ArraySet; import org.junit.Assume; import org.junit.rules.TestRule; @@ -278,6 +277,9 @@ public class RavenwoodRule implements TestRule { return false; } } + if (description.getTestClass().getAnnotation(DisabledOnNonRavenwood.class) != null) { + return false; + } return true; } @@ -413,10 +415,9 @@ public class RavenwoodRule implements TestRule { }; } - /** - * Do not use it outside ravenwood core classes. - */ - public boolean _ravenwood_private$isOptionalValidationEnabled() { - return ENABLE_OPTIONAL_VALIDATION; + public static class _$RavenwoodPrivate { + public static boolean isOptionalValidationEnabled() { + return ENABLE_OPTIONAL_VALIDATION; + } } } |