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()) |
32 if suite_name == 'content_browsertests': | 34 if suite_name == 'content_browsertests': |
33 self.suite_path = os.path.join( | 35 self.suite_path = os.path.join( |
34 constants.GetOutDirectory(), 'apks', '%s.apk' % suite_name) | 36 product_dir, 'apks', '%s.apk' % suite_name) |
35 self._package_info = constants.PACKAGE_INFO['content_browsertests'] | 37 self._package_info = constants.PACKAGE_INFO['content_browsertests'] |
36 else: | 38 else: |
37 self.suite_path = os.path.join( | 39 self.suite_path = os.path.join( |
38 constants.GetOutDirectory(), '%s_apk' % suite_name, | 40 product_dir, '%s_apk' % suite_name, '%s-debug.apk' % suite_name) |
39 '%s-debug.apk' % suite_name) | |
40 self._package_info = constants.PACKAGE_INFO['gtest'] | 41 self._package_info = constants.PACKAGE_INFO['gtest'] |
41 | 42 |
42 def _CreateCommandLineFileOnDevice(self, adb, options): | 43 def _CreateCommandLineFileOnDevice(self, adb, options): |
43 command_line_file = tempfile.NamedTemporaryFile() | 44 command_line_file = tempfile.NamedTemporaryFile() |
44 # GTest expects argv[0] to be the executable path. | 45 # GTest expects argv[0] to be the executable path. |
45 command_line_file.write(self.suite_name + ' ' + options) | 46 command_line_file.write(self.suite_name + ' ' + options) |
46 command_line_file.flush() | 47 command_line_file.flush() |
47 adb.PushIfNeeded(command_line_file.name, | 48 adb.PushIfNeeded(command_line_file.name, |
48 self._package_info.cmdline_file) | 49 self._package_info.cmdline_file) |
49 | 50 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 finally: | 121 finally: |
121 self.tool.CleanUpEnvironment() | 122 self.tool.CleanUpEnvironment() |
122 logfile = android_commands.NewLineNormalizer(sys.stdout) | 123 logfile = android_commands.NewLineNormalizer(sys.stdout) |
123 return self._WatchFifo(adb, timeout=10, logfile=logfile) | 124 return self._WatchFifo(adb, timeout=10, logfile=logfile) |
124 | 125 |
125 #override | 126 #override |
126 def Install(self, adb): | 127 def Install(self, adb): |
127 self.tool.CopyFiles() | 128 self.tool.CopyFiles() |
128 adb.ManagedInstall(self.suite_path, False, | 129 adb.ManagedInstall(self.suite_path, False, |
129 package_name=self._package_info.package) | 130 package_name=self._package_info.package) |
OLD | NEW |