OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Defines TestPackageApk to help run APK-based native tests.""" | 5 """Defines TestPackageApk to help run APK-based native tests.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import shlex | 9 import shlex |
10 import sys | 10 import sys |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 class TestPackageApk(TestPackage): | 23 class TestPackageApk(TestPackage): |
24 """A helper class for running APK-based native tests.""" | 24 """A helper class for running APK-based native tests.""" |
25 | 25 |
26 def __init__(self, suite_name): | 26 def __init__(self, suite_name): |
27 """ | 27 """ |
28 Args: | 28 Args: |
29 suite_name: Name of the test suite (e.g. base_unittests). | 29 suite_name: Name of the test suite (e.g. base_unittests). |
30 """ | 30 """ |
31 TestPackage.__init__(self, suite_name) | 31 TestPackage.__init__(self, suite_name) |
32 product_dir = os.path.join(cmd_helper.OutDirectory.get(), | |
33 constants.GetBuildType()) | |
34 if suite_name == 'content_browsertests': | 32 if suite_name == 'content_browsertests': |
35 self.suite_path = os.path.join( | 33 self.suite_path = os.path.join( |
36 product_dir, 'apks', '%s.apk' % suite_name) | 34 constants.GetOutDirectory(), 'apks', '%s.apk' % suite_name) |
37 self._package_info = constants.PACKAGE_INFO['content_browsertests'] | 35 self._package_info = constants.PACKAGE_INFO['content_browsertests'] |
38 else: | 36 else: |
39 self.suite_path = os.path.join( | 37 self.suite_path = os.path.join( |
40 product_dir, '%s_apk' % suite_name, '%s-debug.apk' % suite_name) | 38 constants.GetOutDirectory(), '%s_apk' % suite_name, |
| 39 '%s-debug.apk' % suite_name) |
41 self._package_info = constants.PACKAGE_INFO['gtest'] | 40 self._package_info = constants.PACKAGE_INFO['gtest'] |
42 | 41 |
43 def _CreateCommandLineFileOnDevice(self, adb, options): | 42 def _CreateCommandLineFileOnDevice(self, adb, options): |
44 command_line_file = tempfile.NamedTemporaryFile() | 43 command_line_file = tempfile.NamedTemporaryFile() |
45 # GTest expects argv[0] to be the executable path. | 44 # GTest expects argv[0] to be the executable path. |
46 command_line_file.write(self.suite_name + ' ' + options) | 45 command_line_file.write(self.suite_name + ' ' + options) |
47 command_line_file.flush() | 46 command_line_file.flush() |
48 adb.PushIfNeeded(command_line_file.name, | 47 adb.PushIfNeeded(command_line_file.name, |
49 self._package_info.cmdline_file) | 48 self._package_info.cmdline_file) |
50 | 49 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 finally: | 120 finally: |
122 self.tool.CleanUpEnvironment() | 121 self.tool.CleanUpEnvironment() |
123 logfile = android_commands.NewLineNormalizer(sys.stdout) | 122 logfile = android_commands.NewLineNormalizer(sys.stdout) |
124 return self._WatchFifo(adb, timeout=10, logfile=logfile) | 123 return self._WatchFifo(adb, timeout=10, logfile=logfile) |
125 | 124 |
126 #override | 125 #override |
127 def Install(self, adb): | 126 def Install(self, adb): |
128 self.tool.CopyFiles() | 127 self.tool.CopyFiles() |
129 adb.ManagedInstall(self.suite_path, False, | 128 adb.ManagedInstall(self.suite_path, False, |
130 package_name=self._package_info.package) | 129 package_name=self._package_info.package) |
OLD | NEW |