| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """A Telemetry page_action that performs the "drag" action on pages. | 5 """A Telemetry page_action that performs the "drag" action on pages. |
| 6 | 6 |
| 7 Action parameters are: | 7 Action parameters are: |
| 8 - selector: If no selector is defined then the action attempts to drag the | 8 - selector: If no selector is defined then the action attempts to drag the |
| 9 document element on the page. | 9 document element on the page. |
| 10 - element_function: CSS selector used to evaluate callback when test completes | 10 - element_function: CSS selector used to evaluate callback when test completes |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 self._element_function = element_function | 36 self._element_function = element_function |
| 37 self._left_start_ratio = left_start_ratio | 37 self._left_start_ratio = left_start_ratio |
| 38 self._top_start_ratio = top_start_ratio | 38 self._top_start_ratio = top_start_ratio |
| 39 self._left_end_ratio = left_end_ratio | 39 self._left_end_ratio = left_end_ratio |
| 40 self._top_end_ratio = top_end_ratio | 40 self._top_end_ratio = top_end_ratio |
| 41 self._speed = speed_in_pixels_per_second | 41 self._speed = speed_in_pixels_per_second |
| 42 self._use_touch = use_touch | 42 self._use_touch = use_touch |
| 43 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' % | 43 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' % |
| 44 synthetic_gesture_source) | 44 synthetic_gesture_source) |
| 45 | 45 |
| 46 def SimulatesUserInput(self): |
| 47 return True |
| 48 |
| 46 def WillRunAction(self, tab): | 49 def WillRunAction(self, tab): |
| 47 utils.InjectJavaScript(tab, 'gesture_common.js') | 50 utils.InjectJavaScript(tab, 'gesture_common.js') |
| 48 utils.InjectJavaScript(tab, 'drag.js') | 51 utils.InjectJavaScript(tab, 'drag.js') |
| 49 | 52 |
| 50 # Fail if browser doesn't support synthetic drag gestures. | 53 # Fail if browser doesn't support synthetic drag gestures. |
| 51 if not tab.EvaluateJavaScript('window.__DragAction_SupportedByBrowser()'): | 54 if not tab.EvaluateJavaScript('window.__DragAction_SupportedByBrowser()'): |
| 52 raise page_action.PageActionNotSupported( | 55 raise page_action.PageActionNotSupported( |
| 53 'Synthetic drag not supported for this browser') | 56 'Synthetic drag not supported for this browser') |
| 54 | 57 |
| 55 # Fail if this action requires touch and we can't send touch events. | 58 # Fail if this action requires touch and we can't send touch events. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 left_start_ratio=self._left_start_ratio, | 100 left_start_ratio=self._left_start_ratio, |
| 98 top_start_ratio=self._top_start_ratio, | 101 top_start_ratio=self._top_start_ratio, |
| 99 left_end_ratio=self._left_end_ratio, | 102 left_end_ratio=self._left_end_ratio, |
| 100 top_end_ratio=self._top_end_ratio, | 103 top_end_ratio=self._top_end_ratio, |
| 101 speed=self._speed, | 104 speed=self._speed, |
| 102 gesture_source_type=gesture_source_type) | 105 gesture_source_type=gesture_source_type) |
| 103 page_action.EvaluateCallbackWithElement( | 106 page_action.EvaluateCallbackWithElement( |
| 104 tab, code, selector=self._selector, text=self._text, | 107 tab, code, selector=self._selector, text=self._text, |
| 105 element_function=self._element_function) | 108 element_function=self._element_function) |
| 106 tab.WaitForJavaScriptCondition('window.__dragActionDone', timeout=60) | 109 tab.WaitForJavaScriptCondition('window.__dragActionDone', timeout=60) |
| OLD | NEW |