OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Run specific test on specific environment.""" | 5 """Run specific test on specific environment.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 'robotium', test_with_deps.name) | 177 'robotium', test_with_deps.name) |
178 else: | 178 else: |
179 self._test_id = self._UploadTestToDevice('robotium', test_path) | 179 self._test_id = self._UploadTestToDevice('robotium', test_path) |
180 | 180 |
181 logging.info('Setting config: %s' % config) | 181 logging.info('Setting config: %s' % config) |
182 self._SetTestConfig('robotium', config) | 182 self._SetTestConfig('robotium', config) |
183 | 183 |
184 def _UploadAppToDevice(self, app_path): | 184 def _UploadAppToDevice(self, app_path): |
185 """Upload app to device.""" | 185 """Upload app to device.""" |
186 logging.info('Uploading %s to remote service.', app_path) | 186 logging.info('Uploading %s to remote service.', app_path) |
187 apk_name = os.path.basename(app_path) | |
188 with open(app_path, 'rb') as apk_src: | 187 with open(app_path, 'rb') as apk_src: |
189 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, | 188 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, |
190 logging.WARNING): | 189 logging.WARNING): |
191 upload_results = appurify_sanitized.api.apps_upload( | 190 upload_results = appurify_sanitized.api.apps_upload( |
192 self._env.token, apk_src, 'raw', name=apk_name) | 191 self._env.token, apk_src, 'raw', name=self._test_instance.suite) |
193 remote_device_helper.TestHttpResponse( | 192 remote_device_helper.TestHttpResponse( |
194 upload_results, 'Unable to upload %s.' % app_path) | 193 upload_results, 'Unable to upload %s.' % app_path) |
195 return upload_results.json()['response']['app_id'] | 194 return upload_results.json()['response']['app_id'] |
196 | 195 |
197 def _UploadTestToDevice(self, test_type, test_path): | 196 def _UploadTestToDevice(self, test_type, test_path): |
198 """Upload test to device | 197 """Upload test to device |
199 Args: | 198 Args: |
200 test_type: Type of test that is being uploaded. Ex. uirobot, gtest.. | 199 test_type: Type of test that is being uploaded. Ex. uirobot, gtest.. |
201 """ | 200 """ |
202 logging.info('Uploading %s to remote service.' % test_path) | 201 logging.info('Uploading %s to remote service.' % test_path) |
(...skipping 17 matching lines...) Expand all Loading... |
220 config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems()) | 219 config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems()) |
221 config.write(''.join('%s\n' % l for l in config_data)) | 220 config.write(''.join('%s\n' % l for l in config_data)) |
222 config.flush() | 221 config.flush() |
223 config.seek(0) | 222 config.seek(0) |
224 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, | 223 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, |
225 logging.WARNING): | 224 logging.WARNING): |
226 config_response = appurify_sanitized.api.config_upload( | 225 config_response = appurify_sanitized.api.config_upload( |
227 self._env.token, config, self._test_id) | 226 self._env.token, config, self._test_id) |
228 remote_device_helper.TestHttpResponse( | 227 remote_device_helper.TestHttpResponse( |
229 config_response, 'Unable to upload test config.') | 228 config_response, 'Unable to upload test config.') |
OLD | NEW |