| 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.GetBuildDirectory(), 'apks', '%s.apk' % suite_name) |
| 37 self._test_apk_package_name = constants.BROWSERTEST_TEST_PACKAGE_NAME | 35 self._test_apk_package_name = constants.BROWSERTEST_TEST_PACKAGE_NAME |
| 38 self._test_activity_name = constants.BROWSERTEST_TEST_ACTIVITY_NAME | 36 self._test_activity_name = constants.BROWSERTEST_TEST_ACTIVITY_NAME |
| 39 self._command_line_file = constants.BROWSERTEST_COMMAND_LINE_FILE | 37 self._command_line_file = constants.BROWSERTEST_COMMAND_LINE_FILE |
| 40 else: | 38 else: |
| 41 self.suite_path = os.path.join( | 39 self.suite_path = os.path.join( |
| 42 product_dir, '%s_apk' % suite_name, '%s-debug.apk' % suite_name) | 40 constants.GetBuildDirectory(), '%s_apk' % suite_name, |
| 41 '%s-debug.apk' % suite_name) |
| 43 self._test_apk_package_name = constants.GTEST_TEST_PACKAGE_NAME | 42 self._test_apk_package_name = constants.GTEST_TEST_PACKAGE_NAME |
| 44 self._test_activity_name = constants.GTEST_TEST_ACTIVITY_NAME | 43 self._test_activity_name = constants.GTEST_TEST_ACTIVITY_NAME |
| 45 self._command_line_file = constants.GTEST_COMMAND_LINE_FILE | 44 self._command_line_file = constants.GTEST_COMMAND_LINE_FILE |
| 46 | 45 |
| 47 def _CreateCommandLineFileOnDevice(self, adb, options): | 46 def _CreateCommandLineFileOnDevice(self, adb, options): |
| 48 command_line_file = tempfile.NamedTemporaryFile() | 47 command_line_file = tempfile.NamedTemporaryFile() |
| 49 # GTest expects argv[0] to be the executable path. | 48 # GTest expects argv[0] to be the executable path. |
| 50 command_line_file.write(self.suite_name + ' ' + options) | 49 command_line_file.write(self.suite_name + ' ' + options) |
| 51 command_line_file.flush() | 50 command_line_file.flush() |
| 52 adb.PushIfNeeded(command_line_file.name, | 51 adb.PushIfNeeded(command_line_file.name, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 finally: | 125 finally: |
| 127 self.tool.CleanUpEnvironment() | 126 self.tool.CleanUpEnvironment() |
| 128 logfile = android_commands.NewLineNormalizer(sys.stdout) | 127 logfile = android_commands.NewLineNormalizer(sys.stdout) |
| 129 return self._WatchFifo(adb, timeout=10, logfile=logfile) | 128 return self._WatchFifo(adb, timeout=10, logfile=logfile) |
| 130 | 129 |
| 131 #override | 130 #override |
| 132 def Install(self, adb): | 131 def Install(self, adb): |
| 133 self.tool.CopyFiles() | 132 self.tool.CopyFiles() |
| 134 adb.ManagedInstall(self.suite_path, False, | 133 adb.ManagedInstall(self.suite_path, False, |
| 135 package_name=self._test_apk_package_name) | 134 package_name=self._test_apk_package_name) |
| OLD | NEW |