1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.cts.tradefed.testtype;
17 
18 import com.android.cts.tradefed.UnitTests;
19 
20 import junit.framework.TestCase;
21 
22 /**
23  * Unit tests for {@link GeeTest}.
24  */
25 public class GeeTestTest extends TestCase {
26 
27     /**
28      * {@inheritDoc}
29      */
30     @Override
setUp()31     protected void setUp() throws Exception {
32         super.setUp();
33     }
34 
35      /**
36      * Test {@link GeeTestTest#getGTestFilters}
37      * @throws DeviceNotAvailableException
38      */
testGetGTestFilters()39     public void testGetGTestFilters() {
40         GeeTest test = new GeeTest("package_foo", "exe_foo");
41         test.setPositiveFilters("a");
42         test.setNegativeFilters("b");
43         String actual = test.getGTestFilters();
44         assertEquals("--gtest_filter=a:-b", actual);
45     }
46 
47     /**
48      * Test {@link GeeTestTest#getGTestFilters} with only positive filters
49      * @throws DeviceNotAvailableException
50      */
testGetGTestFiltersPositiveOnly()51     public void testGetGTestFiltersPositiveOnly() {
52         GeeTest test = new GeeTest("package_foo", "exe_foo");
53         test.setPositiveFilters("a");
54         String actual = test.getGTestFilters();
55         assertEquals("--gtest_filter=a", actual);
56     }
57 
58     /**
59      * Test {@link GeeTestTest#getGTestFilters} with only negative filters
60      * @throws DeviceNotAvailableException
61      */
testGetGTestFiltersNegativeOnly()62     public void testGetGTestFiltersNegativeOnly() {
63         GeeTest test = new GeeTest("package_foo", "exe_foo");
64         test.setNegativeFilters("b");
65         String actual = test.getGTestFilters();
66         assertEquals("--gtest_filter=-b", actual);
67     }
68 
69     /**
70      * Test {@link GeeTestTest#getGTestFilters} with empty filters
71      * @throws DeviceNotAvailableException
72      */
testGetGTestFiltersWithNoFilters()73     public void testGetGTestFiltersWithNoFilters() {
74         GeeTest test = new GeeTest("package_foo", "exe_foo");
75         String actual = test.getGTestFilters();
76         assertEquals("", actual);
77     }
78 }
79