1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package org.chromium.testing.local;
6
7import org.junit.runner.Description;
8import org.junit.runner.manipulation.Filter;
9
10/**
11 *  Filters tests based on the package.
12 */
13class PackageFilter extends Filter {
14
15    private final String mFilterString;
16
17    /**
18     *  Creates the filter.
19     */
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
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
37    public String describe() {
38        return "package-filter: " + mFilterString;
39    }
40
41}
42