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 import glob | 5 import glob |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 | 8 |
9 from pylib import android_commands | 9 from pylib import android_commands |
10 from pylib import constants | 10 from pylib import constants |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 | 156 |
157 def __init__(self, device, test_suite, test_arguments, timeout, | 157 def __init__(self, device, test_suite, test_arguments, timeout, |
158 cleanup_test_files, tool_name, build_type, | 158 cleanup_test_files, tool_name, build_type, |
159 in_webkit_checkout, test_apk_package_name=None, | 159 in_webkit_checkout, test_apk_package_name=None, |
160 test_activity_name=None, command_line_file=None): | 160 test_activity_name=None, command_line_file=None): |
161 super(TestRunner, self).__init__(device, tool_name, build_type) | 161 super(TestRunner, self).__init__(device, tool_name, build_type) |
162 self._running_on_emulator = self.device.startswith('emulator') | 162 self._running_on_emulator = self.device.startswith('emulator') |
163 self._test_arguments = test_arguments | 163 self._test_arguments = test_arguments |
164 self.in_webkit_checkout = in_webkit_checkout | 164 self.in_webkit_checkout = in_webkit_checkout |
165 self._cleanup_test_files = cleanup_test_files | 165 self._cleanup_test_files = cleanup_test_files |
166 self._test_apk_package_name = test_apk_package_name | |
nilesh
2013/02/25 21:27:49
Nit: This is not used anymore.
| |
166 | 167 |
167 logging.warning('Test suite: ' + test_suite) | 168 logging.warning('Test suite: ' + test_suite) |
168 if os.path.splitext(test_suite)[1] == '.apk': | 169 if os.path.splitext(test_suite)[1] == '.apk': |
169 self.test_package = test_package_apk.TestPackageApk( | 170 self.test_package = test_package_apk.TestPackageApk( |
170 self.adb, | 171 self.adb, |
171 device, | 172 device, |
172 test_suite, | 173 test_suite, |
173 timeout, | 174 timeout, |
174 self._cleanup_test_files, | 175 self._cleanup_test_files, |
175 self.tool, | 176 self.tool, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 test: a gtest filter string to run. | 248 test: a gtest filter string to run. |
248 | 249 |
249 Returns: | 250 Returns: |
250 Tuple: (TestResults, test to retry or None) | 251 Tuple: (TestResults, test to retry or None) |
251 """ | 252 """ |
252 test_results = test_result.TestResults() | 253 test_results = test_result.TestResults() |
253 if not test: | 254 if not test: |
254 return test_results, None | 255 return test_results, None |
255 | 256 |
256 try: | 257 try: |
258 self.test_package.ClearApplicationState() | |
257 self.test_package.CreateTestRunnerScript(test, self._test_arguments) | 259 self.test_package.CreateTestRunnerScript(test, self._test_arguments) |
258 test_results = self.test_package.RunTestsAndListResults() | 260 test_results = self.test_package.RunTestsAndListResults() |
259 except errors.DeviceUnresponsiveError as e: | 261 except errors.DeviceUnresponsiveError as e: |
260 # Make sure this device is not attached | 262 # Make sure this device is not attached |
261 logging.warning(e) | 263 logging.warning(e) |
262 if android_commands.IsDeviceAttached(self.device): | 264 if android_commands.IsDeviceAttached(self.device): |
263 raise | 265 raise |
264 test_results.device_exception = device_exception | 266 test_results.device_exception = device_exception |
265 # Calculate unknown test results. | 267 # Calculate unknown test results. |
266 # TODO(frankf): Do not break TestResults encapsulation. | 268 # TODO(frankf): Do not break TestResults encapsulation. |
267 all_tests = set(test.split(':')) | 269 all_tests = set(test.split(':')) |
268 all_tests_ran = set([t.name for t in test_results.GetAll()]) | 270 all_tests_ran = set([t.name for t in test_results.GetAll()]) |
269 unknown_tests = all_tests - all_tests_ran | 271 unknown_tests = all_tests - all_tests_ran |
270 test_results.unknown = [test_result.BaseTestResult(t, '') for t in | 272 test_results.unknown = [test_result.BaseTestResult(t, '') for t in |
271 unknown_tests] | 273 unknown_tests] |
272 retry = ':'.join([t.name for t in test_results.GetAllBroken()]) | 274 retry = ':'.join([t.name for t in test_results.GetAllBroken()]) |
273 return test_results, retry | 275 return test_results, retry |
274 | 276 |
275 def SetUp(self): | 277 def SetUp(self): |
276 """Sets up necessary test enviroment for the test suite.""" | 278 """Sets up necessary test enviroment for the test suite.""" |
277 super(TestRunner, self).SetUp() | 279 super(TestRunner, self).SetUp() |
278 self.adb.ClearApplicationState(constants.CHROME_PACKAGE) | |
279 self.StripAndCopyFiles() | 280 self.StripAndCopyFiles() |
280 if _TestSuiteRequiresMockTestServer(self.test_package.test_suite_basename): | 281 if _TestSuiteRequiresMockTestServer(self.test_package.test_suite_basename): |
281 self.LaunchChromeTestServerSpawner() | 282 self.LaunchChromeTestServerSpawner() |
282 self.tool.SetupEnvironment() | 283 self.tool.SetupEnvironment() |
283 | 284 |
284 def TearDown(self): | 285 def TearDown(self): |
285 """Cleans up the test enviroment for the test suite.""" | 286 """Cleans up the test enviroment for the test suite.""" |
286 self.tool.CleanUpEnvironment() | 287 self.tool.CleanUpEnvironment() |
287 if self._cleanup_test_files: | 288 if self._cleanup_test_files: |
288 self.adb.RemovePushedFiles() | 289 self.adb.RemovePushedFiles() |
289 super(TestRunner, self).TearDown() | 290 super(TestRunner, self).TearDown() |
OLD | NEW |