| 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 """Base class for running tests on a single device.""" | 5 """Base class for running tests on a single device.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import time | 8 import time |
| 9 | 9 |
| 10 from pylib import ports | 10 from pylib import ports |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 Returns: | 65 Returns: |
| 66 Tuple containing: | 66 Tuple containing: |
| 67 (base_test_result.TestRunResults, tests to rerun or None) | 67 (base_test_result.TestRunResults, tests to rerun or None) |
| 68 """ | 68 """ |
| 69 raise NotImplementedError | 69 raise NotImplementedError |
| 70 | 70 |
| 71 def InstallTestPackage(self): | 71 def InstallTestPackage(self): |
| 72 """Installs the test package once before all tests are run.""" | 72 """Installs the test package once before all tests are run.""" |
| 73 pass | 73 pass |
| 74 | 74 |
| 75 def PushDataDeps(self): | |
| 76 """Push all data deps to device once before all tests are run.""" | |
| 77 pass | |
| 78 | |
| 79 def SetUp(self): | 75 def SetUp(self): |
| 80 """Run once before all tests are run.""" | 76 """Run once before all tests are run.""" |
| 81 self.InstallTestPackage() | 77 self.InstallTestPackage() |
| 82 push_size_before = self.device.old_interface.GetPushSizeInfo() | |
| 83 if self._push_deps: | |
| 84 logging.warning('Pushing data files to device.') | |
| 85 self.PushDataDeps() | |
| 86 push_size_after = self.device.old_interface.GetPushSizeInfo() | |
| 87 logging.warning( | |
| 88 'Total data: %0.3fMB' % | |
| 89 ((push_size_after[0] - push_size_before[0]) / float(2 ** 20))) | |
| 90 logging.warning( | |
| 91 'Total data transferred: %0.3fMB' % | |
| 92 ((push_size_after[1] - push_size_before[1]) / float(2 ** 20))) | |
| 93 else: | |
| 94 logging.warning('Skipping pushing data to device.') | |
| 95 | 78 |
| 96 def TearDown(self): | 79 def TearDown(self): |
| 97 """Run once after all tests are run.""" | 80 """Run once after all tests are run.""" |
| 98 self.ShutdownHelperToolsForTestSuite() | 81 self.ShutdownHelperToolsForTestSuite() |
| 99 if self._cleanup_test_files: | 82 if self._cleanup_test_files: |
| 100 self.device.old_interface.RemovePushedFiles() | 83 self.device.old_interface.RemovePushedFiles() |
| 101 | 84 |
| 102 def LaunchTestHttpServer(self, document_root, port=None, | 85 def LaunchTestHttpServer(self, document_root, port=None, |
| 103 extra_config_contents=None): | 86 extra_config_contents=None): |
| 104 """Launches an HTTP server to serve HTTP tests. | 87 """Launches an HTTP server to serve HTTP tests. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 break | 175 break |
| 193 else: | 176 else: |
| 194 error_msgs.append(error_msg) | 177 error_msgs.append(error_msg) |
| 195 self._spawning_server.Stop() | 178 self._spawning_server.Stop() |
| 196 # Wait for 2 seconds then restart. | 179 # Wait for 2 seconds then restart. |
| 197 time.sleep(2) | 180 time.sleep(2) |
| 198 if not server_ready: | 181 if not server_ready: |
| 199 logging.error(';'.join(error_msgs)) | 182 logging.error(';'.join(error_msgs)) |
| 200 raise Exception('Can not start the test spawner server.') | 183 raise Exception('Can not start the test spawner server.') |
| 201 self._PushTestServerPortInfoToDevice() | 184 self._PushTestServerPortInfoToDevice() |
| OLD | NEW |