| Index: build/android/pylib/device/device_utils_test.py
|
| diff --git a/build/android/pylib/device/device_utils_test.py b/build/android/pylib/device/device_utils_test.py
|
| index 2517f6695f76a7773fc3ef2d74c926b03d96f21b..8cb4e3cdbdec0c92bb9b53446f8c85a192aa5dfe 100755
|
| --- a/build/android/pylib/device/device_utils_test.py
|
| +++ b/build/android/pylib/device/device_utils_test.py
|
| @@ -27,6 +27,7 @@ from pylib.device import adb_wrapper
|
| from pylib.device import device_errors
|
| from pylib.device import device_utils
|
| from pylib.device import intent
|
| +from pylib.sdk import split_select
|
| from pylib.utils import mock_calls
|
|
|
| # RunCommand from third_party/android_testrunner/run_command.py is mocked
|
| @@ -310,30 +311,30 @@ class DeviceUtilsGetExternalStoragePathTest(DeviceUtilsTest):
|
| self.device.GetExternalStoragePath()
|
|
|
|
|
| -class DeviceUtilsGetApplicationPathTest(DeviceUtilsTest):
|
| +class DeviceUtilsGetApplicationPathsTest(DeviceUtilsTest):
|
|
|
| - def testGetApplicationPath_exists(self):
|
| + def testGetApplicationPaths_exists(self):
|
| with self.assertCalls(
|
| (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'),
|
| (self.call.adb.Shell('pm path android'),
|
| 'package:/path/to/android.apk\n')):
|
| - self.assertEquals('/path/to/android.apk',
|
| - self.device.GetApplicationPath('android'))
|
| + self.assertEquals(['/path/to/android.apk'],
|
| + self.device.GetApplicationPaths('android'))
|
|
|
| - def testGetApplicationPath_notExists(self):
|
| + def testGetApplicationPaths_notExists(self):
|
| with self.assertCalls(
|
| (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'),
|
| (self.call.adb.Shell('pm path not.installed.app'), '')):
|
| - self.assertEquals(None,
|
| - self.device.GetApplicationPath('not.installed.app'))
|
| + self.assertEquals([],
|
| + self.device.GetApplicationPaths('not.installed.app'))
|
|
|
| - def testGetApplicationPath_fails(self):
|
| + def testGetApplicationPaths_fails(self):
|
| with self.assertCalls(
|
| (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'),
|
| (self.call.adb.Shell('pm path android'),
|
| self.CommandError('ERROR. Is package manager running?\n'))):
|
| with self.assertRaises(device_errors.CommandFailedError):
|
| - self.device.GetApplicationPath('android')
|
| + self.device.GetApplicationPaths('android')
|
|
|
|
|
| class DeviceUtilsGetApplicationDataDirectoryTest(DeviceUtilsTest):
|
| @@ -365,8 +366,8 @@ class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest):
|
| (self.call.device.GetExternalStoragePath(), '/fake/storage/path'),
|
| (self.call.adb.Shell('test -d /fake/storage/path'), ''),
|
| # pm_ready
|
| - (self.call.device.GetApplicationPath('android'),
|
| - 'package:/some/fake/path'),
|
| + (self.call.device.GetApplicationPaths('android'),
|
| + ['package:/some/fake/path']),
|
| # boot_completed
|
| (self.call.device.GetProp('sys.boot_completed'), '1')):
|
| self.device.WaitUntilFullyBooted(wifi=False)
|
| @@ -378,8 +379,8 @@ class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest):
|
| (self.call.device.GetExternalStoragePath(), '/fake/storage/path'),
|
| (self.call.adb.Shell('test -d /fake/storage/path'), ''),
|
| # pm_ready
|
| - (self.call.device.GetApplicationPath('android'),
|
| - 'package:/some/fake/path'),
|
| + (self.call.device.GetApplicationPaths('android'),
|
| + ['package:/some/fake/path']),
|
| # boot_completed
|
| (self.call.device.GetProp('sys.boot_completed'), '1'),
|
| # wifi_enabled
|
| @@ -402,8 +403,8 @@ class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest):
|
| (self.call.device.GetExternalStoragePath(), '/fake/storage/path'),
|
| (self.call.adb.Shell('test -d /fake/storage/path'), ''),
|
| # pm_ready
|
| - (self.call.device.GetApplicationPath('android'),
|
| - 'package:/some/fake/path'),
|
| + (self.call.device.GetApplicationPaths('android'),
|
| + ['package:/some/fake/path']),
|
| # boot_completed
|
| (self.call.device.GetProp('sys.boot_completed'), '1')):
|
| self.device.WaitUntilFullyBooted(wifi=False)
|
| @@ -439,11 +440,11 @@ class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest):
|
| (self.call.device.GetExternalStoragePath(), '/fake/storage/path'),
|
| (self.call.adb.Shell('test -d /fake/storage/path'), ''),
|
| # pm_ready
|
| - (self.call.device.GetApplicationPath('android'), self.CommandError()),
|
| + (self.call.device.GetApplicationPaths('android'), self.CommandError()),
|
| # pm_ready
|
| - (self.call.device.GetApplicationPath('android'), self.CommandError()),
|
| + (self.call.device.GetApplicationPaths('android'), self.CommandError()),
|
| # pm_ready
|
| - (self.call.device.GetApplicationPath('android'), self.TimeoutError())):
|
| + (self.call.device.GetApplicationPaths('android'), self.TimeoutError())):
|
| with self.assertRaises(device_errors.CommandTimeoutError):
|
| self.device.WaitUntilFullyBooted(wifi=False)
|
|
|
| @@ -454,8 +455,8 @@ class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest):
|
| (self.call.device.GetExternalStoragePath(), '/fake/storage/path'),
|
| (self.call.adb.Shell('test -d /fake/storage/path'), ''),
|
| # pm_ready
|
| - (self.call.device.GetApplicationPath('android'),
|
| - 'package:/some/fake/path'),
|
| + (self.call.device.GetApplicationPaths('android'),
|
| + ['package:/some/fake/path']),
|
| # boot_completed
|
| (self.call.device.GetProp('sys.boot_completed'), '0'),
|
| # boot_completed
|
| @@ -472,8 +473,8 @@ class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest):
|
| (self.call.device.GetExternalStoragePath(), '/fake/storage/path'),
|
| (self.call.adb.Shell('test -d /fake/storage/path'), ''),
|
| # pm_ready
|
| - (self.call.device.GetApplicationPath('android'),
|
| - 'package:/some/fake/path'),
|
| + (self.call.device.GetApplicationPaths('android'),
|
| + ['package:/some/fake/path']),
|
| # boot_completed
|
| (self.call.device.GetProp('sys.boot_completed'), '1'),
|
| # wifi_enabled
|
| @@ -519,7 +520,7 @@ class DeviceUtilsInstallTest(DeviceUtilsTest):
|
| with self.assertCalls(
|
| (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'),
|
| 'this.is.a.test.package'),
|
| - (self.call.device.GetApplicationPath('this.is.a.test.package'), None),
|
| + (self.call.device.GetApplicationPaths('this.is.a.test.package'), []),
|
| self.call.adb.Install('/fake/test/app.apk', reinstall=False)):
|
| self.device.Install('/fake/test/app.apk', retries=0)
|
|
|
| @@ -527,8 +528,8 @@ class DeviceUtilsInstallTest(DeviceUtilsTest):
|
| with self.assertCalls(
|
| (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'),
|
| 'this.is.a.test.package'),
|
| - (self.call.device.GetApplicationPath('this.is.a.test.package'),
|
| - '/fake/data/app/this.is.a.test.package.apk'),
|
| + (self.call.device.GetApplicationPaths('this.is.a.test.package'),
|
| + ['/fake/data/app/this.is.a.test.package.apk']),
|
| (self.call.device._GetChangedAndStaleFiles(
|
| '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'),
|
| ([('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')],
|
| @@ -541,8 +542,8 @@ class DeviceUtilsInstallTest(DeviceUtilsTest):
|
| with self.assertCalls(
|
| (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'),
|
| 'this.is.a.test.package'),
|
| - (self.call.device.GetApplicationPath('this.is.a.test.package'),
|
| - '/fake/data/app/this.is.a.test.package.apk'),
|
| + (self.call.device.GetApplicationPaths('this.is.a.test.package'),
|
| + ['/fake/data/app/this.is.a.test.package.apk']),
|
| (self.call.device._GetChangedAndStaleFiles(
|
| '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'),
|
| ([('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')],
|
| @@ -554,8 +555,8 @@ class DeviceUtilsInstallTest(DeviceUtilsTest):
|
| with self.assertCalls(
|
| (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'),
|
| 'this.is.a.test.package'),
|
| - (self.call.device.GetApplicationPath('this.is.a.test.package'),
|
| - '/fake/data/app/this.is.a.test.package.apk'),
|
| + (self.call.device.GetApplicationPaths('this.is.a.test.package'),
|
| + ['/fake/data/app/this.is.a.test.package.apk']),
|
| (self.call.device._GetChangedAndStaleFiles(
|
| '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'),
|
| ([], []))):
|
| @@ -565,12 +566,51 @@ class DeviceUtilsInstallTest(DeviceUtilsTest):
|
| with self.assertCalls(
|
| (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'),
|
| 'this.is.a.test.package'),
|
| - (self.call.device.GetApplicationPath('this.is.a.test.package'), None),
|
| + (self.call.device.GetApplicationPaths('this.is.a.test.package'), []),
|
| (self.call.adb.Install('/fake/test/app.apk', reinstall=False),
|
| self.CommandError('Failure\r\n'))):
|
| with self.assertRaises(device_errors.CommandFailedError):
|
| self.device.Install('/fake/test/app.apk', retries=0)
|
|
|
| +class DeviceUtilsInstallSplitApkTest(DeviceUtilsTest):
|
| +
|
| + def testInstallSplitApk_noPriorInstall(self):
|
| + with self.assertCalls(
|
| + (self.call.device._CheckSdkLevel(21)),
|
| + (mock.call.pylib.sdk.split_select.SelectSplits(
|
| + self.device, 'base.apk',
|
| + ['split1.apk', 'split2.apk', 'split3.apk']),
|
| + ['split2.apk']),
|
| + (mock.call.pylib.utils.apk_helper.GetPackageName('base.apk'),
|
| + 'this.is.a.test.package'),
|
| + (self.call.device.GetApplicationPaths('this.is.a.test.package'), []),
|
| + (self.call.adb.InstallMultiple(
|
| + ['base.apk', 'split2.apk'], partial=None, reinstall=False))):
|
| + self.device.InstallSplitApk('base.apk',
|
| + ['split1.apk', 'split2.apk', 'split3.apk'], retries=0)
|
| +
|
| + def testInstallSplitApk_partialInstall(self):
|
| + with self.assertCalls(
|
| + (self.call.device._CheckSdkLevel(21)),
|
| + (mock.call.pylib.sdk.split_select.SelectSplits(
|
| + self.device, 'base.apk',
|
| + ['split1.apk', 'split2.apk', 'split3.apk']),
|
| + ['split2.apk']),
|
| + (mock.call.pylib.utils.apk_helper.GetPackageName('base.apk'),
|
| + 'test.package'),
|
| + (self.call.device.GetApplicationPaths('test.package'),
|
| + ['base-on-device.apk', 'split2-on-device.apk']),
|
| + (mock.call.pylib.utils.md5sum.CalculateDeviceMd5Sums(
|
| + ['base-on-device.apk', 'split2-on-device.apk'], self.device),
|
| + {'base-on-device.apk': 'AAA', 'split2-on-device.apk': 'BBB'}),
|
| + (mock.call.pylib.utils.md5sum.CalculateHostMd5Sums(
|
| + ['base.apk', 'split2.apk']),
|
| + {'base.apk': 'AAA', 'split2.apk': 'CCC'}),
|
| + (self.call.adb.InstallMultiple(
|
| + ['split2.apk'], partial='test.package', reinstall=True))):
|
| + self.device.InstallSplitApk('base.apk',
|
| + ['split1.apk', 'split2.apk', 'split3.apk'], reinstall=True, retries=0)
|
| +
|
|
|
| class DeviceUtilsRunShellCommandTest(DeviceUtilsTest):
|
|
|
| @@ -1081,8 +1121,8 @@ class DeviceUtilsClearApplicationStateTest(DeviceUtilsTest):
|
| def testClearApplicationState_packageDoesntExist(self):
|
| with self.assertCalls(
|
| (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'),
|
| - (self.call.device.GetApplicationPath('this.package.does.not.exist'),
|
| - None)):
|
| + (self.call.device.GetApplicationPaths('this.package.does.not.exist'),
|
| + [])):
|
| self.device.ClearApplicationState('this.package.does.not.exist')
|
|
|
| def testClearApplicationState_packageDoesntExistOnAndroidJBMR2OrAbove(self):
|
| @@ -1095,8 +1135,8 @@ class DeviceUtilsClearApplicationStateTest(DeviceUtilsTest):
|
| def testClearApplicationState_packageExists(self):
|
| with self.assertCalls(
|
| (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'),
|
| - (self.call.device.GetApplicationPath('this.package.exists'),
|
| - '/data/app/this.package.exists.apk'),
|
| + (self.call.device.GetApplicationPaths('this.package.exists'),
|
| + ['/data/app/this.package.exists.apk']),
|
| (self.call.adb.Shell('pm clear this.package.exists'),
|
| 'Success\r\n')):
|
| self.device.ClearApplicationState('this.package.exists')
|
|
|