| Index: testing/android/java/src/org/chromium/testing/local/RunnerFilter.java
|
| diff --git a/testing/android/java/src/org/chromium/testing/local/RunnerFilter.java b/testing/android/java/src/org/chromium/testing/local/RunnerFilter.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..dd1b2972745455aa676548e94ee4e289e56e09c3
|
| --- /dev/null
|
| +++ b/testing/android/java/src/org/chromium/testing/local/RunnerFilter.java
|
| @@ -0,0 +1,51 @@
|
| +// 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.
|
| + */
|
| + public boolean shouldRun(Description description) {
|
| + try {
|
| + Class<?> c = Class.forName(description.getClassName());
|
| + if (c == null) {
|
| + System.err.println("Unable to find class: " + description.getClassName());
|
| + return false;
|
| + }
|
| + return c.isAnnotationPresent(RunWith.class)
|
| + && c.getAnnotation(RunWith.class).value() == mRunnerClass;
|
| + } catch (ClassNotFoundException e) {
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + /**
|
| + * Returns a description of this filter.
|
| + */
|
| + public String describe() {
|
| + return new String("runner-filter: " + mRunnerClass.toString());
|
| + }
|
| +
|
| +}
|
| +
|
|
|