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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 def TearDown(self): | 91 def TearDown(self): |
92 """Run once after all tests are run.""" | 92 """Run once after all tests are run.""" |
93 self.ShutdownHelperToolsForTestSuite() | 93 self.ShutdownHelperToolsForTestSuite() |
94 | 94 |
95 def CopyTestData(self, test_data_paths, dest_dir): | 95 def CopyTestData(self, test_data_paths, dest_dir): |
96 """Copies |test_data_paths| list of files/directories to |dest_dir|. | 96 """Copies |test_data_paths| list of files/directories to |dest_dir|. |
97 | 97 |
98 Args: | 98 Args: |
99 test_data_paths: A list of files or directories relative to |dest_dir| | 99 test_data_paths: A list of files or directories relative to |dest_dir| |
100 which should be copied to the device. The paths must exist in | 100 which should be copied to the device. The paths must exist in |
101 |CHROME_DIR|. | 101 |DIR_SOURCE_ROOT|. |
102 dest_dir: Absolute path to copy to on the device. | 102 dest_dir: Absolute path to copy to on the device. |
103 """ | 103 """ |
104 for p in test_data_paths: | 104 for p in test_data_paths: |
105 self.adb.PushIfNeeded( | 105 self.adb.PushIfNeeded( |
106 os.path.join(constants.CHROME_DIR, p), | 106 os.path.join(constants.DIR_SOURCE_ROOT, p), |
107 os.path.join(dest_dir, p)) | 107 os.path.join(dest_dir, p)) |
108 | 108 |
109 def LaunchTestHttpServer(self, document_root, port=None, | 109 def LaunchTestHttpServer(self, document_root, port=None, |
110 extra_config_contents=None): | 110 extra_config_contents=None): |
111 """Launches an HTTP server to serve HTTP tests. | 111 """Launches an HTTP server to serve HTTP tests. |
112 | 112 |
113 Args: | 113 Args: |
114 document_root: Document root of the HTTP server. | 114 document_root: Document root of the HTTP server. |
115 port: port on which we want to the http server bind. | 115 port: port on which we want to the http server bind. |
116 extra_config_contents: Extra config contents for the HTTP server. | 116 extra_config_contents: Extra config contents for the HTTP server. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 break | 204 break |
205 else: | 205 else: |
206 error_msgs.append(error_msg) | 206 error_msgs.append(error_msg) |
207 self._spawning_server.Stop() | 207 self._spawning_server.Stop() |
208 # Wait for 2 seconds then restart. | 208 # Wait for 2 seconds then restart. |
209 time.sleep(2) | 209 time.sleep(2) |
210 if not server_ready: | 210 if not server_ready: |
211 logging.error(';'.join(error_msgs)) | 211 logging.error(';'.join(error_msgs)) |
212 raise Exception('Can not start the test spawner server.') | 212 raise Exception('Can not start the test spawner server.') |
213 self._PushTestServerPortInfoToDevice() | 213 self._PushTestServerPortInfoToDevice() |
OLD | NEW |