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