| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 def _TakeScreenshot(self, test): | 141 def _TakeScreenshot(self, test): |
| 142 """Takes a screenshot from the device.""" | 142 """Takes a screenshot from the device.""" |
| 143 screenshot_name = os.path.join(constants.SCREENSHOTS_DIR, '%s.png' % test) | 143 screenshot_name = os.path.join(constants.SCREENSHOTS_DIR, '%s.png' % test) |
| 144 logging.info('Taking screenshot named %s', screenshot_name) | 144 logging.info('Taking screenshot named %s', screenshot_name) |
| 145 self.device.old_interface.TakeScreenshot(screenshot_name) | 145 self.device.old_interface.TakeScreenshot(screenshot_name) |
| 146 | 146 |
| 147 def SetUp(self): | 147 def SetUp(self): |
| 148 """Sets up the test harness and device before all tests are run.""" | 148 """Sets up the test harness and device before all tests are run.""" |
| 149 super(TestRunner, self).SetUp() | 149 super(TestRunner, self).SetUp() |
| 150 if not self.device.old_interface.IsRootEnabled(): | 150 if not self.device.HasRoot(): |
| 151 logging.warning('Unable to enable java asserts for %s, non rooted device', | 151 logging.warning('Unable to enable java asserts for %s, non rooted device', |
| 152 str(self.device)) | 152 str(self.device)) |
| 153 else: | 153 else: |
| 154 if self.device.old_interface.SetJavaAssertsEnabled(True): | 154 if self.device.old_interface.SetJavaAssertsEnabled(True): |
| 155 self.device.old_interface.Reboot(full_reboot=False) | 155 self.device.old_interface.Reboot(full_reboot=False) |
| 156 | 156 |
| 157 # We give different default value to launch HTTP server based on shard index | 157 # We give different default value to launch HTTP server based on shard index |
| 158 # because it may have race condition when multiple processes are trying to | 158 # because it may have race condition when multiple processes are trying to |
| 159 # launch lighttpd with same port at same time. | 159 # launch lighttpd with same port at same time. |
| 160 self.LaunchTestHttpServer( | 160 self.LaunchTestHttpServer( |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 duration_ms = 0 | 383 duration_ms = 0 |
| 384 message = str(e) | 384 message = str(e) |
| 385 if not message: | 385 if not message: |
| 386 message = 'No information.' | 386 message = 'No information.' |
| 387 results.AddResult(test_result.InstrumentationTestResult( | 387 results.AddResult(test_result.InstrumentationTestResult( |
| 388 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, | 388 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, |
| 389 log=message)) | 389 log=message)) |
| 390 raw_result = None | 390 raw_result = None |
| 391 self.TestTeardown(test, raw_result) | 391 self.TestTeardown(test, raw_result) |
| 392 return (results, None if results.DidRunPass() else test) | 392 return (results, None if results.DidRunPass() else test) |
| OLD | NEW |