aboutsummaryrefslogtreecommitdiff
path: root/builder-test-api
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2013-04-02 18:25:11 -0700
committerXavier Ducrohet <xav@android.com>2013-04-29 18:15:56 -0700
commit4a93a6c8ec2772bd9da623a5527d53f338b2727c (patch)
tree21f71942ad23905dc20887bbaacb8bd78fee6570 /builder-test-api
parent7ec84fe75cbb5329eca36ff88b378092827371ad (diff)
downloadbuild-4a93a6c8ec2772bd9da623a5527d53f338b2727c.tar.gz
Refactor test tasks into customizable components.
TestRunner and DeviceConnector allows having different ways to run tests and different ways to connect to devices. Change-Id: I70353965f166d684f1a9193d85c0e11e204aba33
Diffstat (limited to 'builder-test-api')
-rw-r--r--builder-test-api/build.gradle53
-rw-r--r--builder-test-api/src/main/java/com/android/builder/testing/api/DeviceConnector.java36
-rw-r--r--builder-test-api/src/main/java/com/android/builder/testing/api/DeviceException.java28
-rw-r--r--builder-test-api/src/main/java/com/android/builder/testing/api/DeviceProvider.java35
-rw-r--r--builder-test-api/src/main/java/com/android/builder/testing/api/TestRunner.java41
-rw-r--r--builder-test-api/src/main/java/com/android/builder/testing/api/TestServer.java31
6 files changed, 224 insertions, 0 deletions
diff --git a/builder-test-api/build.gradle b/builder-test-api/build.gradle
new file mode 100644
index 0000000..11c3973
--- /dev/null
+++ b/builder-test-api/build.gradle
@@ -0,0 +1,53 @@
+apply plugin: 'java'
+apply plugin: 'maven'
+apply plugin: 'signing'
+apply plugin: 'clone-artifacts'
+
+dependencies {
+ compile "com.android.tools.ddms:ddmlib:$project.ext.baseAndroidVersion"
+}
+
+def getVersion() {
+ if (project.has("release")) {
+ return project.ext.baseVersion
+ }
+
+ return project.ext.baseVersion + '-SNAPSHOT'
+}
+
+version = getVersion()
+archivesBaseName = 'builder-test-api'
+
+task publishLocal(type: Upload) {
+ configuration = configurations.archives
+ repositories {
+ mavenDeployer {
+ repository(url: uri("$rootProject.ext.androidHostOut/repo"))
+ }
+ }
+}
+
+// custom tasks for creating source/javadoc jars
+task sourcesJar(type: Jar, dependsOn:classes) {
+ classifier = 'sources'
+ from sourceSets.main.allSource
+}
+
+javadoc {
+ exclude "**/internal/**"
+ options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
+
+ title "Android Model"
+}
+
+task javadocJar(type: Jar, dependsOn:javadoc) {
+ classifier 'javadoc'
+ from javadoc.destinationDir
+}
+
+// add javadoc/source jar tasks as artifacts
+artifacts {
+ archives jar
+ archives sourcesJar
+ archives javadocJar
+}
diff --git a/builder-test-api/src/main/java/com/android/builder/testing/api/DeviceConnector.java b/builder-test-api/src/main/java/com/android/builder/testing/api/DeviceConnector.java
new file mode 100644
index 0000000..740af07
--- /dev/null
+++ b/builder-test-api/src/main/java/com/android/builder/testing/api/DeviceConnector.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.builder.testing.api;
+
+import com.android.annotations.NonNull;
+import com.android.ddmlib.IShellEnabledDevice;
+import com.android.ddmlib.TimeoutException;
+
+import java.io.File;
+
+/**
+ * A connector to a device to install/uninstall APKs, and run shell command.
+ */
+public interface DeviceConnector extends IShellEnabledDevice {
+
+ void connect(int timeOut) throws TimeoutException;
+ void disconnect(int timeOut) throws TimeoutException;
+
+ void installPackage(@NonNull File apkFile) throws DeviceException;
+
+ void uninstallPackage(@NonNull String packageName) throws DeviceException;
+}
diff --git a/builder-test-api/src/main/java/com/android/builder/testing/api/DeviceException.java b/builder-test-api/src/main/java/com/android/builder/testing/api/DeviceException.java
new file mode 100644
index 0000000..b0627db
--- /dev/null
+++ b/builder-test-api/src/main/java/com/android/builder/testing/api/DeviceException.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.builder.testing.api;
+
+import com.android.annotations.NonNull;
+
+/**
+ */
+public class DeviceException extends Exception {
+
+ public DeviceException(@NonNull Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/builder-test-api/src/main/java/com/android/builder/testing/api/DeviceProvider.java b/builder-test-api/src/main/java/com/android/builder/testing/api/DeviceProvider.java
new file mode 100644
index 0000000..be7bf55
--- /dev/null
+++ b/builder-test-api/src/main/java/com/android/builder/testing/api/DeviceProvider.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.builder.testing.api;
+
+import com.android.annotations.NonNull;
+
+import java.util.List;
+
+/**
+ * Provides a list of remote or local devices.
+ */
+public interface DeviceProvider {
+
+ @NonNull
+ String getName();
+
+ @NonNull
+ List<? extends DeviceConnector> getDevices();
+
+ void init() throws DeviceException;
+}
diff --git a/builder-test-api/src/main/java/com/android/builder/testing/api/TestRunner.java b/builder-test-api/src/main/java/com/android/builder/testing/api/TestRunner.java
new file mode 100644
index 0000000..e514a09
--- /dev/null
+++ b/builder-test-api/src/main/java/com/android/builder/testing/api/TestRunner.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.builder.testing.api;
+
+import com.android.annotations.NonNull;
+import com.android.annotations.Nullable;
+import com.android.utils.ILogger;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ */
+public interface TestRunner {
+
+ boolean runTests(
+ @NonNull String projectName,
+ @NonNull String variantName,
+ @NonNull File testApk,
+ @NonNull String testPackageName,
+ @NonNull String testInstrumentationRunner,
+ @Nullable File testedApk,
+ @Nullable String testedPackageName,
+ @NonNull List<? extends DeviceConnector> deviceList,
+ @NonNull File resultsDir,
+ @NonNull ILogger logger);
+}
diff --git a/builder-test-api/src/main/java/com/android/builder/testing/api/TestServer.java b/builder-test-api/src/main/java/com/android/builder/testing/api/TestServer.java
new file mode 100644
index 0000000..93013ad
--- /dev/null
+++ b/builder-test-api/src/main/java/com/android/builder/testing/api/TestServer.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.builder.testing.api;
+
+import com.android.annotations.NonNull;
+
+/**
+ * Base interface for Remote CI Servers.
+ * TODO
+ *
+ */
+public interface TestServer {
+
+ @NonNull
+ String getName();
+
+}