| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 test: a gtest filter string to run. | 247 test: a gtest filter string to run. |
| 248 | 248 |
| 249 Returns: | 249 Returns: |
| 250 Tuple: (TestResults, test to retry or None) | 250 Tuple: (TestResults, test to retry or None) |
| 251 """ | 251 """ |
| 252 test_results = test_result.TestResults() | 252 test_results = test_result.TestResults() |
| 253 if not test: | 253 if not test: |
| 254 return test_results, None | 254 return test_results, None |
| 255 | 255 |
| 256 try: | 256 try: |
| 257 self.test_package.ClearApplicationState() |
| 257 self.test_package.CreateTestRunnerScript(test, self._test_arguments) | 258 self.test_package.CreateTestRunnerScript(test, self._test_arguments) |
| 258 test_results = self.test_package.RunTestsAndListResults() | 259 test_results = self.test_package.RunTestsAndListResults() |
| 259 except errors.DeviceUnresponsiveError as e: | 260 except errors.DeviceUnresponsiveError as e: |
| 260 # Make sure this device is not attached | 261 # Make sure this device is not attached |
| 261 logging.warning(e) | 262 logging.warning(e) |
| 262 if android_commands.IsDeviceAttached(self.device): | 263 if android_commands.IsDeviceAttached(self.device): |
| 263 raise | 264 raise |
| 264 test_results.device_exception = device_exception | 265 test_results.device_exception = device_exception |
| 265 # Calculate unknown test results. | 266 # Calculate unknown test results. |
| 266 # TODO(frankf): Do not break TestResults encapsulation. | 267 # TODO(frankf): Do not break TestResults encapsulation. |
| 267 all_tests = set(test.split(':')) | 268 all_tests = set(test.split(':')) |
| 268 all_tests_ran = set([t.name for t in test_results.GetAll()]) | 269 all_tests_ran = set([t.name for t in test_results.GetAll()]) |
| 269 unknown_tests = all_tests - all_tests_ran | 270 unknown_tests = all_tests - all_tests_ran |
| 270 test_results.unknown = [test_result.BaseTestResult(t, '') for t in | 271 test_results.unknown = [test_result.BaseTestResult(t, '') for t in |
| 271 unknown_tests] | 272 unknown_tests] |
| 272 retry = ':'.join([t.name for t in test_results.GetAllBroken()]) | 273 retry = ':'.join([t.name for t in test_results.GetAllBroken()]) |
| 273 return test_results, retry | 274 return test_results, retry |
| 274 | 275 |
| 275 def SetUp(self): | 276 def SetUp(self): |
| 276 """Sets up necessary test enviroment for the test suite.""" | 277 """Sets up necessary test enviroment for the test suite.""" |
| 277 super(TestRunner, self).SetUp() | 278 super(TestRunner, self).SetUp() |
| 278 self.adb.ClearApplicationState(constants.CHROME_PACKAGE) | |
| 279 self.StripAndCopyFiles() | 279 self.StripAndCopyFiles() |
| 280 if _TestSuiteRequiresMockTestServer(self.test_package.test_suite_basename): | 280 if _TestSuiteRequiresMockTestServer(self.test_package.test_suite_basename): |
| 281 self.LaunchChromeTestServerSpawner() | 281 self.LaunchChromeTestServerSpawner() |
| 282 self.tool.SetupEnvironment() | 282 self.tool.SetupEnvironment() |
| 283 | 283 |
| 284 def TearDown(self): | 284 def TearDown(self): |
| 285 """Cleans up the test enviroment for the test suite.""" | 285 """Cleans up the test enviroment for the test suite.""" |
| 286 self.tool.CleanUpEnvironment() | 286 self.tool.CleanUpEnvironment() |
| 287 if self._cleanup_test_files: | 287 if self._cleanup_test_files: |
| 288 self.adb.RemovePushedFiles() | 288 self.adb.RemovePushedFiles() |
| 289 super(TestRunner, self).TearDown() | 289 super(TestRunner, self).TearDown() |
| OLD | NEW |