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 = ( | |
samuong
2016/06/28 23:23:40
nit: should probably call this "GET_NETWORK_CONNEC
roisinmcl
2016/06/29 17:55:13
This was mostly a placeholder for Eva's code, so I
| |
150 _Method.GET, '/session/:sessionId/network_connection') | |
151 SET_NETWORK_CONNECTION = ( | |
152 _Method.POST, '/session/:sessionId/network_connection') | |
149 | 153 |
150 # Custom Chrome commands. | 154 # Custom Chrome commands. |
151 IS_LOADING = (_Method.GET, '/session/:sessionId/is_loading') | 155 IS_LOADING = (_Method.GET, '/session/:sessionId/is_loading') |
152 TOUCH_PINCH = (_Method.POST, '/session/:sessionId/touch/pinch') | 156 TOUCH_PINCH = (_Method.POST, '/session/:sessionId/touch/pinch') |
153 | 157 |
154 | 158 |
155 class CommandExecutor(object): | 159 class CommandExecutor(object): |
156 def __init__(self, server_url): | 160 def __init__(self, server_url): |
157 self._server_url = server_url | 161 self._server_url = server_url |
158 port = int(server_url.split(':')[2].split('/')[0]) | 162 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) | 179 self._http_client.request(command[0], '/'.join(substituted_parts), body) |
176 response = self._http_client.getresponse() | 180 response = self._http_client.getresponse() |
177 | 181 |
178 if response.status == 303: | 182 if response.status == 303: |
179 self._http_client.request(_Method.GET, response.getheader('location')) | 183 self._http_client.request(_Method.GET, response.getheader('location')) |
180 response = self._http_client.getresponse() | 184 response = self._http_client.getresponse() |
181 if response.status != 200: | 185 if response.status != 200: |
182 raise RuntimeError('Server returned error: ' + response.reason) | 186 raise RuntimeError('Server returned error: ' + response.reason) |
183 | 187 |
184 return json.loads(response.read()) | 188 return json.loads(response.read()) |
OLD | NEW |