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

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

Issue 840393003: Add support for ios_uirobot (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 """Environment setup and teardown for remote devices.""" 5 """Environment setup and teardown for remote devices."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import random 9 import random
10 import sys 10 import sys
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 self._api_port = args.api_port 58 self._api_port = args.api_port
59 59
60 self._access_token = '' 60 self._access_token = ''
61 self._results_path = args.results_path 61 self._results_path = args.results_path
62 self._remote_device = args.remote_device 62 self._remote_device = args.remote_device
63 self._remote_device_os = args.remote_device_os 63 self._remote_device_os = args.remote_device_os
64 self._runner_package = args.runner_package 64 self._runner_package = args.runner_package
65 self._runner_type = args.runner_type 65 self._runner_type = args.runner_type
66 self._device = '' 66 self._device = ''
67 self._verbose_count = args.verbose_count 67 self._verbose_count = args.verbose_count
68 self._device_type = args.device_type
68 self._timeouts = { 69 self._timeouts = {
69 'queueing': 60 * 10, 70 'queueing': 60 * 10,
70 'installing': 60 * 10, 71 'installing': 60 * 10,
71 'in-progress': 60 * 30, 72 'in-progress': 60 * 30,
72 'unknown': 60 * 5 73 'unknown': 60 * 5
73 } 74 }
74 75
75 if not args.trigger and not args.collect: 76 if not args.trigger and not args.collect:
76 self._trigger = True 77 self._trigger = True
77 self._collect = True 78 self._collect = True
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 """Select which device to use.""" 141 """Select which device to use."""
141 logging.info('Finding device to run tests on.') 142 logging.info('Finding device to run tests on.')
142 with appurify_sanitized.SanitizeLogging(self._verbose_count, 143 with appurify_sanitized.SanitizeLogging(self._verbose_count,
143 logging.WARNING): 144 logging.WARNING):
144 dev_list_res = appurify_sanitized.api.devices_list(self._access_token) 145 dev_list_res = appurify_sanitized.api.devices_list(self._access_token)
145 remote_device_helper.TestHttpResponse(dev_list_res, 146 remote_device_helper.TestHttpResponse(dev_list_res,
146 'Unable to generate access token.') 147 'Unable to generate access token.')
147 device_list = dev_list_res.json()['response'] 148 device_list = dev_list_res.json()['response']
148 random.shuffle(device_list) 149 random.shuffle(device_list)
149 for device in device_list: 150 for device in device_list:
150 if device['os_name'] != 'Android': 151 if device['os_name'] != self._device_type:
151 continue 152 continue
152 if self._remote_device and device['name'] != self._remote_device: 153 if self._remote_device and device['name'] != self._remote_device:
153 continue 154 continue
154 if (self._remote_device_os 155 if (self._remote_device_os
155 and device['os_version'] != self._remote_device_os): 156 and device['os_version'] != self._remote_device_os):
156 continue 157 continue
157 if ((self._remote_device and self._remote_device_os) 158 if ((self._remote_device and self._remote_device_os)
158 or device['available_devices_count']): 159 or device['available_devices_count']):
159 logging.info('Found device: %s %s', 160 logging.info('Found device: %s %s',
160 device['name'], device['os_version']) 161 device['name'], device['os_version'])
161 return device 162 return device
162 self._NoDeviceFound(device_list) 163 self._NoDeviceFound(device_list)
163 164
164 def _PrintAvailableDevices(self, device_list): 165 def _PrintAvailableDevices(self, device_list):
165 def compare_devices(a,b): 166 def compare_devices(a,b):
166 for key in ('os_version', 'name'): 167 for key in ('os_version', 'name'):
167 c = cmp(a[key], b[key]) 168 c = cmp(a[key], b[key])
168 if c: 169 if c:
169 return c 170 return c
170 return 0 171 return 0
171 172
172 logging.critical('Available Android Devices:') 173 logging.critical('Available %s Devices:', self._device_type)
173 android_devices = (d for d in device_list if d['os_name'] == 'Android') 174 devices = (d for d in device_list if d['os_name'] == self._device_type)
174 for d in sorted(android_devices, compare_devices): 175 for d in sorted(devices, compare_devices):
175 logging.critical(' %s %s', d['os_version'].ljust(7), d['name']) 176 logging.critical(' %s %s', d['os_version'].ljust(7), d['name'])
176 177
177 def _NoDeviceFound(self, device_list): 178 def _NoDeviceFound(self, device_list):
178 self._PrintAvailableDevices(device_list) 179 self._PrintAvailableDevices(device_list)
179 raise remote_device_helper.RemoteDeviceError('No device found.') 180 raise remote_device_helper.RemoteDeviceError('No device found.')
180 181
181 @property 182 @property
182 def collect(self): 183 def collect(self):
183 return self._collect 184 return self._collect
184 185
(...skipping 26 matching lines...) Expand all
211 def token(self): 212 def token(self):
212 return self._access_token 213 return self._access_token
213 214
214 @property 215 @property
215 def trigger(self): 216 def trigger(self):
216 return self._trigger 217 return self._trigger
217 218
218 @property 219 @property
219 def verbose_count(self): 220 def verbose_count(self):
220 return self._verbose_count 221 return self._verbose_count
222
223 @property
224 def device_type(self):
225 return self._device_type
OLDNEW
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/pylib/remote/device/remote_device_uirobot_test_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698