1 /* 2 * Copyright (C) 2022 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 android.signature.cts.api; 17 18 import android.signature.cts.ApiComplianceChecker; 19 import android.signature.cts.ApiDocumentParser; 20 import java.util.function.Supplier; 21 22 /** 23 * Base class of the tests that check accessibility of API signatures at runtime. 24 */ 25 public class AbstractSignatureTest extends AbstractApiTest { 26 27 private static final String TAG = AbstractSignatureTest.class.getSimpleName(); 28 29 /** 30 * The name of the instrumentation option that contains the list of the current API signatures 31 * that are expected to be accessible. 32 */ 33 protected static final String EXPECTED_API_FILES_ARG = "expected-api-files"; 34 35 /** 36 * The name of the instrumentation option that contains the list of the previous API signatures 37 * that are expected to be accessible. 38 */ 39 protected static final String PREVIOUS_API_FILES_ARG = "previous-api-files"; 40 41 /** 42 * Supplier of the list of files specified in the instrumentation argument "base-api-files". 43 */ 44 private static final Supplier<String[]> BASE_API_FILES = 45 getSupplierOfAnOptionalCommaSeparatedListArgument("base-api-files"); 46 47 /** 48 * Load the base API files into the supplied compliance checker. 49 * 50 * <p>Base API files are not checked by the compliance checker but may be extended by classes 51 * which are checked.</p> 52 * 53 * @param complianceChecker the {@link ApiComplianceChecker} into which the base API will be 54 * loaded. 55 */ loadBaseClasses(ApiComplianceChecker complianceChecker)56 protected void loadBaseClasses(ApiComplianceChecker complianceChecker) { 57 ApiDocumentParser apiDocumentParser = new ApiDocumentParser(TAG); 58 parseApiResourcesAsStream(apiDocumentParser, BASE_API_FILES.get()) 59 .forEach(complianceChecker::addBaseClass); 60 } 61 } 62