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 17 package com.android.compatibility.common.util; 18 19 import junit.framework.TestCase; 20 21 /** 22 * Unit tests for {@link TestFilter} 23 */ 24 public class TestFilterTest extends TestCase { 25 26 private static final String NAME = "ModuleName"; 27 private static final String ABI = "mips64"; 28 private static final String TEST = "com.android.foobar.Blah#testAllTheThings"; 29 private static final String NAME_FILTER = String.format("%s", NAME); 30 private static final String ABI_NAME_FILTER = String.format("%s %s", ABI, NAME); 31 private static final String NAME_TEST_FILTER = String.format("%s %s", NAME, TEST); 32 private static final String FULL_FILTER = String.format("%s %s %s", ABI, NAME, TEST); 33 testParseNameFilter()34 public void testParseNameFilter() { 35 TestFilter filter = TestFilter.createFrom(NAME_FILTER); 36 assertNull("Incorrect abi", filter.getAbi()); 37 assertEquals("Incorrect name", NAME, filter.getName()); 38 assertNull("Incorrect test", filter.getTest()); 39 } 40 testParseAbiNameFilter()41 public void testParseAbiNameFilter() { 42 TestFilter filter = TestFilter.createFrom(ABI_NAME_FILTER); 43 assertEquals("Incorrect abi", ABI, filter.getAbi()); 44 assertEquals("Incorrect name", NAME, filter.getName()); 45 assertNull("Incorrect test", filter.getTest()); 46 } 47 testParseNameTestFilter()48 public void testParseNameTestFilter() { 49 TestFilter filter = TestFilter.createFrom(NAME_TEST_FILTER); 50 assertNull("Incorrect abi", filter.getAbi()); 51 assertEquals("Incorrect name", NAME, filter.getName()); 52 assertEquals("Incorrect test", TEST, filter.getTest()); 53 } 54 testParseFullFilter()55 public void testParseFullFilter() { 56 TestFilter filter = TestFilter.createFrom(FULL_FILTER); 57 assertEquals("Incorrect abi", ABI, filter.getAbi()); 58 assertEquals("Incorrect name", NAME, filter.getName()); 59 assertEquals("Incorrect test", TEST, filter.getTest()); 60 } 61 testCreateNameFilter()62 public void testCreateNameFilter() { 63 TestFilter filter = new TestFilter(null, NAME, null); 64 assertEquals("Incorrect filter", NAME_FILTER, filter.toString()); 65 } 66 testCreateAbiNameFilter()67 public void testCreateAbiNameFilter() { 68 TestFilter filter = new TestFilter(ABI, NAME, null); 69 assertEquals("Incorrect filter", ABI_NAME_FILTER, filter.toString()); 70 } 71 testCreateNameTestFilter()72 public void testCreateNameTestFilter() { 73 TestFilter filter = new TestFilter(null, NAME, TEST); 74 assertEquals("Incorrect filter", NAME_TEST_FILTER, filter.toString()); 75 } 76 testCreateFullFilter()77 public void testCreateFullFilter() { 78 TestFilter filter = new TestFilter(ABI, NAME, TEST); 79 assertEquals("Incorrect filter", FULL_FILTER, filter.toString()); 80 } 81 82 } 83