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 collections | 7 import collections |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 def _TakeScreenshot(self, test): | 90 def _TakeScreenshot(self, test): |
91 """Takes a screenshot from the device.""" | 91 """Takes a screenshot from the device.""" |
92 screenshot_name = os.path.join(constants.SCREENSHOTS_DIR, '%s.png' % test) | 92 screenshot_name = os.path.join(constants.SCREENSHOTS_DIR, '%s.png' % test) |
93 logging.info('Taking screenshot named %s', screenshot_name) | 93 logging.info('Taking screenshot named %s', screenshot_name) |
94 self.device.TakeScreenshot(screenshot_name) | 94 self.device.TakeScreenshot(screenshot_name) |
95 | 95 |
96 def SetUp(self): | 96 def SetUp(self): |
97 """Sets up the test harness and device before all tests are run.""" | 97 """Sets up the test harness and device before all tests are run.""" |
98 super(TestRunner, self).SetUp() | 98 super(TestRunner, self).SetUp() |
99 if not self.device.HasRoot(): | 99 if not self.device.HasRoot(): |
100 logging.warning('Unable to enable java asserts for %s, non rooted device', | 100 logging.warning('Unable to enable java asserts for %s; run `adb root`.', |
101 str(self.device)) | 101 str(self.device)) |
102 else: | 102 else: |
103 if self.device.SetJavaAsserts(self.options.set_asserts): | 103 if self.device.SetJavaAsserts(self.options.set_asserts): |
104 self.device.RunShellCommand('stop') | 104 self.device.RunShellCommand('stop') |
105 self.device.RunShellCommand('start') | 105 self.device.RunShellCommand('start') |
106 self.device.WaitUntilFullyBooted() | 106 self.device.WaitUntilFullyBooted() |
107 | 107 |
108 # We give different default value to launch HTTP server based on shard index | 108 # We give different default value to launch HTTP server based on shard index |
109 # because it may have race condition when multiple processes are trying to | 109 # because it may have race condition when multiple processes are trying to |
110 # launch lighttpd with same port at same time. | 110 # launch lighttpd with same port at same time. |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 result_name, ' '.join(flag_modifiers.add)) | 411 result_name, ' '.join(flag_modifiers.add)) |
412 if flag_modifiers.remove: | 412 if flag_modifiers.remove: |
413 result_name = '%s without {%s}' % ( | 413 result_name = '%s without {%s}' % ( |
414 result_name, ' '.join(flag_modifiers.remove)) | 414 result_name, ' '.join(flag_modifiers.remove)) |
415 result.SetName(result_name) | 415 result.SetName(result_name) |
416 results.AddResult(result) | 416 results.AddResult(result) |
417 | 417 |
418 self.TestTeardown(test, results) | 418 self.TestTeardown(test, results) |
419 | 419 |
420 return (results, None if results.DidRunPass() else test) | 420 return (results, None if results.DidRunPass() else test) |
OLD | NEW |