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.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.config.OptionSetter; 22 import com.android.tradefed.util.FileUtil; 23 24 import junit.framework.TestCase; 25 26 import java.io.File; 27 28 /** 29 * Tests for cts-tradefed. 30 */ 31 public class CtsTradefedTest extends TestCase { 32 33 private static final String PROPERTY_NAME = "CTS_ROOT"; 34 private static final String SUITE_FULL_NAME = "Compatibility Test Suite"; 35 private static final String SUITE_NAME = "CTS"; 36 private static final String SUITE_PLAN = "cts"; 37 private static final String DYNAMIC_CONFIG_URL = ""; 38 39 private String mOriginalProperty = null; 40 41 @Override setUp()42 protected void setUp() throws Exception { 43 super.setUp(); 44 mOriginalProperty = System.getProperty(PROPERTY_NAME); 45 } 46 47 @Override tearDown()48 protected void tearDown() throws Exception { 49 if (mOriginalProperty != null) { 50 System.setProperty(PROPERTY_NAME, mOriginalProperty); 51 } 52 super.tearDown(); 53 } 54 testSuiteInfoLoad()55 public void testSuiteInfoLoad() throws Exception { 56 // Test the values in the manifest can be loaded 57 File root = FileUtil.createTempDir("root"); 58 System.setProperty(PROPERTY_NAME, root.getAbsolutePath()); 59 File base = new File(root, "android-cts"); 60 base.mkdirs(); 61 File tests = new File(base, "testcases"); 62 tests.mkdirs(); 63 CompatibilityBuildProvider provider = new CompatibilityBuildProvider(); 64 OptionSetter setter = new OptionSetter(provider); 65 setter.setOptionValue("plan", SUITE_PLAN); 66 setter.setOptionValue("dynamic-config-url", DYNAMIC_CONFIG_URL); 67 IBuildInfo info = provider.getBuild(); 68 CompatibilityBuildHelper helper = new CompatibilityBuildHelper(info); 69 assertEquals("Incorrect suite full name", SUITE_FULL_NAME, helper.getSuiteFullName()); 70 assertEquals("Incorrect suite name", SUITE_NAME, helper.getSuiteName()); 71 FileUtil.recursiveDelete(root); 72 } 73 } 74