| 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 import sys | 8 import sys |
| 9 | 9 |
| 10 from pylib import android_commands | 10 from pylib import android_commands |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 os.path.join( | 240 os.path.join( |
| 241 self.adb.GetExternalStorage(), | 241 self.adb.GetExternalStorage(), |
| 242 'third_party/WebKit/Source/WebKit/chromium/tests/data')) | 242 'third_party/WebKit/Source/WebKit/chromium/tests/data')) |
| 243 | 243 |
| 244 def RunTests(self): | 244 def RunTests(self): |
| 245 """Runs tests on a single device. | 245 """Runs tests on a single device. |
| 246 | 246 |
| 247 Returns: | 247 Returns: |
| 248 A TestResults object. | 248 A TestResults object. |
| 249 """ | 249 """ |
| 250 try: | 250 if self._gtest_filter: |
| 251 self.test_package.CreateTestRunnerScript(self._gtest_filter, | 251 try: |
| 252 self._test_arguments) | 252 self.test_package.CreateTestRunnerScript(self._gtest_filter, |
| 253 self.test_results = self.test_package.RunTestsAndListResults() | 253 self._test_arguments) |
| 254 except errors.DeviceUnresponsiveError as e: | 254 self.test_results = self.test_package.RunTestsAndListResults() |
| 255 # Make sure this device is not attached | 255 except errors.DeviceUnresponsiveError as e: |
| 256 if android_commands.IsDeviceAttached(self.device): | 256 # Make sure this device is not attached |
| 257 raise e | 257 logging.warning(e) |
| 258 | 258 if android_commands.IsDeviceAttached(self.device): |
| 259 # TODO(frankf): We should report these as "skipped" not "failures". | 259 raise e |
| 260 # Wrap the results | 260 self.test_results.device_exception = device_exception |
| 261 logging.warning(e) | 261 # Calculate unknown test results. |
| 262 failed_tests = [] | 262 finally: |
| 263 for t in self._gtest_filter.split(':'): | 263 # TODO(frankf): Do not break TestResults encapsulation. |
| 264 failed_tests += [BaseTestResult(t, '')] | 264 all_tests = set(self._gtest_filter.split(':')) |
| 265 self.test_results = TestResults.FromRun( | 265 all_tests_ran = set([t.name for t in self.test_results.GetAll()]) |
| 266 failed=failed_tests, device_exception=self.device) | 266 unknown_tests = all_tests - all_tests_ran |
| 267 self.test_results.unknown = [BaseTestResult(t, '') for t in |
| 268 unknown_tests] |
| 267 | 269 |
| 268 return self.test_results | 270 return self.test_results |
| 269 | 271 |
| 270 def SetUp(self): | 272 def SetUp(self): |
| 271 """Sets up necessary test enviroment for the test suite.""" | 273 """Sets up necessary test enviroment for the test suite.""" |
| 272 super(SingleTestRunner, self).SetUp() | 274 super(SingleTestRunner, self).SetUp() |
| 273 self.adb.ClearApplicationState(constants.CHROME_PACKAGE) | 275 self.adb.ClearApplicationState(constants.CHROME_PACKAGE) |
| 274 if self.dump_debug_info: | 276 if self.dump_debug_info: |
| 275 self.dump_debug_info.StartRecordingLog(True) | 277 self.dump_debug_info.StartRecordingLog(True) |
| 276 self.StripAndCopyFiles() | 278 self.StripAndCopyFiles() |
| 277 self.LaunchHelperToolsForTestSuite() | 279 self.LaunchHelperToolsForTestSuite() |
| 278 self.tool.SetupEnvironment() | 280 self.tool.SetupEnvironment() |
| 279 | 281 |
| 280 def TearDown(self): | 282 def TearDown(self): |
| 281 """Cleans up the test enviroment for the test suite.""" | 283 """Cleans up the test enviroment for the test suite.""" |
| 282 self.tool.CleanUpEnvironment() | 284 self.tool.CleanUpEnvironment() |
| 283 if self.test_package.cleanup_test_files: | 285 if self.test_package.cleanup_test_files: |
| 284 self.adb.RemovePushedFiles() | 286 self.adb.RemovePushedFiles() |
| 285 if self.dump_debug_info: | 287 if self.dump_debug_info: |
| 286 self.dump_debug_info.StopRecordingLog() | 288 self.dump_debug_info.StopRecordingLog() |
| 287 if self.dump_debug_info: | 289 if self.dump_debug_info: |
| 288 self.dump_debug_info.ArchiveNewCrashFiles() | 290 self.dump_debug_info.ArchiveNewCrashFiles() |
| 289 super(SingleTestRunner, self).TearDown() | 291 super(SingleTestRunner, self).TearDown() |
| OLD | NEW |