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

Unified Diff: testing/android/junit/java/src/org/chromium/testing/local/RunnerFilter.java

Issue 596303002: Revert of Revert of [Android] JUnit runner + gyp changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@deps-changes
Patch Set: Created 6 years, 3 months 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
Index: testing/android/junit/java/src/org/chromium/testing/local/RunnerFilter.java
diff --git a/testing/android/junit/java/src/org/chromium/testing/local/RunnerFilter.java b/testing/android/junit/java/src/org/chromium/testing/local/RunnerFilter.java
new file mode 100644
index 0000000000000000000000000000000000000000..e32753e998676aa6dbde8388d9ce4a99681f2a5d
--- /dev/null
+++ b/testing/android/junit/java/src/org/chromium/testing/local/RunnerFilter.java
@@ -0,0 +1,45 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.testing.local;
+
+import org.junit.runner.Description;
+import org.junit.runner.RunWith;
+import org.junit.runner.manipulation.Filter;
+
+/**
+ * Filters tests based on the Runner class annotating the test class.
+ */
+class RunnerFilter extends Filter {
+
+ private final Class<?> mRunnerClass;
+
+ /**
+ * Creates the filter.
+ */
+ public RunnerFilter(Class<?> runnerClass) {
+ mRunnerClass = runnerClass;
+ }
+
+ /**
+ * Determines whether or not a test with the provided description should
+ * run based on the Runner class annotating the test class.
+ */
+ @Override
+ public boolean shouldRun(Description description) {
+ Class<?> c = description.getTestClass();
+ return c != null && c.isAnnotationPresent(RunWith.class)
+ && c.getAnnotation(RunWith.class).value() == mRunnerClass;
+ }
+
+ /**
+ * Returns a description of this filter.
+ */
+ @Override
+ public String describe() {
+ return "runner-filter: " + mRunnerClass.getName();
+ }
+
+}
+

Powered by Google App Engine
This is Rietveld 408576698