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.common.tradefed.testtype;
17 
18 import com.android.tradefed.build.IBuildInfo;
19 import com.android.tradefed.config.Option;
20 import com.android.tradefed.device.DeviceNotAvailableException;
21 import com.android.tradefed.result.ITestInvocationListener;
22 import com.android.tradefed.testtype.IAbi;
23 import com.android.tradefed.testtype.IAbiReceiver;
24 import com.android.tradefed.testtype.IBuildReceiver;
25 import com.android.tradefed.testtype.IRemoteTest;
26 import com.android.tradefed.testtype.IRuntimeHintProvider;
27 import com.android.tradefed.testtype.IShardableTest;
28 import com.android.tradefed.testtype.ITestCollector;
29 import com.android.tradefed.testtype.ITestFilterReceiver;
30 
31 import junit.framework.Assert;
32 
33 import java.util.ArrayList;
34 import java.util.Collection;
35 import java.util.List;
36 import java.util.Set;
37 
38 public class ShardableTestStub implements IRemoteTest, IShardableTest, IBuildReceiver,
39         IAbiReceiver, IRuntimeHintProvider, ITestCollector, ITestFilterReceiver {
40 
41     @Option(name = "module")
42     String mModule;
43     @Option(name = "foo")
44     String mFoo;
45     @Option(name = "blah")
46     String mBlah;
47 
48     public IBuildInfo mBuildInfo = null;
49 
50     Collection<IRemoteTest> mShards;
51 
52     /**
53      * {@inheritDoc}
54      */
55     @Override
setBuild(IBuildInfo buildInfo)56     public void setBuild(IBuildInfo buildInfo) {
57         mBuildInfo = buildInfo;
58     }
59 
60     /**
61      * {@inheritdoc}
62      */
63     @Override
run(ITestInvocationListener listener)64     public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
65         // Do nothing
66     }
67 
68     /**
69      * {@inheritDoc}
70      */
71     @Override
split()72     public Collection<IRemoteTest> split() {
73         Assert.assertNotNull(mBuildInfo);
74 
75         mShards = new ArrayList<>();
76         for (int i = 0; i < 3; i++) {
77             mShards.add(new ShardableTestStub());
78         }
79         return mShards;
80     }
81 
82     @Override
setAbi(IAbi abi)83     public void setAbi(IAbi abi) {
84         // Do nothing
85     }
86 
87     @Override
getRuntimeHint()88     public long getRuntimeHint() {
89         return 1L;
90     }
91 
92     @Override
setCollectTestsOnly(boolean shouldCollectTest)93     public void setCollectTestsOnly(boolean shouldCollectTest) {
94         // Do nothing
95     }
96 
97     @Override
addIncludeFilter(String filter)98     public void addIncludeFilter(String filter) {
99 
100     }
101 
102     @Override
addAllIncludeFilters(Set<String> filters)103     public void addAllIncludeFilters(Set<String> filters) {
104 
105     }
106 
107     @Override
addExcludeFilter(String filter)108     public void addExcludeFilter(String filter) {
109 
110     }
111 
112     @Override
addAllExcludeFilters(Set<String> filters)113     public void addAllExcludeFilters(Set<String> filters) {
114 
115     }
116 
117 }
118