diff options
author | Neal Nguyen <tommyn@google.com> | 2010-03-24 19:15:31 -0700 |
---|---|---|
committer | Neal Nguyen <tommyn@google.com> | 2010-03-24 19:17:55 -0700 |
commit | 70df9ba15a2845984bcb94f029299a06c7210d49 (patch) | |
tree | 7af709698babcf4ff0a87d541187052a901f045e /core/tests/hosttests | |
parent | 2c9607137cd496cd0373f17a8bd4454715057f67 (diff) | |
download | frameworks_base-70df9ba15a2845984bcb94f029299a06c7210d49.zip frameworks_base-70df9ba15a2845984bcb94f029299a06c7210d49.tar.gz frameworks_base-70df9ba15a2845984bcb94f029299a06c7210d49.tar.bz2 |
Refactoring PackageManagerHostTests helper functions into a utility class for easier sharing with future stress tests.
Change-Id: I4ec77b005e2f480687b13c92676c5f62962c2e66
Diffstat (limited to 'core/tests/hosttests')
-rw-r--r-- | core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java | 335 | ||||
-rw-r--r-- | core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java | 337 |
2 files changed, 393 insertions, 279 deletions
diff --git a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java new file mode 100644 index 0000000..8dfa850 --- /dev/null +++ b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTestUtils.java @@ -0,0 +1,335 @@ +/* + * 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.content.pm; + +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 junit.framework.Assert; +import com.android.hosttest.DeviceTestCase; + +/** + * Set of tests that verify host side install cases + */ +public class PackageManagerHostTestUtils extends Assert { + + private static final String LOG_TAG = "PackageManagerHostTests"; + private IDevice mDevice = null; + + // TODO: get this value from Android Environment instead of hardcoding + private static final String APP_PRIVATE_PATH = "/data/app-private/"; + private static final String DEVICE_APP_PATH = "/data/app/"; + private static final String SDCARD_APP_PATH = "/mnt/secure/asec/"; + + private static final int MAX_WAIT_FOR_DEVICE_TIME = 120 * 1000; + private static final int WAIT_FOR_DEVICE_POLL_TIME = 10 * 1000; + + /** + * Constructor takes the device to use + * @param the device to use when performing operations + */ + public PackageManagerHostTestUtils(IDevice device) + { + mDevice = device; + } + + /** + * Disable default constructor + */ + private PackageManagerHostTestUtils() {} + + /** + * Returns the path on the device of forward-locked apps. + * + * @return path of forward-locked apps on the device + */ + public static String getAppPrivatePath() { + return APP_PRIVATE_PATH; + } + + /** + * Returns the path on the device of normal apps. + * + * @return path of forward-locked apps on the device + */ + public static String getDeviceAppPath() { + return DEVICE_APP_PATH; + } + + /** + * Returns the path of apps installed on the SD card. + * + * @return path of forward-locked apps on the device + */ + public static String getSDCardAppPath() { + return SDCARD_APP_PATH; + } + + /** + * Helper method to push a file to device + * @param apkAppPrivatePath + * @throws IOException + */ + public void pushFile(final String localFilePath, final String destFilePath) + throws IOException { + SyncResult result = mDevice.getSyncService().pushFile( + localFilePath, destFilePath, new NullSyncProgressMonitor()); + assertEquals(SyncService.RESULT_OK, result.getCode()); + } + + /** + * Helper method to install a file to device + * @param localFilePath the absolute file system path to file on local host to install + * @param reinstall set to <code>true</code> if re-install of app should be performed + * @throws IOException + */ + public void installFile(final String localFilePath, final boolean replace) + throws IOException { + String result = mDevice.installPackage(localFilePath, replace); + assertEquals(null, result); + } + + /** + * Helper method to determine if file on device exists. + * + * @param destPath the absolute path of file on device to check + * @return <code>true</code> if file exists, <code>false</code> otherwise. + * @throws IOException if adb shell command failed + */ + public boolean doesRemoteFileExist(String destPath) throws IOException { + String lsGrep = executeShellCommand(String.format("ls %s", destPath)); + return !lsGrep.contains("No such file or directory"); + } + + /** + * Helper method to determine if file exists on the device containing a given string. + * + * @param destPath the + * @return <code>true</code> if file exists containing given string, + * <code>false</code> otherwise. + * @throws IOException if adb shell command failed + */ + public boolean doesRemoteFileExistContainingString(String destPath, String searchString) + throws IOException { + String lsResult = executeShellCommand(String.format("ls %s", destPath)); + return lsResult.contains(searchString); + } + + /** + * Helper method to determine if package on device exists. + * + * @param packageName the Android manifest package to check. + * @return <code>true</code> if package exists, <code>false</code> otherwise + * @throws IOException if adb shell command failed + */ + public boolean doesPackageExist(String packageName) throws IOException { + String pkgGrep = executeShellCommand(String.format("pm path %s", packageName)); + return pkgGrep.contains("package:"); + } + + /** + * Helper method to determine if app was installed on device. + * + * @param packageName package name to check for + * @return <code>true</code> if file exists, <code>false</code> otherwise. + * @throws IOException if adb shell command failed + */ + private boolean doesAppExistOnDevice(String packageName) throws IOException { + return doesRemoteFileExistContainingString(DEVICE_APP_PATH, packageName); + } + + /** + * Helper method to determine if app was installed on SD card. + * + * @param packageName package name to check for + * @return <code>true</code> if file exists, <code>false</code> otherwise. + * @throws IOException if adb shell command failed + */ + public boolean doesAppExistOnSDCard(String packageName) throws IOException { + return doesRemoteFileExistContainingString(SDCARD_APP_PATH, packageName); + } + + /** + * Waits for device's package manager to respond. + * + * @throws InterruptedException + * @throws IOException + */ + public void waitForDevice() throws InterruptedException, IOException { + Log.i(LOG_TAG, "waiting for device"); + int currentWaitTime = 0; + // poll the package manager until it returns something for android + while (!doesPackageExist("android")) { + Thread.sleep(WAIT_FOR_DEVICE_POLL_TIME); + currentWaitTime += WAIT_FOR_DEVICE_POLL_TIME; + if (currentWaitTime > MAX_WAIT_FOR_DEVICE_TIME) { + Log.e(LOG_TAG, "time out waiting for device"); + throw new InterruptedException(); + } + } + } + + /** + * Helper method which executes a adb shell command and returns output as a {@link String} + * @return the output of the command + * @throws IOException + */ + public String executeShellCommand(String command) throws IOException { + Log.d(LOG_TAG, String.format("adb shell %s", command)); + CollectingOutputReceiver receiver = new CollectingOutputReceiver(); + mDevice.executeShellCommand(command, receiver); + String output = receiver.getOutput(); + Log.d(LOG_TAG, String.format("Result: %s", output)); + return output; + } + + /** + * A {@link IShellOutputReceiver} which collects the whole shell output into one {@link String} + */ + private class CollectingOutputReceiver extends MultiLineReceiver { + + private StringBuffer mOutputBuffer = new StringBuffer(); + + public String getOutput() { + return mOutputBuffer.toString(); + } + + @Override + public void processNewLines(String[] lines) { + for (String line: lines) { + mOutputBuffer.append(line); + mOutputBuffer.append("\n"); + } + } + + public boolean isCancelled() { + return false; + } + } + + private class NullSyncProgressMonitor implements ISyncProgressMonitor { + public void advance(int work) { + // ignore + } + + public boolean isCanceled() { + // ignore + return false; + } + + public void start(int totalWork) { + // ignore + + } + + public void startSubTask(String name) { + // ignore + } + + public void stop() { + // ignore + } + } + + /** + * Helper method for installing an app to wherever is specified in its manifest, and + * then verifying the app was installed onto SD Card. + * + * @param the path of the apk to install + * @param the name of the package + * @param <code>true</code> if the app should be overwritten, <code>false</code> otherwise + * @throws IOException if adb shell command failed + * @throws InterruptedException if the thread was interrupted + * <p/> + * Assumes adb is running as root in device under test. + */ + public void installAppAndVerifyExistsOnSDCard(String apkPath, String pkgName, boolean overwrite) + throws IOException, InterruptedException { + // Start with a clean slate if we're not overwriting + if (!overwrite) { + // cleanup test app just in case it already exists + mDevice.uninstallPackage(pkgName); + // grep for package to make sure its not installed + assertFalse(doesPackageExist(pkgName)); + } + + installFile(apkPath, overwrite); + assertTrue(doesAppExistOnSDCard(pkgName)); + assertFalse(doesAppExistOnDevice(pkgName)); + waitForDevice(); + + // grep for package to make sure it is installed + assertTrue(doesPackageExist(pkgName)); + } + + /** + * Helper method for installing an app to wherever is specified in its manifest, and + * then verifying the app was installed onto device. + * + * @param the path of the apk to install + * @param the name of the package + * @param <code>true</code> if the app should be overwritten, <code>false</code> otherwise + * @throws IOException if adb shell command failed + * @throws InterruptedException if the thread was interrupted + * <p/> + * Assumes adb is running as root in device under test. + */ + public void installAppAndVerifyExistsOnDevice(String apkPath, String pkgName, boolean overwrite) + throws IOException, InterruptedException { + // Start with a clean slate if we're not overwriting + if (!overwrite) { + // cleanup test app just in case it already exists + mDevice.uninstallPackage(pkgName); + // grep for package to make sure its not installed + assertFalse(doesPackageExist(pkgName)); + } + + installFile(apkPath, overwrite); + assertFalse(doesAppExistOnSDCard(pkgName)); + assertTrue(doesAppExistOnDevice(pkgName)); + waitForDevice(); + + // grep for package to make sure it is installed + assertTrue(doesPackageExist(pkgName)); + } + + /** + * Helper method for uninstalling an app. + * + * @param pkgName package name to uninstall + * @throws IOException if adb shell command failed + * @throws InterruptedException if the thread was interrupted + * <p/> + * Assumes adb is running as root in device under test. + */ + public void uninstallApp(String pkgName) throws IOException, InterruptedException { + mDevice.uninstallPackage(pkgName); + // make sure its not installed anymore + assertFalse(doesPackageExist(pkgName)); + } + +} diff --git a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java index ca0094e..90ddc3a 100644 --- a/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java +++ b/core/tests/hosttests/src/android/content/pm/PackageManagerHostTests.java @@ -37,14 +37,11 @@ import junit.framework.Test; public class PackageManagerHostTests extends DeviceTestCase { private static final String LOG_TAG = "PackageManagerHostTests"; + private PackageManagerHostTestUtils mPMHostUtils = null; - // TODO: get this value from Android Environment instead of hardcoding - private static final String APP_PRIVATE_PATH = "/data/app-private/"; - private static final String DEVICE_APP_PATH = "/data/app/"; - private static final String SDCARD_APP_PATH = "/mnt/secure/asec/"; - - private static final int MAX_WAIT_FOR_DEVICE_TIME = 120 * 1000; - private static final int WAIT_FOR_DEVICE_POLL_TIME = 10 * 1000; + private String appPrivatePath = null; + private String deviceAppPath = null; + private String sdcardAppPath = null; // Various test files and their corresponding package names... @@ -92,154 +89,12 @@ public class PackageManagerHostTests extends DeviceTestCase { super.setUp(); // ensure apk path has been set before test is run assertNotNull(getTestAppPath()); - } - - /** - * Regression test to verify that pushing an apk to the private app directory doesn't install - * the app, and otherwise cause the system to blow up. - * <p/> - * Assumes adb is running as root in device under test. - */ - public void testPushAppPrivate() throws IOException, InterruptedException { - Log.i(LOG_TAG, "testing pushing an apk to /data/app-private"); - final String apkAppPrivatePath = APP_PRIVATE_PATH + SIMPLE_APK; - - // cleanup test app just in case it was accidently installed - getDevice().uninstallPackage(SIMPLE_PKG); - executeShellCommand("stop"); - pushFile(getTestAppFilePath(SIMPLE_APK), apkAppPrivatePath); - // sanity check to make sure file is there - assertTrue(doesRemoteFileExist(apkAppPrivatePath)); - executeShellCommand("start"); - - waitForDevice(); - - // grep for package to make sure its not installed - assertFalse(doesPackageExist(SIMPLE_PKG)); - // ensure it has been deleted from app-private - assertFalse(doesRemoteFileExist(apkAppPrivatePath)); - } - - /** - * Helper method to push a file to device - * @param apkAppPrivatePath - * @throws IOException - */ - private void pushFile(final String localFilePath, final String destFilePath) - throws IOException { - SyncResult result = getDevice().getSyncService().pushFile( - localFilePath, destFilePath, - new NullSyncProgressMonitor()); - assertEquals(SyncService.RESULT_OK, result.getCode()); - } - - /** - * Helper method to install a file to device - * @param localFilePath the absolute file system path to file on local host to install - * @param reinstall set to <code>true</code> if re-install of app should be performed - * @throws IOException - */ - private void installFile(final String localFilePath, final boolean replace) - throws IOException { - String result = getDevice().installPackage(localFilePath, replace); - assertEquals(null, result); - } - - /** - * Helper method to determine if file on device exists. - * - * @param destPath the absolute path of file on device to check - * @return <code>true</code> if file exists, <code>false</code> otherwise. - * @throws IOException if adb shell command failed - */ - private boolean doesRemoteFileExist(String destPath) throws IOException { - String lsGrep = executeShellCommand(String.format("ls %s", - destPath)); - return !lsGrep.contains("No such file or directory"); - } - - /** - * Helper method to determine if file exists on the device containing a given string. - * - * @param destPath the - * @return <code>true</code> if file exists containing given string, - * <code>false</code> otherwise. - * @throws IOException if adb shell command failed - */ - private boolean doesRemoteFileExistContainingString(String destPath, String searchString) - throws IOException { - String lsResult = executeShellCommand(String.format("ls %s", - destPath)); - return lsResult.contains(searchString); - } - - /** - * Helper method to determine if package on device exists. - * - * @param packageName the Android manifest package to check. - * @return <code>true</code> if package exists, <code>false</code> otherwise - * @throws IOException if adb shell command failed - */ - private boolean doesPackageExist(String packageName) throws IOException { - String pkgGrep = executeShellCommand(String.format("pm path %s", - packageName)); - return pkgGrep.contains("package:"); - } - - /** - * Helper method to determine if app was installed on device. - * - * @param packageName package name to check for - * @return <code>true</code> if file exists, <code>false</code> otherwise. - * @throws IOException if adb shell command failed - */ - private boolean doesAppExistOnDevice(String packageName) throws IOException { - return doesRemoteFileExistContainingString(DEVICE_APP_PATH, packageName); - } - - /** - * Helper method to determine if app was installed on SD card. - * - * @param packageName package name to check for - * @return <code>true</code> if file exists, <code>false</code> otherwise. - * @throws IOException if adb shell command failed - */ - private boolean doesAppExistOnSDCard(String packageName) throws IOException { - return doesRemoteFileExistContainingString(SDCARD_APP_PATH, packageName); - } - - /** - * Waits for device's package manager to respond. - * - * @throws InterruptedException - * @throws IOException - */ - private void waitForDevice() throws InterruptedException, IOException { - Log.i(LOG_TAG, "waiting for device"); - int currentWaitTime = 0; - // poll the package manager until it returns something for android - while (!doesPackageExist("android")) { - Thread.sleep(WAIT_FOR_DEVICE_POLL_TIME); - currentWaitTime += WAIT_FOR_DEVICE_POLL_TIME; - if (currentWaitTime > MAX_WAIT_FOR_DEVICE_TIME) { - Log.e(LOG_TAG, "time out waiting for device"); - throw new InterruptedException(); - } - } - } - /** - * Helper method which executes a adb shell command and returns output as a {@link String} - * @return - * @throws IOException - */ - private String executeShellCommand(String command) throws IOException { - Log.d(LOG_TAG, String.format("adb shell %s", command)); - CollectingOutputReceiver receiver = new CollectingOutputReceiver(); - getDevice().executeShellCommand(command, receiver); - String output = receiver.getOutput(); - Log.d(LOG_TAG, String.format("Result: %s", output)); - return output; + // setup the PackageManager host tests utilities class, and get various paths we'll need... + mPMHostUtils = new PackageManagerHostTestUtils(getDevice()); + appPrivatePath = mPMHostUtils.getAppPrivatePath(); + deviceAppPath = mPMHostUtils.getDeviceAppPath(); + sdcardAppPath = mPMHostUtils.getSDCardAppPath(); } /** @@ -247,7 +102,7 @@ public class PackageManagerHostTests extends DeviceTestCase { * @param fileName the file name of the test app apk * @return {@link String} of absolute file path */ - private String getTestAppFilePath(String fileName) { + public String getTestAppFilePath(String fileName) { return String.format("%s%s%s", getTestAppPath(), File.separator, fileName); } @@ -256,112 +111,30 @@ public class PackageManagerHostTests extends DeviceTestCase { } /** - * A {@link IShellOutputReceiver} which collects the whole shell output into one {@link String} - */ - private static class CollectingOutputReceiver extends MultiLineReceiver { - - private StringBuffer mOutputBuffer = new StringBuffer(); - - public String getOutput() { - return mOutputBuffer.toString(); - } - - @Override - public void processNewLines(String[] lines) { - for (String line: lines) { - mOutputBuffer.append(line); - mOutputBuffer.append("\n"); - } - } - - public boolean isCancelled() { - return false; - } - } - - private static class NullSyncProgressMonitor implements ISyncProgressMonitor { - public void advance(int work) { - // ignore - } - - public boolean isCanceled() { - // ignore - return false; - } - - public void start(int totalWork) { - // ignore - - } - - public void startSubTask(String name) { - // ignore - } - - public void stop() { - // ignore - } - } - - /** - * Helper method for installing an app to wherever is specified in its manifest, and - * then verifying the app was installed onto SD Card. + * Regression test to verify that pushing an apk to the private app directory doesn't install + * the app, and otherwise cause the system to blow up. * <p/> * Assumes adb is running as root in device under test. */ - void installAppAndVerifyExistsOnSDCard(String apkName, String pkgName, boolean overwrite) - throws IOException, InterruptedException { - // Start with a clean slate if we're not overwriting - if (!overwrite) { - // cleanup test app just in case it already exists - getDevice().uninstallPackage(pkgName); - // grep for package to make sure its not installed - assertFalse(doesPackageExist(pkgName)); - } - - installFile(getTestAppFilePath(apkName), overwrite); - assertTrue(doesAppExistOnSDCard(pkgName)); - assertFalse(doesAppExistOnDevice(pkgName)); - waitForDevice(); - - // grep for package to make sure it is installed - assertTrue(doesPackageExist(pkgName)); - } + public void testPushAppPrivate() throws IOException, InterruptedException { + Log.i(LOG_TAG, "testing pushing an apk to /data/app-private"); + final String apkAppPrivatePath = appPrivatePath + SIMPLE_APK; - /** - * Helper method for installing an app to wherever is specified in its manifest, and - * then verifying the app was installed onto device. - * <p/> - * Assumes adb is running as root in device under test. - */ - void installAppAndVerifyExistsOnDevice(String apkName, String pkgName, boolean overwrite) - throws IOException, InterruptedException { - // Start with a clean slate if we're not overwriting - if (!overwrite) { - // cleanup test app just in case it already exists - getDevice().uninstallPackage(pkgName); - // grep for package to make sure its not installed - assertFalse(doesPackageExist(pkgName)); - } + // cleanup test app just in case it was accidently installed + getDevice().uninstallPackage(SIMPLE_PKG); + mPMHostUtils.executeShellCommand("stop"); + mPMHostUtils.pushFile(getTestAppFilePath(SIMPLE_APK), apkAppPrivatePath); - installFile(getTestAppFilePath(apkName), overwrite); - assertFalse(doesAppExistOnSDCard(pkgName)); - assertTrue(doesAppExistOnDevice(pkgName)); - waitForDevice(); + // sanity check to make sure file is there + assertTrue(mPMHostUtils.doesRemoteFileExist(apkAppPrivatePath)); + mPMHostUtils.executeShellCommand("start"); - // grep for package to make sure it is installed - assertTrue(doesPackageExist(pkgName)); - } + mPMHostUtils.waitForDevice(); - /** - * Helper method for uninstalling an app. - * <p/> - * Assumes adb is running as root in device under test. - */ - void uninstallApp(String pkgName) throws IOException, InterruptedException { - getDevice().uninstallPackage(pkgName); - // make sure its not installed anymore - assertFalse(doesPackageExist(pkgName)); + // grep for package to make sure its not installed + assertFalse(mPMHostUtils.doesPackageExist(SIMPLE_PKG)); + // ensure it has been deleted from app-private + assertFalse(mPMHostUtils.doesRemoteFileExist(apkAppPrivatePath)); } /** @@ -374,11 +147,12 @@ public class PackageManagerHostTests extends DeviceTestCase { Log.i(LOG_TAG, "Test an app with installLocation=auto gets installed on device"); try { - installAppAndVerifyExistsOnDevice(AUTO_LOC_APK, AUTO_LOC_PKG, false); + mPMHostUtils.installAppAndVerifyExistsOnDevice( + getTestAppFilePath(AUTO_LOC_APK), AUTO_LOC_PKG, false); } // cleanup test app finally { - uninstallApp(AUTO_LOC_PKG); + mPMHostUtils.uninstallApp(AUTO_LOC_PKG); } } @@ -392,11 +166,12 @@ public class PackageManagerHostTests extends DeviceTestCase { Log.i(LOG_TAG, "Test an app with installLocation=internalOnly gets installed on device"); try { - installAppAndVerifyExistsOnDevice(INTERNAL_LOC_APK, INTERNAL_LOC_PKG, false); + mPMHostUtils.installAppAndVerifyExistsOnDevice( + getTestAppFilePath(INTERNAL_LOC_APK), INTERNAL_LOC_PKG, false); } // cleanup test app finally { - uninstallApp(INTERNAL_LOC_PKG); + mPMHostUtils.uninstallApp(INTERNAL_LOC_PKG); } } @@ -410,11 +185,12 @@ public class PackageManagerHostTests extends DeviceTestCase { Log.i(LOG_TAG, "Test an app with installLocation=preferExternal gets installed on SD Card"); try { - installAppAndVerifyExistsOnSDCard(EXTERNAL_LOC_APK, EXTERNAL_LOC_PKG, false); + mPMHostUtils.installAppAndVerifyExistsOnSDCard( + getTestAppFilePath(EXTERNAL_LOC_APK), EXTERNAL_LOC_PKG, false); } // cleanup test app finally { - uninstallApp(EXTERNAL_LOC_PKG); + mPMHostUtils.uninstallApp(EXTERNAL_LOC_PKG); } } @@ -432,13 +208,15 @@ public class PackageManagerHostTests extends DeviceTestCase { Log.i(LOG_TAG, "Test installing an app first to the device, then to the SD Card"); try { - installAppAndVerifyExistsOnDevice(VERSATILE_LOC_INTERNAL_APK, VERSATILE_LOC_PKG, false); - uninstallApp(VERSATILE_LOC_PKG); - installAppAndVerifyExistsOnSDCard(VERSATILE_LOC_EXTERNAL_APK, VERSATILE_LOC_PKG, false); + mPMHostUtils.installAppAndVerifyExistsOnDevice( + getTestAppFilePath(VERSATILE_LOC_INTERNAL_APK), VERSATILE_LOC_PKG, false); + mPMHostUtils.uninstallApp(VERSATILE_LOC_PKG); + mPMHostUtils.installAppAndVerifyExistsOnSDCard( + getTestAppFilePath(VERSATILE_LOC_EXTERNAL_APK), VERSATILE_LOC_PKG, false); } // cleanup test app finally { - uninstallApp(VERSATILE_LOC_PKG); + mPMHostUtils.uninstallApp(VERSATILE_LOC_PKG); } } @@ -457,14 +235,16 @@ public class PackageManagerHostTests extends DeviceTestCase { try { // install the app externally - installAppAndVerifyExistsOnSDCard(VERSATILE_LOC_EXTERNAL_APK, VERSATILE_LOC_PKG, false); - uninstallApp(VERSATILE_LOC_PKG); + mPMHostUtils.installAppAndVerifyExistsOnSDCard( + getTestAppFilePath(VERSATILE_LOC_EXTERNAL_APK), VERSATILE_LOC_PKG, false); + mPMHostUtils.uninstallApp(VERSATILE_LOC_PKG); // then replace the app with one marked for internalOnly - installAppAndVerifyExistsOnDevice(VERSATILE_LOC_INTERNAL_APK, VERSATILE_LOC_PKG, true); + mPMHostUtils.installAppAndVerifyExistsOnDevice( + getTestAppFilePath(VERSATILE_LOC_INTERNAL_APK), VERSATILE_LOC_PKG, false); } // cleanup test app finally { - uninstallApp(VERSATILE_LOC_PKG); + mPMHostUtils.uninstallApp(VERSATILE_LOC_PKG); } } @@ -480,15 +260,15 @@ public class PackageManagerHostTests extends DeviceTestCase { try { // install the app externally - installAppAndVerifyExistsOnSDCard(UPDATE_EXTERNAL_LOC_V1_EXT_APK, - UPDATE_EXTERNAL_LOC_PKG, false); + mPMHostUtils.installAppAndVerifyExistsOnSDCard(getTestAppFilePath( + UPDATE_EXTERNAL_LOC_V1_EXT_APK), UPDATE_EXTERNAL_LOC_PKG, false); // now replace the app with one where the location is blank (app should stay external) - installAppAndVerifyExistsOnSDCard(UPDATE_EXTERNAL_LOC_V2_NONE_APK, - UPDATE_EXTERNAL_LOC_PKG, true); + mPMHostUtils.installAppAndVerifyExistsOnSDCard(getTestAppFilePath( + UPDATE_EXTERNAL_LOC_V2_NONE_APK), UPDATE_EXTERNAL_LOC_PKG, true); } // cleanup test app finally { - uninstallApp(UPDATE_EXTERNAL_LOC_PKG); + mPMHostUtils.uninstallApp(UPDATE_EXTERNAL_LOC_PKG); } } @@ -504,16 +284,15 @@ public class PackageManagerHostTests extends DeviceTestCase { try { // install the app externally - installAppAndVerifyExistsOnSDCard(UPDATE_EXT_TO_INT_LOC_V1_EXT_APK, - UPDATE_EXT_TO_INT_LOC_PKG, false); + mPMHostUtils.installAppAndVerifyExistsOnSDCard(getTestAppFilePath( + UPDATE_EXT_TO_INT_LOC_V1_EXT_APK), UPDATE_EXT_TO_INT_LOC_PKG, false); // now replace the app with an update marked for internalOnly... - installAppAndVerifyExistsOnDevice(UPDATE_EXT_TO_INT_LOC_V2_INT_APK, - UPDATE_EXT_TO_INT_LOC_PKG, true); + mPMHostUtils.installAppAndVerifyExistsOnDevice(getTestAppFilePath( + UPDATE_EXT_TO_INT_LOC_V2_INT_APK), UPDATE_EXT_TO_INT_LOC_PKG, true); } // cleanup test app finally { - uninstallApp(UPDATE_EXT_TO_INT_LOC_PKG); + mPMHostUtils.uninstallApp(UPDATE_EXT_TO_INT_LOC_PKG); } } - } |