Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: build/android/pylib/remote/device/remote_device_test_run.py

Issue 833403002: [Android] Create a dummy app to upload to Appurify for gtests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add gn Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/remote/device/remote_device_gtest_run.py ('k') | build/apk_test.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 """ 131 """
132 132
133 test_check_res = appurify_sanitized.api.tests_check_result(self._env.token, 133 test_check_res = appurify_sanitized.api.tests_check_result(self._env.token,
134 test_run_id) 134 test_run_id)
135 remote_device_helper.TestHttpResponse(test_check_res, 135 remote_device_helper.TestHttpResponse(test_check_res,
136 'Unable to get test status.') 136 'Unable to get test status.')
137 self._results = test_check_res.json()['response'] 137 self._results = test_check_res.json()['response']
138 logging.info('Test status: %s' % self._results['detailed_status']) 138 logging.info('Test status: %s' % self._results['detailed_status'])
139 return self._results['status'] 139 return self._results['status']
140 140
141 def _UploadAppToDevice(self, apk_path): 141 def _AmInstrumentTestSetup(self, app_path, test_path, runner_package):
142 config = {'runner': runner_package}
143
144 self._app_id = self._UploadAppToDevice(app_path)
145 self._test_id = self._UploadTestToDevice('robotium', test_path)
146
147 logging.info('Setting config: %s' % config)
148 self._SetTestConfig('robotium', config)
149
150 def _UploadAppToDevice(self, app_path):
142 """Upload app to device.""" 151 """Upload app to device."""
143 logging.info('Upload %s to remote service.' % apk_path) 152 logging.info('Upload %s to remote service.' % app_path)
144 apk_name = os.path.basename(apk_path) 153 apk_name = os.path.basename(app_path)
145 with open(apk_path, 'rb') as apk_src: 154 with open(app_path, 'rb') as apk_src:
146 upload_results = appurify_sanitized.api.apps_upload(self._env.token, 155 upload_results = appurify_sanitized.api.apps_upload(
147 apk_src, 'raw', name=apk_name) 156 self._env.token, apk_src, 'raw', name=apk_name)
148 remote_device_helper.TestHttpResponse( 157 remote_device_helper.TestHttpResponse(
149 upload_results, 'Unable to upload %s.' %(apk_path)) 158 upload_results, 'Unable to upload %s.' % app_path)
150 return upload_results.json()['response']['app_id'] 159 return upload_results.json()['response']['app_id']
151 160
152 def _UploadTestToDevice(self, test_type): 161 def _UploadTestToDevice(self, test_type, test_path):
153 """Upload test to device 162 """Upload test to device
154 Args: 163 Args:
155 test_type: Type of test that is being uploaded. Ex. uirobot, gtest.. 164 test_type: Type of test that is being uploaded. Ex. uirobot, gtest..
156 """ 165 """
157 logging.info('Uploading %s to remote service.' % self._test_instance.apk) 166 logging.info('Uploading %s to remote service.' % test_path)
158 with open(self._test_instance.apk, 'rb') as test_src: 167 with open(test_path, 'rb') as test_src:
159 upload_results = appurify_sanitized.api.tests_upload( 168 upload_results = appurify_sanitized.api.tests_upload(
160 self._env.token, test_src, 'raw', test_type, app_id=self._app_id) 169 self._env.token, test_src, 'raw', test_type)
161 remote_device_helper.TestHttpResponse(upload_results, 170 remote_device_helper.TestHttpResponse(upload_results,
162 'Unable to upload %s.' %(self._test_instance.apk)) 171 'Unable to upload %s.' % test_path)
163 return upload_results.json()['response']['test_id'] 172 return upload_results.json()['response']['test_id']
164 173
165 def _SetTestConfig(self, runner_type, body): 174 def _SetTestConfig(self, runner_type, body):
166 """Generates and uploads config file for test. 175 """Generates and uploads config file for test.
167 Args: 176 Args:
168 extras: Extra arguments to set in the config file. 177 extras: Extra arguments to set in the config file.
169 """ 178 """
170 logging.info('Generating config file for test.') 179 logging.info('Generating config file for test.')
171 with tempfile.TemporaryFile() as config: 180 with tempfile.TemporaryFile() as config:
172 config_data = ['[appurify]', '[%s]' % runner_type] 181 config_data = ['[appurify]', '[%s]' % runner_type]
173 config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems()) 182 config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems())
174 config.write(''.join('%s\n' % l for l in config_data)) 183 config.write(''.join('%s\n' % l for l in config_data))
175 config.flush() 184 config.flush()
176 config.seek(0) 185 config.seek(0)
177 config_response = appurify_sanitized.api.config_upload(self._env.token, 186 config_response = appurify_sanitized.api.config_upload(
178 config, self._test_id) 187 self._env.token, config, self._test_id)
179 remote_device_helper.TestHttpResponse(config_response, 188 remote_device_helper.TestHttpResponse(
180 'Unable to upload test config.') 189 config_response, 'Unable to upload test config.')
OLDNEW
« no previous file with comments | « build/android/pylib/remote/device/remote_device_gtest_run.py ('k') | build/apk_test.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698