1 /*
2  * Copyright (C) 2010 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 
17 package com.android.cts.tradefed.testtype;
18 
19 import com.android.ddmlib.testrunner.TestIdentifier;
20 import com.android.tradefed.targetprep.ITargetPreparer;
21 import com.android.tradefed.testtype.IAbi;
22 import com.android.tradefed.testtype.IRemoteTest;
23 
24 import java.io.File;
25 import java.util.Collection;
26 import java.util.List;
27 
28 /**
29  * Container for CTS test info.
30  * <p/>
31  * Knows how to translate this info into a runnable {@link IRemoteTest}.
32  */
33 public interface ITestPackageDef extends Comparable<ITestPackageDef> {
34 
35     /**
36      * Get the id of the test package.
37      * @return the {@link String} id
38      */
getId()39     public String getId();
40 
41     /**
42      * Creates a runnable {@link IRemoteTest} from info stored in this definition.
43      *
44      * @param testCaseDir {@link File} representing directory of test case data
45      * @return a {@link IRemoteTest} with all necessary data populated to run the test or
46      *         <code>null</code> if test could not be created
47      */
createTest(File testCaseDir)48     public IRemoteTest createTest(File testCaseDir);
49 
50     /**
51      * Get the collection of tests in this test package.
52      */
getTests()53     public Collection<TestIdentifier> getTests();
54 
55     /**
56      * Return the sha1sum of the binary file for this test package.
57      * <p/>
58      * Will only return a valid value after {@link #createTest(File)} has been called.
59      *
60      * @return the sha1sum in {@link String} form
61      */
getDigest()62     public String getDigest();
63 
64     /**
65      * @return the name of this test package.
66      */
getName()67     public String getName();
68 
69     /**
70      * @return the ABI of this test package.
71      */
getAbi()72     public IAbi getAbi();
73 
74     /**
75      * Set the filter to use for tests
76      *
77      * @param testFilter
78      */
setTestFilter(TestFilter testFilter)79     public void setTestFilter(TestFilter testFilter);
80 
81     /**
82      * Restrict this test package to run a specific class and method name
83      *
84      * @param className the test class to restrict this run to
85      * @param methodName the optional test method to restrict this run to, or <code>null</code> to
86      *            run all tests in class
87      */
setClassName(String className, String methodName)88     public void setClassName(String className, String methodName);
89 
90     /**
91      * Return the file name of this package's instrumentation target apk.
92      *
93      * @return the file name or <code>null</code> if not applicable.
94      */
getTargetApkName()95     public String getTargetApkName();
96 
97     /**
98      * Return the Android package name of this package's instrumentation target, or
99      * <code>null</code> if not applicable.
100      */
getTargetPackageName()101     public String getTargetPackageName();
102 
103     /**
104      * Return a list of preparers used for setup or teardown of test cases in this package
105      * @return
106      */
getPackagePreparers()107     public List<ITargetPreparer> getPackagePreparers();
108 }
109