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         System.setProperty(PROPERTY_NAME, mOriginalProperty);
50         super.tearDown();
51     }
52 
testSuiteInfoLoad()53     public void testSuiteInfoLoad() throws Exception {
54         // Test the values in the manifest can be loaded
55         File root = FileUtil.createTempDir("root");
56         System.setProperty(PROPERTY_NAME, root.getAbsolutePath());
57         File base = new File(root, "android-cts");
58         base.mkdirs();
59         File tests = new File(base, "testcases");
60         tests.mkdirs();
61         CompatibilityBuildProvider provider = new CompatibilityBuildProvider();
62         OptionSetter setter = new OptionSetter(provider);
63         setter.setOptionValue("plan", SUITE_PLAN);
64         setter.setOptionValue("dynamic-config-url", DYNAMIC_CONFIG_URL);
65         IBuildInfo info = provider.getBuild();
66         CompatibilityBuildHelper helper = new CompatibilityBuildHelper(info);
67         assertEquals("Incorrect suite full name", SUITE_FULL_NAME, helper.getSuiteFullName());
68         assertEquals("Incorrect suite name", SUITE_NAME, helper.getSuiteName());
69         FileUtil.recursiveDelete(root);
70     }
71 }
72