| 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 |
| 11 - text: The element with exact text is selected. | 11 - text: The element with exact text is selected. |
| 12 - left_start_ratio: ratio of start point's left coordinate to the element | 12 - left_start_ratio: ratio of start point's left coordinate to the element |
| 13 width. | 13 width. |
| 14 - top_start_ratio: ratio of start point's top coordinate to the element height. | 14 - top_start_ratio: ratio of start point's top coordinate to the element height. |
| 15 - left_end_ratio: ratio of end point's left coordinate to the element width. | 15 - left_end_ratio: ratio of end point's left coordinate to the element width. |
| 16 - left_end_ratio: ratio of end point's top coordinate to the element height. | 16 - left_end_ratio: ratio of end point's top coordinate to the element height. |
| 17 - speed_in_pixels_per_second: speed of the drag gesture in pixels per second. | 17 - speed_in_pixels_per_second: speed of the drag gesture in pixels per second. |
| 18 - use_touch: boolean value to specify if gesture should use touch input or not. | 18 - use_touch: boolean value to specify if gesture should use touch input or not. |
| 19 """ | 19 """ |
| 20 | 20 |
| 21 import os | 21 import os |
| 22 | 22 |
| 23 from telemetry.page.actions import page_action | 23 from telemetry.internal.actions import page_action |
| 24 | 24 |
| 25 | 25 |
| 26 class DragAction(page_action.PageAction): | 26 class DragAction(page_action.PageAction): |
| 27 | 27 |
| 28 def __init__(self, selector=None, text=None, element_function=None, | 28 def __init__(self, selector=None, text=None, element_function=None, |
| 29 left_start_ratio=None, top_start_ratio=None, left_end_ratio=None, | 29 left_start_ratio=None, top_start_ratio=None, left_end_ratio=None, |
| 30 top_end_ratio=None, speed_in_pixels_per_second=800, | 30 top_end_ratio=None, speed_in_pixels_per_second=800, |
| 31 use_touch=False): | 31 use_touch=False): |
| 32 super(DragAction, self).__init__() | 32 super(DragAction, self).__init__() |
| 33 self._selector = selector | 33 self._selector = selector |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 }''' % (self._left_start_ratio, | 95 }''' % (self._left_start_ratio, |
| 96 self._top_start_ratio, | 96 self._top_start_ratio, |
| 97 self._left_end_ratio, | 97 self._left_end_ratio, |
| 98 self._top_end_ratio, | 98 self._top_end_ratio, |
| 99 self._speed, | 99 self._speed, |
| 100 gesture_source_type) | 100 gesture_source_type) |
| 101 page_action.EvaluateCallbackWithElement( | 101 page_action.EvaluateCallbackWithElement( |
| 102 tab, code, selector=self._selector, text=self._text, | 102 tab, code, selector=self._selector, text=self._text, |
| 103 element_function=self._element_function) | 103 element_function=self._element_function) |
| 104 tab.WaitForJavaScriptExpression('window.__dragActionDone', 60) | 104 tab.WaitForJavaScriptExpression('window.__dragActionDone', 60) |
| OLD | NEW |