Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: build/android/pylib/gtest/local_device_gtest_run.py

Issue 1165623003: [Android] Allow gtests to pull app data off the device before clearing it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/gtest/gtest_test_instance.py ('k') | build/android/pylib/gtest/test_options.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/gtest/local_device_gtest_run.py
diff --git a/build/android/pylib/gtest/local_device_gtest_run.py b/build/android/pylib/gtest/local_device_gtest_run.py
index 15a58a459f81e68f89c7fa8c62143ba5b9a2fd0c..c375b970943bc50a7f76e2b689a7aa7ab0dc52fa 100644
--- a/build/android/pylib/gtest/local_device_gtest_run.py
+++ b/build/android/pylib/gtest/local_device_gtest_run.py
@@ -2,9 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-
+import itertools
import logging
import os
+import posixpath
from pylib import constants
from pylib import ports
@@ -37,6 +38,20 @@ _SUITE_REQUIRES_TEST_SERVER_SPAWNER = [
'net_unittests', 'unit_tests'
]
+# TODO(jbudorick): Move this inside _ApkDelegate once TestPackageApk is gone.
+def PullAppFilesImpl(device, package, files, directory):
+ device_dir = device.GetApplicationDataDirectory(package)
+ host_dir = os.path.join(directory, str(device))
+ for f in files:
+ device_file = posixpath.join(device_dir, f)
+ host_file = os.path.join(host_dir, *f.split(posixpath.sep))
+ host_file_base, ext = os.path.splitext(host_file)
+ for i in itertools.count():
+ host_file = '%s_%d%s' % (host_file_base, i, ext)
+ if not os.path.exists(host_file):
+ break
+ device.PullFile(device_file, host_file)
+
class _ApkDelegate(object):
def __init__(self, apk):
self._apk = apk
@@ -63,6 +78,9 @@ class _ApkDelegate(object):
return device.StartInstrumentation(
self._component, extras=extras, raw=False, **kwargs)
+ def PullAppFiles(self, device, files, directory):
+ PullAppFilesImpl(device, self._package, files, directory)
+
def Clear(self, device):
device.ClearApplicationState(self._package)
@@ -119,6 +137,9 @@ class _ExeDelegate(object):
env=env, **kwargs)
return output
+ def PullAppFiles(self, device, files, directory):
+ pass
+
def Clear(self, device):
device.KillAll(self._exe_file_name, blocking=True, timeout=30, quiet=True)
@@ -199,6 +220,9 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun):
device, '--gtest_filter=%s' % test, timeout=900, retries=0)
for s in self._servers[str(device)]:
s.Reset()
+ if self._test_instance.app_files:
+ self._delegate.PullAppFiles(device, self._test_instance.app_files,
+ self._test_instance.app_file_dir)
self._delegate.Clear(device)
# Parse the output.
« no previous file with comments | « build/android/pylib/gtest/gtest_test_instance.py ('k') | build/android/pylib/gtest/test_options.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698