OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import httplib | 5 import httplib |
6 import json | 6 import json |
7 | 7 |
8 | 8 |
9 class _Method(object): | 9 class _Method(object): |
10 GET = 'GET' | 10 GET = 'GET' |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 TOUCH_SCROLL = (_Method.POST, '/session/:sessionId/touch/scroll') | 139 TOUCH_SCROLL = (_Method.POST, '/session/:sessionId/touch/scroll') |
140 TOUCH_DOUBLE_TAP = (_Method.POST, '/session/:sessionId/touch/doubleclick') | 140 TOUCH_DOUBLE_TAP = (_Method.POST, '/session/:sessionId/touch/doubleclick') |
141 TOUCH_LONG_PRESS = (_Method.POST, '/session/:sessionId/touch/longclick') | 141 TOUCH_LONG_PRESS = (_Method.POST, '/session/:sessionId/touch/longclick') |
142 TOUCH_FLICK = (_Method.POST, '/session/:sessionId/touch/flick') | 142 TOUCH_FLICK = (_Method.POST, '/session/:sessionId/touch/flick') |
143 GET_LOG = (_Method.POST, '/session/:sessionId/log') | 143 GET_LOG = (_Method.POST, '/session/:sessionId/log') |
144 GET_AVAILABLE_LOG_TYPES = (_Method.GET, '/session/:sessionId/log/types') | 144 GET_AVAILABLE_LOG_TYPES = (_Method.GET, '/session/:sessionId/log/types') |
145 IS_AUTO_REPORTING = (_Method.GET, '/session/:sessionId/autoreport') | 145 IS_AUTO_REPORTING = (_Method.GET, '/session/:sessionId/autoreport') |
146 SET_AUTO_REPORTING = (_Method.POST, '/session/:sessionId/autoreport') | 146 SET_AUTO_REPORTING = (_Method.POST, '/session/:sessionId/autoreport') |
147 GET_SESSION_LOGS = (_Method.POST, '/logs') | 147 GET_SESSION_LOGS = (_Method.POST, '/logs') |
148 STATUS = (_Method.GET, '/status') | 148 STATUS = (_Method.GET, '/status') |
149 GET_EMULATED_NETWORK_CONDITIONS = (_Method.GET, '/session/:sessionId/network_c onnection') | |
samuong
2016/06/14 17:45:59
style nitpick: keep lines to within 80 charws
roisinmcl
2016/06/17 18:13:33
Done.
| |
150 SET_EMULATED_NETWORK_CONDITIONS = (_Method.POST, '/session/:sessionId/network_ connection') | |
151 NETWORK_CONDITIONS_DIFFERENT_WEBVIEWS = (_Method.GET, 'session/:sessionId/netw ork_connection') | |
samuong
2016/06/14 17:45:59
lines 149 and 151 are the same commmand (same http
roisinmcl
2016/06/17 18:13:33
Done.
| |
149 | 152 |
150 # Custom Chrome commands. | 153 # Custom Chrome commands. |
151 IS_LOADING = (_Method.GET, '/session/:sessionId/is_loading') | 154 IS_LOADING = (_Method.GET, '/session/:sessionId/is_loading') |
152 TOUCH_PINCH = (_Method.POST, '/session/:sessionId/touch/pinch') | 155 TOUCH_PINCH = (_Method.POST, '/session/:sessionId/touch/pinch') |
153 | 156 |
154 | 157 |
155 class CommandExecutor(object): | 158 class CommandExecutor(object): |
156 def __init__(self, server_url): | 159 def __init__(self, server_url): |
157 self._server_url = server_url | 160 self._server_url = server_url |
158 port = int(server_url.split(':')[2].split('/')[0]) | 161 port = int(server_url.split(':')[2].split('/')[0]) |
(...skipping 16 matching lines...) Expand all Loading... | |
175 self._http_client.request(command[0], '/'.join(substituted_parts), body) | 178 self._http_client.request(command[0], '/'.join(substituted_parts), body) |
176 response = self._http_client.getresponse() | 179 response = self._http_client.getresponse() |
177 | 180 |
178 if response.status == 303: | 181 if response.status == 303: |
179 self._http_client.request(_Method.GET, response.getheader('location')) | 182 self._http_client.request(_Method.GET, response.getheader('location')) |
180 response = self._http_client.getresponse() | 183 response = self._http_client.getresponse() |
181 if response.status != 200: | 184 if response.status != 200: |
182 raise RuntimeError('Server returned error: ' + response.reason) | 185 raise RuntimeError('Server returned error: ' + response.reason) |
183 | 186 |
184 return json.loads(response.read()) | 187 return json.loads(response.read()) |
OLD | NEW |