• 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 /**
11  *  Filters tests based on the package.
12  */
13 class PackageFilter extends Filter {
14 
15     private final String mFilterString;
16 
17     /**
18      *  Creates the filter.
19      */
PackageFilter(String filterString)20     public PackageFilter(String filterString) {
21         mFilterString = filterString;
22     }
23 
24     /**
25      *  Determines whether or not a test with the provided description should
26      *  run based on its package.
27      */
28     @Override
shouldRun(Description description)29     public boolean shouldRun(Description description) {
30         return description.getTestClass().getPackage().getName().equals(mFilterString);
31     }
32 
33     /**
34      *  Returns a description of this filter.
35      */
36     @Override
describe()37     public String describe() {
38         return "package-filter: " + mFilterString;
39     }
40 
41 }
42