diff options
author | Xavier Ducrohet <xav@android.com> | 2013-04-29 15:41:03 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2013-04-30 12:46:27 -0700 |
commit | d286b1c742e27792684e7278a3c9c3fdeb05b535 (patch) | |
tree | f90a815442827aff66a37980c6153b14407dc665 /builder-test-api/src | |
parent | 2a955e0b81d1a5cb3b06e0b20b42f8b3ad42bef8 (diff) | |
download | build-d286b1c742e27792684e7278a3c9c3fdeb05b535.tar.gz |
Add new check tasks based on DeviceProvider/TestServer
Also add a new test project that use a fake implementation
of both to make sure they are correctly called.
Change-Id: I2a3dcd078a97fbeffedcf730adc59414afeb274d
Diffstat (limited to 'builder-test-api/src')
5 files changed, 83 insertions, 21 deletions
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 index 740af07..90becae 100644 --- 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 @@ -25,12 +25,35 @@ import java.io.File; /** * A connector to a device to install/uninstall APKs, and run shell command. */ -public interface DeviceConnector extends IShellEnabledDevice { +public abstract class DeviceConnector implements IShellEnabledDevice { - void connect(int timeOut) throws TimeoutException; - void disconnect(int timeOut) throws TimeoutException; + /** + * Establishes the connection with the device. Called before any other actions. + * @param timeOut the time out. + * @throws TimeoutException + */ + public abstract void connect(int timeOut) throws TimeoutException; - void installPackage(@NonNull File apkFile) throws DeviceException; + /** + * Disconnects from the device. No other action is called afterwards. + * @param timeOut the time out. + * @throws TimeoutException + */ + public abstract void disconnect(int timeOut) throws TimeoutException; - void uninstallPackage(@NonNull String packageName) throws DeviceException; + /** + * Installs the given APK on the device. + * @param apkFile the APK file to install. + * @param timeout the time out. + * @throws DeviceException + */ + public abstract void installPackage(@NonNull File apkFile, int timeout) throws DeviceException; + + /** + * Uninstall the given package name from the device + * @param packageName the package name + * @param timeout the time out + * @throws DeviceException + */ + public abstract void uninstallPackage(@NonNull String packageName, int timeout) 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 index b0627db..1a06155 100644 --- 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 @@ -19,6 +19,7 @@ package com.android.builder.testing.api; import com.android.annotations.NonNull; /** + * Exception thrown during device actions. */ public class DeviceException extends Exception { 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 index be7bf55..ccbef01 100644 --- 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 @@ -23,13 +23,33 @@ import java.util.List; /** * Provides a list of remote or local devices. */ -public interface DeviceProvider { +public abstract class DeviceProvider { + /** + * Returns the name of the provider. Must be unique, not contain spaces, and start with a lower + * case. + * + * @return the name of the provider. + */ @NonNull - String getName(); + public abstract String getName(); + /** + * Initializes the provider. This is called before any other method (except {@link #getName()}). + * @throws DeviceException + */ + public abstract void init() throws DeviceException; + + /** + * Returns a list of DeviceConnector. + * @return a non-null list (but could be empty.) + */ @NonNull - List<? extends DeviceConnector> getDevices(); + public abstract List<? extends DeviceConnector> getDevices(); - void init() throws DeviceException; + /** + * Returns the timeout to use. + * @return the time out. + */ + public abstract int getTimeout(); } 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 index e514a09..652a168 100644 --- 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 @@ -24,18 +24,20 @@ import java.io.File; import java.util.List; /** + * A test runner able to run tests on a list of {@link DeviceConnector} */ public interface TestRunner { boolean runTests( - @NonNull String projectName, - @NonNull String variantName, - @NonNull File testApk, - @NonNull String testPackageName, - @NonNull String testInstrumentationRunner, + @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); + @NonNull List<? extends DeviceConnector> deviceList, + int timeout, + @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 index 93013ad..91f0370 100644 --- 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 @@ -17,15 +17,31 @@ package com.android.builder.testing.api; import com.android.annotations.NonNull; +import com.android.annotations.Nullable; + +import java.io.File; /** * Base interface for Remote CI Servers. - * TODO - * */ -public interface TestServer { +public abstract class TestServer { + /** + * Returns the name of the server. Must be unique, not contain spaces, and start with a lower + * case. + * + * @return the name of the provider. + */ @NonNull - String getName(); + public abstract String getName(); + /** + * Uploads the APKs to the server. + * + * TODO: add more details + * + * @param testApk the APK containing the tests. + * @param testedApk the APK to be tested. This is optional in case the test apk is self-tested. + */ + public abstract void uploadApks(@NonNull File testApk, @Nullable File testedApk); } |