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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 logging.warning( | 104 logging.warning( |
105 'Total data transferred: %0.3fMB' % | 105 'Total data transferred: %0.3fMB' % |
106 ((push_size_after[1] - push_size_before[1]) / float(2 ** 20))) | 106 ((push_size_after[1] - push_size_before[1]) / float(2 ** 20))) |
107 else: | 107 else: |
108 logging.warning('Skipping pushing data to device.') | 108 logging.warning('Skipping pushing data to device.') |
109 | 109 |
110 def TearDown(self): | 110 def TearDown(self): |
111 """Run once after all tests are run.""" | 111 """Run once after all tests are run.""" |
112 self.ShutdownHelperToolsForTestSuite() | 112 self.ShutdownHelperToolsForTestSuite() |
113 | 113 |
114 def CopyTestData(self, test_data_paths, dest_dir): | |
115 """Copies |test_data_paths| list of files/directories to |dest_dir|. | |
116 | |
117 Args: | |
118 test_data_paths: A list of files or directories relative to |dest_dir| | |
119 which should be copied to the device. The paths must exist in | |
120 |DIR_SOURCE_ROOT|. | |
121 dest_dir: Absolute path to copy to on the device. | |
122 """ | |
123 for p in test_data_paths: | |
124 self.adb.PushIfNeeded( | |
125 os.path.join(constants.DIR_SOURCE_ROOT, p), | |
126 os.path.join(dest_dir, p)) | |
127 | |
128 def LaunchTestHttpServer(self, document_root, port=None, | 114 def LaunchTestHttpServer(self, document_root, port=None, |
129 extra_config_contents=None): | 115 extra_config_contents=None): |
130 """Launches an HTTP server to serve HTTP tests. | 116 """Launches an HTTP server to serve HTTP tests. |
131 | 117 |
132 Args: | 118 Args: |
133 document_root: Document root of the HTTP server. | 119 document_root: Document root of the HTTP server. |
134 port: port on which we want to the http server bind. | 120 port: port on which we want to the http server bind. |
135 extra_config_contents: Extra config contents for the HTTP server. | 121 extra_config_contents: Extra config contents for the HTTP server. |
136 """ | 122 """ |
137 self._http_server = lighttpd_server.LighttpdServer( | 123 self._http_server = lighttpd_server.LighttpdServer( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 break | 209 break |
224 else: | 210 else: |
225 error_msgs.append(error_msg) | 211 error_msgs.append(error_msg) |
226 self._spawning_server.Stop() | 212 self._spawning_server.Stop() |
227 # Wait for 2 seconds then restart. | 213 # Wait for 2 seconds then restart. |
228 time.sleep(2) | 214 time.sleep(2) |
229 if not server_ready: | 215 if not server_ready: |
230 logging.error(';'.join(error_msgs)) | 216 logging.error(';'.join(error_msgs)) |
231 raise Exception('Can not start the test spawner server.') | 217 raise Exception('Can not start the test spawner server.') |
232 self._PushTestServerPortInfoToDevice() | 218 self._PushTestServerPortInfoToDevice() |
OLD | NEW |