summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorjbudorick <jbudorick@chromium.org>2016-01-15 13:39:31 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-15 21:40:40 +0000
commit4aa57448482ce4abf01d65a80d113a4b664890a9 (patch)
treeb9f1f5b388ea748202dd4636159f143f3442db18 /build
parent5afb10f3485f626a04aac9af869a5b38ed052071 (diff)
downloadchromium_src-4aa57448482ce4abf01d65a80d113a4b664890a9.zip
chromium_src-4aa57448482ce4abf01d65a80d113a4b664890a9.tar.gz
chromium_src-4aa57448482ce4abf01d65a80d113a4b664890a9.tar.bz2
[Android] Restore permissions when clearing app state in instrumentation tests.
BUG=577855 Review URL: https://codereview.chromium.org/1591753003 Cr-Commit-Position: refs/heads/master@{#369849}
Diffstat (limited to 'build')
-rw-r--r--build/android/pylib/instrumentation/test_package.py25
-rw-r--r--build/android/pylib/instrumentation/test_runner.py5
2 files changed, 23 insertions, 7 deletions
diff --git a/build/android/pylib/instrumentation/test_package.py b/build/android/pylib/instrumentation/test_package.py
index d6469b2..e2e3b77 100644
--- a/build/android/pylib/instrumentation/test_package.py
+++ b/build/android/pylib/instrumentation/test_package.py
@@ -19,14 +19,23 @@ class TestPackage(test_jar.TestJar):
raise Exception('%s not found, please build it' % apk_path)
self._additional_apks = additional_apks or []
self._apk_name = os.path.splitext(os.path.basename(apk_path))[0]
- self._apk_path = apk_path
- self._apk_under_test = apk_under_test
- self._package_name = apk_helper.GetPackageName(self._apk_path)
+ if apk_under_test:
+ self._apk_under_test = apk_helper.ApkHelper(apk_under_test)
+ else:
+ self._apk_under_test = None
+ self._test_apk = apk_helper.ApkHelper(apk_path)
self._test_support_apk_path = test_support_apk_path
def GetApkPath(self):
"""Returns the absolute path to the APK."""
- return self._apk_path
+ return self._test_apk.path
+
+ def GetApkUnderTest(self):
+ """Returns an ApkHelper instance for the apk under test.
+
+ Note that --apk-under-test is not required, so this can be None.
+ """
+ return self._apk_under_test
def GetApkName(self):
"""Returns the name of the apk without the suffix."""
@@ -34,12 +43,16 @@ class TestPackage(test_jar.TestJar):
def GetPackageName(self):
"""Returns the package name of this APK."""
- return self._package_name
+ return self._test_apk.GetPackageName()
+
+ def GetTestApk(self):
+ """Returns an ApkHelper instance for the test apk."""
+ return self._test_apk
# Override.
def Install(self, device):
if self._apk_under_test:
- device.Install(self._apk_under_test)
+ device.Install(self._apk_under_test.path)
device.Install(self.GetApkPath())
if (self._test_support_apk_path and
os.path.exists(self._test_support_apk_path)):
diff --git a/build/android/pylib/instrumentation/test_runner.py b/build/android/pylib/instrumentation/test_runner.py
index 7579bee..b4bbb62 100644
--- a/build/android/pylib/instrumentation/test_runner.py
+++ b/build/android/pylib/instrumentation/test_runner.py
@@ -230,7 +230,10 @@ class TestRunner(base_test_runner.BaseTestRunner):
self.device.RunShellCommand(
'rm -f %s' % self.coverage_device_file)
elif self.package_info:
- self.device.ClearApplicationState(self.package_info.package)
+ apk_under_test = self.test_pkg.GetApkUnderTest()
+ permissions = apk_under_test.GetPermissions() if apk_under_test else None
+ self.device.ClearApplicationState(
+ self.package_info.package, permissions=permissions)
def TearDownPerfMonitoring(self, test):
"""Cleans up performance monitoring if the specified test required it.