Index: base/test/android/javatests/src/org/chromium/base/test/util/SkipCheck.java |
diff --git a/base/test/android/javatests/src/org/chromium/base/test/util/SkipCheck.java b/base/test/android/javatests/src/org/chromium/base/test/util/SkipCheck.java |
index 5f2b95e0f50165413709be41f6273d185f3b9d5a..33dea8346a21e9856a590a5641df9bb50d534a17 100644 |
--- a/base/test/android/javatests/src/org/chromium/base/test/util/SkipCheck.java |
+++ b/base/test/android/javatests/src/org/chromium/base/test/util/SkipCheck.java |
@@ -6,6 +6,8 @@ package org.chromium.base.test.util; |
import junit.framework.TestCase; |
+import org.junit.runners.model.FrameworkMethod; |
+ |
import org.chromium.base.Log; |
import java.lang.annotation.Annotation; |
@@ -23,24 +25,36 @@ public abstract class SkipCheck { |
/** |
* |
+ * Checks whether the given test method should be skipped. |
+ * |
+ * @param testMethod The test method to check. |
+ * @return Whether the test case should be skipped. |
+ */ |
+ public abstract boolean shouldSkip(FrameworkMethod testMethod); |
+ |
+ /** |
+ * |
* Checks whether the given test case should be skipped. |
* |
* @param testCase The test case to check. |
* @return Whether the test case should be skipped. |
*/ |
- public abstract boolean shouldSkip(TestCase testCase); |
- |
- protected static Method getTestMethod(TestCase testCase) { |
+ public boolean shouldSkip(TestCase testCase) { |
try { |
- return testCase.getClass().getMethod(testCase.getName(), (Class[]) null); |
+ Method m = testCase.getClass().getMethod(testCase.getName(), (Class[]) null); |
+ return shouldSkip(new FrameworkMethod(m)); |
} catch (NoSuchMethodException e) { |
Log.e(TAG, "Unable to find %s in %s", testCase.getName(), |
testCase.getClass().getName(), e); |
- return null; |
+ return false; |
} |
} |
- @SuppressWarnings("unchecked") |
+ protected static <T extends Annotation> List<T> getAnnotations(FrameworkMethod frameworkMethod, |
+ Class<T> annotationClass) { |
+ return getAnnotations(frameworkMethod.getMethod(), annotationClass); |
+ } |
+ |
protected static <T extends Annotation> List<T> getAnnotations(AnnotatedElement element, |
Class<T> annotationClass) { |
AnnotatedElement parent = (element instanceof Method) |
@@ -49,12 +63,8 @@ public abstract class SkipCheck { |
List<T> annotations = (parent == null) |
? new ArrayList<T>() |
: getAnnotations(parent, annotationClass); |
- Annotation[] allAnnotations = element.getAnnotations(); |
- for (Annotation a : allAnnotations) { |
- if (annotationClass.isInstance(a)) { |
- annotations.add((T) a); |
- } |
- } |
+ T annotation = element.getAnnotation(annotationClass); |
+ if (annotation != null) annotations.add(annotation); |
return annotations; |
} |
} |