| 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 # pylint: disable=W0212 | 6 # pylint: disable=W0212 |
| 7 | 7 |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import shlex | 10 import shlex |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 def __init__(self, suite_name): | 27 def __init__(self, suite_name): |
| 28 """ | 28 """ |
| 29 Args: | 29 Args: |
| 30 suite_name: Name of the test suite (e.g. base_unittests). | 30 suite_name: Name of the test suite (e.g. base_unittests). |
| 31 """ | 31 """ |
| 32 TestPackage.__init__(self, suite_name) | 32 TestPackage.__init__(self, suite_name) |
| 33 if suite_name == 'content_browsertests': | 33 if suite_name == 'content_browsertests': |
| 34 self.suite_path = os.path.join( | 34 self.suite_path = os.path.join( |
| 35 constants.GetOutDirectory(), 'apks', '%s.apk' % suite_name) | 35 constants.GetOutDirectory(), 'apks', '%s.apk' % suite_name) |
| 36 self._package_info = constants.PACKAGE_INFO['content_browsertests'] | 36 self._package_info = constants.PACKAGE_INFO['content_browsertests'] |
| 37 elif suite_name == 'components_browsertests': |
| 38 self.suite_path = os.path.join( |
| 39 constants.GetOutDirectory(), 'apks', '%s.apk' % suite_name) |
| 40 self._package_info = constants.PACKAGE_INFO['components_browsertests'] |
| 37 else: | 41 else: |
| 38 self.suite_path = os.path.join( | 42 self.suite_path = os.path.join( |
| 39 constants.GetOutDirectory(), '%s_apk' % suite_name, | 43 constants.GetOutDirectory(), '%s_apk' % suite_name, |
| 40 '%s-debug.apk' % suite_name) | 44 '%s-debug.apk' % suite_name) |
| 41 self._package_info = constants.PACKAGE_INFO['gtest'] | 45 self._package_info = constants.PACKAGE_INFO['gtest'] |
| 42 | 46 |
| 43 def _CreateCommandLineFileOnDevice(self, device, options): | 47 def _CreateCommandLineFileOnDevice(self, device, options): |
| 44 device.WriteFile(self._package_info.cmdline_file, | 48 device.WriteFile(self._package_info.cmdline_file, |
| 45 self.suite_name + ' ' + options) | 49 self.suite_name + ' ' + options) |
| 46 | 50 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 # files over time. | 87 # files over time. |
| 84 if self.suite_name == 'content_browsertests': | 88 if self.suite_name == 'content_browsertests': |
| 85 try: | 89 try: |
| 86 device.RunShellCommand( | 90 device.RunShellCommand( |
| 87 'rm -r %s/content_shell' % device.GetExternalStoragePath(), | 91 'rm -r %s/content_shell' % device.GetExternalStoragePath(), |
| 88 timeout=60 * 2) | 92 timeout=60 * 2) |
| 89 except device_errors.CommandFailedError: | 93 except device_errors.CommandFailedError: |
| 90 # TODO(jbudorick) Handle this exception appropriately once the | 94 # TODO(jbudorick) Handle this exception appropriately once the |
| 91 # conversions are done. | 95 # conversions are done. |
| 92 pass | 96 pass |
| 97 elif self.suite_name == 'components_browsertests': |
| 98 try: |
| 99 device.RunShellCommand( |
| 100 'rm -r %s/components_shell' % device.GetExternalStoragePath(), |
| 101 timeout=60 * 2) |
| 102 except device_errors.CommandFailedError: |
| 103 # TODO(jbudorick) Handle this exception appropriately once the |
| 104 # conversions are done. |
| 105 pass |
| 93 | 106 |
| 94 #override | 107 #override |
| 95 def CreateCommandLineFileOnDevice(self, device, test_filter, test_arguments): | 108 def CreateCommandLineFileOnDevice(self, device, test_filter, test_arguments): |
| 96 self._CreateCommandLineFileOnDevice( | 109 self._CreateCommandLineFileOnDevice( |
| 97 device, '--gtest_filter=%s %s' % (test_filter, test_arguments)) | 110 device, '--gtest_filter=%s %s' % (test_filter, test_arguments)) |
| 98 | 111 |
| 99 #override | 112 #override |
| 100 def GetAllTests(self, device): | 113 def GetAllTests(self, device): |
| 101 self._CreateCommandLineFileOnDevice(device, '--gtest_list_tests') | 114 self._CreateCommandLineFileOnDevice(device, '--gtest_list_tests') |
| 102 try: | 115 try: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 125 self._StartActivity(device, force_stop=False) | 138 self._StartActivity(device, force_stop=False) |
| 126 finally: | 139 finally: |
| 127 self.tool.CleanUpEnvironment() | 140 self.tool.CleanUpEnvironment() |
| 128 logfile = android_commands.NewLineNormalizer(sys.stdout) | 141 logfile = android_commands.NewLineNormalizer(sys.stdout) |
| 129 return self._WatchFifo(device, timeout=10, logfile=logfile) | 142 return self._WatchFifo(device, timeout=10, logfile=logfile) |
| 130 | 143 |
| 131 #override | 144 #override |
| 132 def Install(self, device): | 145 def Install(self, device): |
| 133 self.tool.CopyFiles(device) | 146 self.tool.CopyFiles(device) |
| 134 device.Install(self.suite_path) | 147 device.Install(self.suite_path) |
| OLD | NEW |