1 /*
2  * Copyright (C) 2019 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.*;
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.util.FileUtil;
24 
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.junit.runners.JUnit4;
28 
29 import java.io.File;
30 
31 /**
32  * Tests for mts-tradefed.
33  */
34 @RunWith(JUnit4.class)
35 public class MtsTradefedTest {
36 
37     private static final String PROPERTY_NAME = "MTS_ROOT";
38     private static final String SUITE_FULL_NAME = "Mainline Test Suite";
39     private static final String SUITE_NAME = "MTS";
40 
41     @Test
testSuiteInfoLoad()42     public void testSuiteInfoLoad() throws Exception {
43         // Test the values in the manifest can be loaded
44         File root = FileUtil.createTempDir("root");
45         System.setProperty(PROPERTY_NAME, root.getAbsolutePath());
46         File base = new File(root, "android-mts");
47         base.mkdirs();
48         File tests = new File(base, "testcases");
49         tests.mkdirs();
50         CompatibilityBuildProvider provider = new CompatibilityBuildProvider() {
51             @Override
52             protected String getSuiteInfoName() {
53                 return SUITE_NAME;
54             }
55             @Override
56             protected String getSuiteInfoFullname() {
57                 return SUITE_FULL_NAME;
58             }
59         };
60         IBuildInfo info = provider.getBuild();
61         CompatibilityBuildHelper helper = new CompatibilityBuildHelper(info);
62         assertEquals("Incorrect suite full name", SUITE_FULL_NAME, helper.getSuiteFullName());
63         assertEquals("Incorrect suite name", SUITE_NAME, helper.getSuiteName());
64         FileUtil.recursiveDelete(root);
65         System.clearProperty(PROPERTY_NAME);
66     }
67 }
68 
69