• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.testing.local;
6 
7 import org.junit.runner.Description;
8 import org.junit.runner.manipulation.Filter;
9 
10 /** Filters tests based on the package. */
11 class PackageFilter extends Filter {
12 
13     private final String mFilterString;
14 
15     /** Creates the filter. */
PackageFilter(String filterString)16     public PackageFilter(String filterString) {
17         mFilterString = filterString;
18     }
19 
20     /**
21      *  Determines whether or not a test with the provided description should
22      *  run based on its package.
23      */
24     @Override
shouldRun(Description description)25     public boolean shouldRun(Description description) {
26         return description.getTestClass().getPackage().getName().equals(mFilterString);
27     }
28 
29     /** Returns a description of this filter. */
30     @Override
describe()31     public String describe() {
32         return "package-filter: " + mFilterString;
33     }
34 }
35