1 /*
2  * Copyright (C) 2018 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.tradefed.build;
18 
19 import java.io.File;
20 import java.io.IOException;
21 
22 /**
23  * A {@link IBuildInfo} that represents an Android application and its test package(s).
24  */
25 public class TestzipBuildInfo extends BuildInfo implements ITestzipBuildInfo {
26 
27     private static final long serialVersionUID = BuildSerializedVersion.VERSION;
28     private static final String TESTDIR_IMAGE_NAME = "testsdir";
29 
30     /**
31      * Creates a {@link TestzipBuildInfo}.
32      *
33      * @param buildId the unique build id
34      * @param buildName the build name
35      */
TestzipBuildInfo(String buildId, String buildName)36     public TestzipBuildInfo(String buildId, String buildName) {
37         super(buildId, buildName);
38     }
39 
40     /**
41      * @see BuildInfo#BuildInfo(BuildInfo)
42      */
TestzipBuildInfo(BuildInfo buildToCopy)43     public TestzipBuildInfo(BuildInfo buildToCopy) {
44         super(buildToCopy);
45     }
46 
47     /**
48      * {@inheritDoc}
49      */
50     @Override
getTestzipDir()51     public File getTestzipDir() {
52         return getFile(TESTDIR_IMAGE_NAME);
53     }
54 
55     /**
56      * {@inheritDoc}
57      */
58     @Override
getTestzipDirVersion()59     public String getTestzipDirVersion() {
60         return getVersion(TESTDIR_IMAGE_NAME);
61     }
62 
63     /**
64      * {@inheritDoc}
65      */
66     @Override
setTestzipDir(File testsDir, String version)67     public void setTestzipDir(File testsDir, String version) {
68         setFile(TESTDIR_IMAGE_NAME, testsDir, version);
69     }
70 
71     /**
72      * {@inheritDoc}
73      */
74     @Override
clone()75     public IBuildInfo clone() {
76         AppBuildInfo copy = new AppBuildInfo(getBuildId(), getBuildTargetName());
77         copy.addAllBuildAttributes(this);
78         try {
79             copy.addAllFiles(this);
80         } catch (IOException e) {
81             throw new RuntimeException(e);
82         }
83         copy.setBuildBranch(getBuildBranch());
84         copy.setBuildFlavor(getBuildFlavor());
85 
86         return copy;
87     }
88 }
89