| 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 contextlib | 7 import contextlib |
| 8 import httplib | 8 import httplib |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 pass | 86 pass |
| 87 | 87 |
| 88 def PushDataDeps(self): | 88 def PushDataDeps(self): |
| 89 """Push all data deps to device once before all tests are run.""" | 89 """Push all data deps to device once before all tests are run.""" |
| 90 pass | 90 pass |
| 91 | 91 |
| 92 def SetUp(self): | 92 def SetUp(self): |
| 93 """Run once before all tests are run.""" | 93 """Run once before all tests are run.""" |
| 94 Forwarder.KillDevice(self.adb, self.tool) | 94 Forwarder.KillDevice(self.adb, self.tool) |
| 95 self.InstallTestPackage() | 95 self.InstallTestPackage() |
| 96 push_size_before = self.adb.GetPushSizeInfo() |
| 96 if self._push_deps: | 97 if self._push_deps: |
| 97 logging.info('Pushing data deps to device.') | 98 logging.warning('Pushing data files to device.') |
| 98 self.PushDataDeps() | 99 self.PushDataDeps() |
| 100 push_size_after = self.adb.GetPushSizeInfo() |
| 101 logging.warning( |
| 102 'Total data: %0.3fMB' % |
| 103 ((push_size_after[0] - push_size_before[0]) / float(2 ** 20))) |
| 104 logging.warning( |
| 105 'Total data transferred: %0.3fMB' % |
| 106 ((push_size_after[1] - push_size_before[1]) / float(2 ** 20))) |
| 99 else: | 107 else: |
| 100 logging.warning('Skipping pushing data deps to device.') | 108 logging.warning('Skipping pushing data to device.') |
| 101 | 109 |
| 102 def TearDown(self): | 110 def TearDown(self): |
| 103 """Run once after all tests are run.""" | 111 """Run once after all tests are run.""" |
| 104 self.ShutdownHelperToolsForTestSuite() | 112 self.ShutdownHelperToolsForTestSuite() |
| 105 | 113 |
| 106 def CopyTestData(self, test_data_paths, dest_dir): | 114 def CopyTestData(self, test_data_paths, dest_dir): |
| 107 """Copies |test_data_paths| list of files/directories to |dest_dir|. | 115 """Copies |test_data_paths| list of files/directories to |dest_dir|. |
| 108 | 116 |
| 109 Args: | 117 Args: |
| 110 test_data_paths: A list of files or directories relative to |dest_dir| | 118 test_data_paths: A list of files or directories relative to |dest_dir| |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 break | 223 break |
| 216 else: | 224 else: |
| 217 error_msgs.append(error_msg) | 225 error_msgs.append(error_msg) |
| 218 self._spawning_server.Stop() | 226 self._spawning_server.Stop() |
| 219 # Wait for 2 seconds then restart. | 227 # Wait for 2 seconds then restart. |
| 220 time.sleep(2) | 228 time.sleep(2) |
| 221 if not server_ready: | 229 if not server_ready: |
| 222 logging.error(';'.join(error_msgs)) | 230 logging.error(';'.join(error_msgs)) |
| 223 raise Exception('Can not start the test spawner server.') | 231 raise Exception('Can not start the test spawner server.') |
| 224 self._PushTestServerPortInfoToDevice() | 232 self._PushTestServerPortInfoToDevice() |
| OLD | NEW |