| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 TOUCH_LONG_PRESS = (_Method.POST, '/session/:sessionId/touch/longclick') | 145 TOUCH_LONG_PRESS = (_Method.POST, '/session/:sessionId/touch/longclick') |
| 146 TOUCH_FLICK = (_Method.POST, '/session/:sessionId/touch/flick') | 146 TOUCH_FLICK = (_Method.POST, '/session/:sessionId/touch/flick') |
| 147 GET_LOG = (_Method.POST, '/session/:sessionId/log') | 147 GET_LOG = (_Method.POST, '/session/:sessionId/log') |
| 148 GET_AVAILABLE_LOG_TYPES = (_Method.GET, '/session/:sessionId/log/types') | 148 GET_AVAILABLE_LOG_TYPES = (_Method.GET, '/session/:sessionId/log/types') |
| 149 IS_AUTO_REPORTING = (_Method.GET, '/session/:sessionId/autoreport') | 149 IS_AUTO_REPORTING = (_Method.GET, '/session/:sessionId/autoreport') |
| 150 SET_AUTO_REPORTING = (_Method.POST, '/session/:sessionId/autoreport') | 150 SET_AUTO_REPORTING = (_Method.POST, '/session/:sessionId/autoreport') |
| 151 GET_SESSION_LOGS = (_Method.POST, '/logs') | 151 GET_SESSION_LOGS = (_Method.POST, '/logs') |
| 152 STATUS = (_Method.GET, '/status') | 152 STATUS = (_Method.GET, '/status') |
| 153 SET_NETWORK_CONNECTION = ( | 153 SET_NETWORK_CONNECTION = ( |
| 154 _Method.POST, '/session/:sessionId/network_connection') | 154 _Method.POST, '/session/:sessionId/network_connection') |
| 155 SEND_COMMAND = ( |
| 156 _Method.POST, '/session/:sessionId/chromium/send_command') |
| 157 SEND_COMMAND_AND_GET_RESULT = ( |
| 158 _Method.POST, '/session/:sessionId/chromium/send_command_and_get_result') |
| 155 | 159 |
| 156 # Custom Chrome commands. | 160 # Custom Chrome commands. |
| 157 IS_LOADING = (_Method.GET, '/session/:sessionId/is_loading') | 161 IS_LOADING = (_Method.GET, '/session/:sessionId/is_loading') |
| 158 TOUCH_PINCH = (_Method.POST, '/session/:sessionId/touch/pinch') | 162 TOUCH_PINCH = (_Method.POST, '/session/:sessionId/touch/pinch') |
| 159 | 163 |
| 160 | 164 |
| 161 class CommandExecutor(object): | 165 class CommandExecutor(object): |
| 162 def __init__(self, server_url): | 166 def __init__(self, server_url): |
| 163 self._server_url = server_url | 167 self._server_url = server_url |
| 164 port = int(server_url.split(':')[2].split('/')[0]) | 168 port = int(server_url.split(':')[2].split('/')[0]) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 182 response = self._http_client.getresponse() | 186 response = self._http_client.getresponse() |
| 183 | 187 |
| 184 if response.status == 303: | 188 if response.status == 303: |
| 185 self._http_client.request(_Method.GET, response.getheader('location')) | 189 self._http_client.request(_Method.GET, response.getheader('location')) |
| 186 response = self._http_client.getresponse() | 190 response = self._http_client.getresponse() |
| 187 result = json.loads(response.read()) | 191 result = json.loads(response.read()) |
| 188 if response.status != 200 and 'error' not in result: | 192 if response.status != 200 and 'error' not in result: |
| 189 raise RuntimeError('Server returned error: ' + response.reason) | 193 raise RuntimeError('Server returned error: ' + response.reason) |
| 190 | 194 |
| 191 return result | 195 return result |
| OLD | NEW |