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.cts.tradefed.targetprep;
17 
18 import com.android.cts.tradefed.build.CtsBuildHelper;
19 import com.android.tradefed.build.IBuildInfo;
20 import com.android.tradefed.config.OptionClass;
21 import com.android.tradefed.targetprep.PushFilePreparer;
22 
23 import java.io.File;
24 
25 /**
26  * Pushes specified testing artifacts from CTS test case repository
27  */
28 @OptionClass(alias="cts-file-pusher")
29 public class CtsFilePusher extends PushFilePreparer {
30 
31     private CtsBuildHelper mBuildHelper;
32 
getCtsBuildHelper(IBuildInfo buildInfo)33     protected CtsBuildHelper getCtsBuildHelper(IBuildInfo buildInfo) {
34         if (mBuildHelper == null) {
35             mBuildHelper = CtsBuildHelper.createBuildHelper(buildInfo);
36         }
37         return mBuildHelper;
38     }
39 
40     /**
41      * {@inheritDoc}
42      */
43     @Override
resolveRelativeFilePath(IBuildInfo buildInfo, String fileName)44     public File resolveRelativeFilePath(IBuildInfo buildInfo, String fileName) {
45         return new File(getCtsBuildHelper(buildInfo).getTestCasesDir(), fileName);
46     }
47 }
48