| 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 """Class for running instrumentation tests on a single device.""" | 5 """Class for running instrumentation tests on a single device.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import sys | 10 import sys |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 logging.info('Taking screenshot named %s', screenshot_name) | 86 logging.info('Taking screenshot named %s', screenshot_name) |
| 87 self.device.TakeScreenshot(screenshot_name) | 87 self.device.TakeScreenshot(screenshot_name) |
| 88 | 88 |
| 89 def SetUp(self): | 89 def SetUp(self): |
| 90 """Sets up the test harness and device before all tests are run.""" | 90 """Sets up the test harness and device before all tests are run.""" |
| 91 super(TestRunner, self).SetUp() | 91 super(TestRunner, self).SetUp() |
| 92 if not self.device.HasRoot(): | 92 if not self.device.HasRoot(): |
| 93 logging.warning('Unable to enable java asserts for %s, non rooted device', | 93 logging.warning('Unable to enable java asserts for %s, non rooted device', |
| 94 str(self.device)) | 94 str(self.device)) |
| 95 else: | 95 else: |
| 96 if self.device.SetJavaAsserts(True): | 96 if self.device.SetJavaAsserts(self.options.set_asserts): |
| 97 # TODO(jbudorick) How to best do shell restart after the | 97 # TODO(jbudorick) How to best do shell restart after the |
| 98 # android_commands refactor? | 98 # android_commands refactor? |
| 99 self.device.RunShellCommand('stop') | 99 self.device.RunShellCommand('stop') |
| 100 self.device.RunShellCommand('start') | 100 self.device.RunShellCommand('start') |
| 101 | 101 |
| 102 # We give different default value to launch HTTP server based on shard index | 102 # We give different default value to launch HTTP server based on shard index |
| 103 # because it may have race condition when multiple processes are trying to | 103 # because it may have race condition when multiple processes are trying to |
| 104 # launch lighttpd with same port at same time. | 104 # launch lighttpd with same port at same time. |
| 105 self.LaunchTestHttpServer( | 105 self.LaunchTestHttpServer( |
| 106 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) | 106 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 except device_errors.CommandTimeoutError as e: | 464 except device_errors.CommandTimeoutError as e: |
| 465 results.AddResult(test_result.InstrumentationTestResult( | 465 results.AddResult(test_result.InstrumentationTestResult( |
| 466 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, | 466 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, |
| 467 log=str(e) or 'No information')) | 467 log=str(e) or 'No information')) |
| 468 except device_errors.DeviceUnreachableError as e: | 468 except device_errors.DeviceUnreachableError as e: |
| 469 results.AddResult(test_result.InstrumentationTestResult( | 469 results.AddResult(test_result.InstrumentationTestResult( |
| 470 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 470 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
| 471 log=str(e) or 'No information')) | 471 log=str(e) or 'No information')) |
| 472 self.TestTeardown(test, results) | 472 self.TestTeardown(test, results) |
| 473 return (results, None if results.DidRunPass() else test) | 473 return (results, None if results.DidRunPass() else test) |
| OLD | NEW |