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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 TOUCH_SINGLE_TAP = (_Method.POST, '/session/:sessionId/touch/click') | 126 TOUCH_SINGLE_TAP = (_Method.POST, '/session/:sessionId/touch/click') |
127 TOUCH_DOWN = (_Method.POST, '/session/:sessionId/touch/down') | 127 TOUCH_DOWN = (_Method.POST, '/session/:sessionId/touch/down') |
128 TOUCH_UP = (_Method.POST, '/session/:sessionId/touch/up') | 128 TOUCH_UP = (_Method.POST, '/session/:sessionId/touch/up') |
129 TOUCH_MOVE = (_Method.POST, '/session/:sessionId/touch/move') | 129 TOUCH_MOVE = (_Method.POST, '/session/:sessionId/touch/move') |
130 TOUCH_SCROLL = (_Method.POST, '/session/:sessionId/touch/scroll') | 130 TOUCH_SCROLL = (_Method.POST, '/session/:sessionId/touch/scroll') |
131 TOUCH_DOUBLE_TAP = (_Method.POST, '/session/:sessionId/touch/doubleclick') | 131 TOUCH_DOUBLE_TAP = (_Method.POST, '/session/:sessionId/touch/doubleclick') |
132 TOUCH_LONG_PRESS = (_Method.POST, '/session/:sessionId/touch/longclick') | 132 TOUCH_LONG_PRESS = (_Method.POST, '/session/:sessionId/touch/longclick') |
133 TOUCH_FLICK = (_Method.POST, '/session/:sessionId/touch/flick') | 133 TOUCH_FLICK = (_Method.POST, '/session/:sessionId/touch/flick') |
134 GET_LOG = (_Method.POST, '/session/:sessionId/log') | 134 GET_LOG = (_Method.POST, '/session/:sessionId/log') |
135 GET_AVAILABLE_LOG_TYPES = (_Method.GET, '/session/:sessionId/log/types') | 135 GET_AVAILABLE_LOG_TYPES = (_Method.GET, '/session/:sessionId/log/types') |
| 136 IS_AUTO_REPORTING_ENABLED = (_Method.GET, '/session/:sessionId/autoreport') |
| 137 SET_AUTO_REPORTING_ENABLED = (_Method.POST, '/session/:sessionId/autoreport') |
136 GET_SESSION_LOGS = (_Method.POST, '/logs') | 138 GET_SESSION_LOGS = (_Method.POST, '/logs') |
137 STATUS = (_Method.GET, '/status') | 139 STATUS = (_Method.GET, '/status') |
138 | 140 |
139 # Custom Chrome commands. | 141 # Custom Chrome commands. |
140 IS_LOADING = (_Method.GET, '/session/:sessionId/is_loading') | 142 IS_LOADING = (_Method.GET, '/session/:sessionId/is_loading') |
141 | 143 |
142 | 144 |
143 class CommandExecutor(object): | 145 class CommandExecutor(object): |
144 def __init__(self, server_url): | 146 def __init__(self, server_url): |
145 self._server_url = server_url | 147 self._server_url = server_url |
(...skipping 17 matching lines...) Expand all Loading... |
163 self._http_client.request(command[0], '/'.join(substituted_parts), body) | 165 self._http_client.request(command[0], '/'.join(substituted_parts), body) |
164 response = self._http_client.getresponse() | 166 response = self._http_client.getresponse() |
165 | 167 |
166 if response.status == 303: | 168 if response.status == 303: |
167 self._http_client.request(_Method.GET, response.getheader('location')) | 169 self._http_client.request(_Method.GET, response.getheader('location')) |
168 response = self._http_client.getresponse() | 170 response = self._http_client.getresponse() |
169 if response.status != 200: | 171 if response.status != 200: |
170 raise RuntimeError('Server returned error: ' + response.reason) | 172 raise RuntimeError('Server returned error: ' + response.reason) |
171 | 173 |
172 return json.loads(response.read()) | 174 return json.loads(response.read()) |
OLD | NEW |