summaryrefslogtreecommitdiffstats
path: root/core/tests/hosttests/src/android
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2010-09-08 11:07:30 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-08 11:07:30 -0700
commitcf67abbc48d6d56538dd6f2412d6aa9863a31637 (patch)
tree05d6de193cf3fa73777e518d5dfeb40c4cd2d3b8 /core/tests/hosttests/src/android
parentd41b037c6b645768bf55d4d9efb4904373bd61b0 (diff)
parent6ffee9bbba53700d33456261b986ac8a3f333b9e (diff)
downloadframeworks_base-cf67abbc48d6d56538dd6f2412d6aa9863a31637.zip
frameworks_base-cf67abbc48d6d56538dd6f2412d6aa9863a31637.tar.gz
frameworks_base-cf67abbc48d6d56538dd6f2412d6aa9863a31637.tar.bz2
am 6ffee9bb: Merge "Revert "resolve conflicts"" into gingerbread-plus-aosp
Merge commit '6ffee9bbba53700d33456261b986ac8a3f333b9e' * commit '6ffee9bbba53700d33456261b986ac8a3f333b9e': Revert "resolve conflicts"
Diffstat (limited to 'core/tests/hosttests/src/android')
-rw-r--r--core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java54
-rw-r--r--core/tests/hosttests/src/android/net/DownloadManagerHostTests.java201
2 files changed, 7 insertions, 248 deletions
diff --git a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java
index f962bab..38191b0 100644
--- a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java
+++ b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java
@@ -37,9 +37,7 @@ 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;
@@ -119,14 +117,7 @@ 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
- * @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
* @return the {@link CollectingTestRunListener}
* @throws TimeoutException in case of a timeout on the connection.
* @throws AdbCommandRejectedException if adb rejects the command
@@ -134,24 +125,10 @@ public class PackageManagerHostTestUtils extends Assert {
* a period longer than the max time to output.
* @throws IOException if connection to device was lost.
*/
- 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());
- }
- }
-
+ private CollectingTestRunListener doRunTests(String pkgName) throws IOException,
+ TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
+ RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(
+ pkgName, mDevice);
CollectingTestRunListener listener = new CollectingTestRunListener();
try {
testRunner.run(listener);
@@ -165,23 +142,6 @@ 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
- * @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 {
- 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
* @return true if every test passed, false otherwise.
* @throws TimeoutException in case of a timeout on the connection.
* @throws AdbCommandRejectedException if adb rejects the command
@@ -189,9 +149,9 @@ public class PackageManagerHostTestUtils extends Assert {
* a period longer than the max time to output.
* @throws IOException if connection to device was lost.
*/
- public boolean runDeviceTestsDidAllTestsPass(String pkgName) throws IOException,
+ public boolean runDeviceTestsDidAllTestsPass(String pkgName) throws IOException,
TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
- CollectingTestRunListener listener = doRunTests(pkgName, null, null, null, null);
+ CollectingTestRunListener listener = doRunTests(pkgName);
return listener.didAllTestsPass();
}
@@ -575,7 +535,7 @@ public class PackageManagerHostTestUtils extends Assert {
}
// For collecting results from running device tests
- public static class CollectingTestRunListener implements ITestRunListener {
+ private static class CollectingTestRunListener implements ITestRunListener {
private boolean mAllTestsPassed = true;
private String mTestRunErrorMessage = null;
diff --git a/core/tests/hosttests/src/android/net/DownloadManagerHostTests.java b/core/tests/hosttests/src/android/net/DownloadManagerHostTests.java
deleted file mode 100644
index ed280c9..0000000
--- a/core/tests/hosttests/src/android/net/DownloadManagerHostTests.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) 2010 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 android.net;
-
-import android.content.pm.PackageManagerHostTestUtils;
-import android.content.pm.PackageManagerHostTestUtils.CollectingTestRunListener;
-
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.SyncService;
-import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-import com.android.ddmlib.SyncService.SyncResult;
-import com.android.hosttest.DeviceTestCase;
-import com.android.hosttest.DeviceTestSuite;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Hashtable;
-
-import junit.framework.Test;
-
-/**
- * Host-based tests of the DownloadManager API. (Uses a device-based app to actually invoke the
- * various tests.)
- */
-public class DownloadManagerHostTests extends DeviceTestCase {
- protected PackageManagerHostTestUtils mPMUtils = null;
-
- private static final String LOG_TAG = "android.net.DownloadManagerHostTests";
- private static final String FILE_DOWNLOAD_APK = "DownloadManagerTestApp.apk";
- private static final String FILE_DOWNLOAD_PKG = "com.android.frameworks.downloadmanagertests";
- private static final String FILE_DOWNLOAD_CLASS =
- "com.android.frameworks.downloadmanagertests.DownloadManagerTestApp";
- private static final String DOWNLOAD_TEST_RUNNER_NAME =
- "com.android.frameworks.downloadmanagertests.DownloadManagerTestRunner";
-
- // Extra parameters to pass to the TestRunner
- private static final String EXTERNAL_DOWNLOAD_URI_KEY = "external_download_uri";
- // Note: External environment variable ANDROID_TEST_EXTERNAL_URI must be set to point to the
- // external URI under which the files downloaded by the tests can be found. Note that the Uri
- // must be accessible by the device during a test run.
- private static String EXTERNAL_DOWNLOAD_URI_VALUE = null;
-
- Hashtable<String, String> mExtraParams = null;
-
- public static Test suite() {
- return new DeviceTestSuite(DownloadManagerHostTests.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // ensure apk path has been set before test is run
- assertNotNull(getTestAppPath());
- mPMUtils = new PackageManagerHostTestUtils(getDevice());
- EXTERNAL_DOWNLOAD_URI_VALUE = System.getenv("ANDROID_TEST_EXTERNAL_URI");
- assertNotNull(EXTERNAL_DOWNLOAD_URI_VALUE);
- mExtraParams = getExtraParams();
- }
-
- /**
- * Helper function to get extra params that can be used to pass into the helper app.
- */
- protected Hashtable<String, String> getExtraParams() {
- Hashtable<String, String> extraParams = new Hashtable<String, String>();
- extraParams.put(EXTERNAL_DOWNLOAD_URI_KEY, EXTERNAL_DOWNLOAD_URI_VALUE);
- return extraParams;
- }
-
- /**
- * Tests that a large download over WiFi
- * @throws Exception if the test failed at any point
- */
- public void testLargeDownloadOverWiFi() throws Exception {
- mPMUtils.installAppAndVerifyExistsOnDevice(String.format("%s%s%s", getTestAppPath(),
- File.separator, FILE_DOWNLOAD_APK), FILE_DOWNLOAD_PKG, true);
-
- boolean testPassed = mPMUtils.runDeviceTestsDidAllTestsPass(FILE_DOWNLOAD_PKG,
- FILE_DOWNLOAD_CLASS, "runLargeDownloadOverWiFi", DOWNLOAD_TEST_RUNNER_NAME,
- mExtraParams);
-
- assertTrue("Failed to install large file over WiFi in < 10 minutes!", testPassed);
- }
-
- /**
- * Spawns a device-based function to initiate a download on the device, reboots the device,
- * then waits and verifies the download succeeded.
- *
- * @throws Exception if the test failed at any point
- */
- public void testDownloadManagerSingleReboot() throws Exception {
- mPMUtils.installAppAndVerifyExistsOnDevice(String.format("%s%s%s", getTestAppPath(),
- File.separator, FILE_DOWNLOAD_APK), FILE_DOWNLOAD_PKG, true);
-
- boolean testPassed = mPMUtils.runDeviceTestsDidAllTestsPass(FILE_DOWNLOAD_PKG,
- FILE_DOWNLOAD_CLASS, "initiateDownload", DOWNLOAD_TEST_RUNNER_NAME,
- mExtraParams);
-
- assertTrue("Failed to initiate download properly!", testPassed);
- mPMUtils.rebootDevice();
- testPassed = mPMUtils.runDeviceTestsDidAllTestsPass(FILE_DOWNLOAD_PKG,
- FILE_DOWNLOAD_CLASS, "verifyFileDownloadSucceeded", DOWNLOAD_TEST_RUNNER_NAME,
- mExtraParams);
- assertTrue("Failed to verify initiated download completed properyly!", testPassed);
- }
-
- /**
- * Spawns a device-based function to initiate a download on the device, reboots the device three
- * times (using different intervals), then waits and verifies the download succeeded.
- *
- * @throws Exception if the test failed at any point
- */
- public void testDownloadManagerMultipleReboots() throws Exception {
- mPMUtils.installAppAndVerifyExistsOnDevice(String.format("%s%s%s", getTestAppPath(),
- File.separator, FILE_DOWNLOAD_APK), FILE_DOWNLOAD_PKG, true);
-
- boolean testPassed = mPMUtils.runDeviceTestsDidAllTestsPass(FILE_DOWNLOAD_PKG,
- FILE_DOWNLOAD_CLASS, "initiateDownload", DOWNLOAD_TEST_RUNNER_NAME,
- mExtraParams);
-
- assertTrue("Failed to initiate download properly!", testPassed);
- Thread.sleep(5000);
-
- // Do 3 random reboots - after 13, 9, and 19 seconds
- Log.i(LOG_TAG, "First reboot...");
- mPMUtils.rebootDevice();
- Thread.sleep(13000);
- Log.i(LOG_TAG, "Second reboot...");
- mPMUtils.rebootDevice();
- Thread.sleep(9000);
- Log.i(LOG_TAG, "Third reboot...");
- mPMUtils.rebootDevice();
- Thread.sleep(19000);
- testPassed = mPMUtils.runDeviceTestsDidAllTestsPass(FILE_DOWNLOAD_PKG,
- FILE_DOWNLOAD_CLASS, "verifyFileDownloadSucceeded", DOWNLOAD_TEST_RUNNER_NAME,
- mExtraParams);
- assertTrue("Failed to verify initiated download completed properyly!", testPassed);
- }
-
- /**
- * Spawns a device-based function to test download while WiFi is enabled/disabled multiple times
- * during the download.
- *
- * @throws Exception if the test failed at any point
- */
- public void testDownloadMultipleWiFiEnableDisable() throws Exception {
- mPMUtils.installAppAndVerifyExistsOnDevice(String.format("%s%s%s", getTestAppPath(),
- File.separator, FILE_DOWNLOAD_APK), FILE_DOWNLOAD_PKG, true);
-
- boolean testPassed = mPMUtils.runDeviceTestsDidAllTestsPass(FILE_DOWNLOAD_PKG,
- FILE_DOWNLOAD_CLASS, "runDownloadMultipleWiFiEnableDisable",
- DOWNLOAD_TEST_RUNNER_NAME, mExtraParams);
- assertTrue(testPassed);
- }
-
- /**
- * Spawns a device-based function to test switching on/off both airplane mode and WiFi
- *
- * @throws Exception if the test failed at any point
- */
- public void testDownloadMultipleSwitching() throws Exception {
- mPMUtils.installAppAndVerifyExistsOnDevice(String.format("%s%s%s", getTestAppPath(),
- File.separator, FILE_DOWNLOAD_APK), FILE_DOWNLOAD_PKG, true);
-
- boolean testPassed = mPMUtils.runDeviceTestsDidAllTestsPass(FILE_DOWNLOAD_PKG,
- FILE_DOWNLOAD_CLASS, "runDownloadMultipleSwitching",
- DOWNLOAD_TEST_RUNNER_NAME, mExtraParams);
- assertTrue(testPassed);
- }
-
- /**
- * Spawns a device-based function to test switching on/off airplane mode multiple times
- *
- * @throws Exception if the test failed at any point
- */
- public void testDownloadMultipleAirplaneModeEnableDisable() throws Exception {
- mPMUtils.installAppAndVerifyExistsOnDevice(String.format("%s%s%s", getTestAppPath(),
- File.separator, FILE_DOWNLOAD_APK), FILE_DOWNLOAD_PKG, true);
-
- boolean testPassed = mPMUtils.runDeviceTestsDidAllTestsPass(FILE_DOWNLOAD_PKG,
- FILE_DOWNLOAD_CLASS, "runDownloadMultipleAirplaneModeEnableDisable",
- DOWNLOAD_TEST_RUNNER_NAME, mExtraParams);
- assertTrue(testPassed);
- }
-}