1 /* 2 * Copyright (C) 2021 Google LLC. 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.compatibility.tradefed; 17 18 import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper; 19 import com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider; 20 import com.android.tradefed.build.IBuildInfo; 21 import com.android.tradefed.util.FileUtil; 22 23 import junit.framework.TestCase; 24 25 import java.io.File; 26 27 /** Tests for cat-tradefed. */ 28 public class CatBoxTradefedTest extends TestCase { 29 private static final String PROPERTY_NAME = "CATBOX_ROOT"; 30 private static final String SUITE_FULL_NAME = "Complete Automotive Test Suite"; 31 private static final String SUITE_NAME = "CATBOX"; 32 testSuiteInfoLoad()33 public void testSuiteInfoLoad() throws Exception { 34 // Test the values in the manifest can be loaded 35 File root = FileUtil.createTempDir("root"); 36 System.setProperty(PROPERTY_NAME, root.getAbsolutePath()); 37 File base = new File(root, "android-catbox"); 38 base.mkdirs(); 39 File tests = new File(base, "testcases"); 40 tests.mkdirs(); 41 CompatibilityBuildProvider provider = 42 new CompatibilityBuildProvider() { 43 @Override 44 protected String getSuiteInfoName() { 45 return SUITE_NAME; 46 } 47 48 @Override 49 protected String getSuiteInfoFullname() { 50 return SUITE_FULL_NAME; 51 } 52 }; 53 IBuildInfo info = provider.getBuild(); 54 CompatibilityBuildHelper helper = new CompatibilityBuildHelper(info); 55 assertEquals("Incorrect suite full name", SUITE_FULL_NAME, helper.getSuiteFullName()); 56 assertEquals("Incorrect suite name", SUITE_NAME, helper.getSuiteName()); 57 FileUtil.recursiveDelete(root); 58 System.clearProperty(PROPERTY_NAME); 59 } 60 } 61