diff options
author | Neal Nguyen <tommyn@google.com> | 2010-08-09 14:08:26 -0700 |
---|---|---|
committer | Neal Nguyen <tommyn@google.com> | 2010-09-08 17:02:53 -0700 |
commit | 5f53bca55b2c9e217dee12bff8ce55e168829783 (patch) | |
tree | 14f9203ef32283086d3fe6f1ac06d30804c1e2c9 /core/tests/hosttests/src/android/content | |
parent | 3fa7d8af6560de07ef673f73308f7e51de64e4ec (diff) | |
download | frameworks_base-5f53bca55b2c9e217dee12bff8ce55e168829783.zip frameworks_base-5f53bca55b2c9e217dee12bff8ce55e168829783.tar.gz frameworks_base-5f53bca55b2c9e217dee12bff8ce55e168829783.tar.bz2 |
Adding Download Manager Integration, stress, and hosts-based tests.
Change-Id: I97008f6cfd95ea9950db0b4e093da02528849b63
Diffstat (limited to 'core/tests/hosttests/src/android/content')
-rw-r--r-- | core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java index b225c37..1593bb5 100644 --- a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java +++ b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java @@ -37,7 +37,9 @@ import java.io.InputStreamReader; import java.io.StringReader; import java.lang.Runtime; import java.lang.Process; +import java.util.Hashtable; import java.util.Map; +import java.util.Map.Entry; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -117,18 +119,38 @@ public class PackageManagerHostTestUtils extends Assert { /** * Helper method to run tests and return the listener that collected the results. + * + * For the optional params, pass null to use the default values. + * @param pkgName Android application package for tests - * @return the {@link CollectingTestRunListener} + * @param className (optional) The class containing the method to test + * @param methodName (optional) The method in the class of which to test + * @param runnerName (optional) The name of the TestRunner of the test on the device to be run + * @param params (optional) Any additional parameters to pass into the Test Runner * @throws TimeoutException in case of a timeout on the connection. * @throws AdbCommandRejectedException if adb rejects the command * @throws ShellCommandUnresponsiveException if the device did not output anything for * a period longer than the max time to output. * @throws IOException if connection to device was lost. + * @return the {@link CollectingTestRunListener} */ - private CollectingTestRunListener doRunTests(String pkgName) throws IOException, - TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException { - RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner( - pkgName, mDevice); + private CollectingTestRunListener doRunTests(String pkgName, String className, + String methodName, String runnerName, Map<String, String> params) throws IOException, + TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException { + RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(pkgName, runnerName, + mDevice); + + if (className != null && methodName != null) { + testRunner.setMethodName(className, methodName); + } + + // Add in any additional args to pass into the test + if (params != null) { + for (Entry<String, String> argPair : params.entrySet()) { + testRunner.addInstrumentationArg(argPair.getKey(), argPair.getValue()); + } + } + CollectingTestRunListener listener = new CollectingTestRunListener(); testRunner.run(listener); return listener; @@ -138,16 +160,34 @@ public class PackageManagerHostTestUtils extends Assert { * Runs the specified packages tests, and returns whether all tests passed or not. * * @param pkgName Android application package for tests - * @return true if every test passed, false otherwise. + * @param className The class containing the method to test + * @param methodName The method in the class of which to test + * @param runnerName The name of the TestRunner of the test on the device to be run + * @param params Any additional parameters to pass into the Test Runner + * @return true if test passed, false otherwise. + */ + public boolean runDeviceTestsDidAllTestsPass(String pkgName, String className, + String methodName, String runnerName, Map<String, String> params) throws IOException, + TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException { + CollectingTestRunListener listener = doRunTests(pkgName, className, methodName, + runnerName, params); + return listener.didAllTestsPass(); + } + + /** + * Runs the specified packages tests, and returns whether all tests passed or not. + * + * @param pkgName Android application package for tests * @throws TimeoutException in case of a timeout on the connection. * @throws AdbCommandRejectedException if adb rejects the command * @throws ShellCommandUnresponsiveException if the device did not output anything for * a period longer than the max time to output. * @throws IOException if connection to device was lost. + * @return true if every test passed, false otherwise. */ public boolean runDeviceTestsDidAllTestsPass(String pkgName) throws IOException, TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException { - CollectingTestRunListener listener = doRunTests(pkgName); + CollectingTestRunListener listener = doRunTests(pkgName, null, null, null, null); return listener.didAllTestsPass(); } @@ -531,7 +571,7 @@ public class PackageManagerHostTestUtils extends Assert { } // For collecting results from running device tests - private static class CollectingTestRunListener implements ITestRunListener { + public static class CollectingTestRunListener implements ITestRunListener { private boolean mAllTestsPassed = true; private String mTestRunErrorMessage = null; |