Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2300)

Unified Diff: base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java

Issue 1519523002: [Android] Support conditional test disabling based on android.os.Build values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix one outdated use of SkipCheck Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base.gyp ('k') | base/test/android/javatests/src/org/chromium/base/test/BaseTestResult.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java
diff --git a/base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java b/base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java
index 58e5b1c4252e80d798a87494e07241df0a523057..8bf3d0fb454b9463ec303e091dc8ebceff432365 100644
--- a/base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java
+++ b/base/test/android/javatests/src/org/chromium/base/test/BaseInstrumentationTestRunner.java
@@ -19,10 +19,11 @@ import junit.framework.TestResult;
import org.chromium.base.Log;
import org.chromium.base.SysUtils;
import org.chromium.base.multidex.ChromiumMultiDex;
-import org.chromium.base.test.BaseTestResult.SkipCheck;
import org.chromium.base.test.util.CommandLineFlags;
+import org.chromium.base.test.util.DisableIfSkipCheck;
import org.chromium.base.test.util.MinAndroidSdkLevel;
import org.chromium.base.test.util.Restriction;
+import org.chromium.base.test.util.SkipCheck;
import org.chromium.test.reporter.TestStatusListener;
import java.lang.reflect.Method;
@@ -64,24 +65,21 @@ public class BaseInstrumentationTestRunner extends InstrumentationTestRunner {
protected void addTestHooks(BaseTestResult result) {
result.addSkipCheck(new MinAndroidSdkLevelSkipCheck());
result.addSkipCheck(new RestrictionSkipCheck());
+ result.addSkipCheck(new DisableIfSkipCheck());
result.addPreTestHook(CommandLineFlags.getRegistrationHook());
}
+
/**
* Checks if any restrictions exist and skip the test if it meets those restrictions.
*/
- public class RestrictionSkipCheck implements SkipCheck {
+ public class RestrictionSkipCheck extends SkipCheck {
@Override
public boolean shouldSkip(TestCase testCase) {
- Method method;
- try {
- method = testCase.getClass().getMethod(testCase.getName(), (Class[]) null);
- } catch (NoSuchMethodException e) {
- Log.e(TAG, "Unable to find %s in %s", testCase.getName(),
- testCase.getClass().getName(), e);
- return true;
- }
+ Method method = getTestMethod(testCase);
+ if (method == null) return true;
+
Restriction restrictions = method.getAnnotation(Restriction.class);
if (restrictions != null) {
for (String restriction : restrictions.value()) {
@@ -120,7 +118,7 @@ public class BaseInstrumentationTestRunner extends InstrumentationTestRunner {
/**
* Checks the device's SDK level against any specified minimum requirement.
*/
- public static class MinAndroidSdkLevelSkipCheck implements SkipCheck {
+ public static class MinAndroidSdkLevelSkipCheck extends SkipCheck {
/**
* If {@link MinAndroidSdkLevel} is present, checks its value
« no previous file with comments | « base/base.gyp ('k') | base/test/android/javatests/src/org/chromium/base/test/BaseTestResult.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698