OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 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 import os | 4 import os |
5 | 5 |
6 from telemetry.page.actions import page_action | 6 from telemetry.page.actions import page_action |
7 | 7 |
8 | 8 |
9 class ScrollAction(page_action.PageAction): | 9 class ScrollAction(page_action.PageAction): |
10 # TODO(chrishenry): Ignore attributes, to be deleted when usage in | 10 # TODO(chrishenry): Ignore attributes, to be deleted when usage in |
11 # other repo is cleaned up. | 11 # other repo is cleaned up. |
12 def __init__(self, selector=None, text=None, element_function=None, | 12 def __init__(self, selector=None, text=None, element_function=None, |
13 left_start_ratio=0.5, top_start_ratio=0.5, direction='down', | 13 left_start_ratio=0.5, top_start_ratio=0.5, direction='down', |
14 distance=None, distance_expr=None, | 14 distance=None, distance_expr=None, |
15 speed_in_pixels_per_second=800, use_touch=False): | 15 speed_in_pixels_per_second=800, use_touch=False): |
16 super(ScrollAction, self).__init__() | 16 super(ScrollAction, self).__init__() |
17 if direction not in ['down', 'up', 'left', 'right']: | 17 if direction not in ['down', 'up', 'left', 'right', |
| 18 'downleft', 'downright', |
| 19 'upleft', 'upright']: |
18 raise page_action.PageActionNotSupported( | 20 raise page_action.PageActionNotSupported( |
19 'Invalid scroll direction: %s' % self.direction) | 21 'Invalid scroll direction: %s' % self.direction) |
20 self._selector = selector | 22 self._selector = selector |
21 self._text = text | 23 self._text = text |
22 self._element_function = element_function | 24 self._element_function = element_function |
23 self._left_start_ratio = left_start_ratio | 25 self._left_start_ratio = left_start_ratio |
24 self._top_start_ratio = top_start_ratio | 26 self._top_start_ratio = top_start_ratio |
25 self._direction = direction | 27 self._direction = direction |
26 self._speed = speed_in_pixels_per_second | 28 self._speed = speed_in_pixels_per_second |
27 self._use_touch = use_touch | 29 self._use_touch = use_touch |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 }); | 88 }); |
87 }''' % (self._left_start_ratio, | 89 }''' % (self._left_start_ratio, |
88 self._top_start_ratio, | 90 self._top_start_ratio, |
89 self._direction, | 91 self._direction, |
90 self._speed, | 92 self._speed, |
91 gesture_source_type) | 93 gesture_source_type) |
92 page_action.EvaluateCallbackWithElement( | 94 page_action.EvaluateCallbackWithElement( |
93 tab, code, selector=self._selector, text=self._text, | 95 tab, code, selector=self._selector, text=self._text, |
94 element_function=self._element_function) | 96 element_function=self._element_function) |
95 tab.WaitForJavaScriptExpression('window.__scrollActionDone', 60) | 97 tab.WaitForJavaScriptExpression('window.__scrollActionDone', 60) |
OLD | NEW |