OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 logging | 5 import logging |
6 import time | 6 import time |
7 import urlparse | 7 import urlparse |
8 | 8 |
9 from telemetry.internal.actions.drag import DragAction | 9 from telemetry.internal.actions.drag import DragAction |
10 from telemetry.internal.actions.javascript_click import ClickElementAction | 10 from telemetry.internal.actions.javascript_click import ClickElementAction |
11 from telemetry.internal.actions.load_media import LoadMediaAction | 11 from telemetry.internal.actions.load_media import LoadMediaAction |
12 from telemetry.internal.actions.loop import LoopAction | 12 from telemetry.internal.actions.loop import LoopAction |
13 from telemetry.internal.actions.mouse_click import MouseClickAction | 13 from telemetry.internal.actions.mouse_click import MouseClickAction |
14 from telemetry.internal.actions.navigate import NavigateAction | 14 from telemetry.internal.actions.navigate import NavigateAction |
15 from telemetry.internal.actions.page_action import GESTURE_SOURCE_DEFAULT | 15 from telemetry.internal.actions.page_action import GESTURE_SOURCE_DEFAULT |
16 from telemetry.internal.actions.page_action import SUPPORTED_GESTURE_SOURCES | 16 from telemetry.internal.actions.page_action import SUPPORTED_GESTURE_SOURCES |
17 from telemetry.internal.actions.pinch import PinchAction | 17 from telemetry.internal.actions.pinch import PinchAction |
18 from telemetry.internal.actions.play import PlayAction | 18 from telemetry.internal.actions.play import PlayAction |
19 from telemetry.internal.actions.repaint_continuously import ( | 19 from telemetry.internal.actions.repaint_continuously import ( |
20 RepaintContinuouslyAction) | 20 RepaintContinuouslyAction) |
| 21 from telemetry.internal.actions.repeatable_scroll import RepeatableScrollAction |
21 from telemetry.internal.actions.scroll import ScrollAction | 22 from telemetry.internal.actions.scroll import ScrollAction |
22 from telemetry.internal.actions.scroll_bounce import ScrollBounceAction | 23 from telemetry.internal.actions.scroll_bounce import ScrollBounceAction |
23 from telemetry.internal.actions.seek import SeekAction | 24 from telemetry.internal.actions.seek import SeekAction |
24 from telemetry.internal.actions.swipe import SwipeAction | 25 from telemetry.internal.actions.swipe import SwipeAction |
25 from telemetry.internal.actions.tap import TapAction | 26 from telemetry.internal.actions.tap import TapAction |
26 from telemetry.internal.actions.wait import WaitForElementAction | 27 from telemetry.internal.actions.wait import WaitForElementAction |
27 from telemetry.web_perf import timeline_interaction_record | 28 from telemetry.web_perf import timeline_interaction_record |
28 | 29 |
29 | 30 |
30 class ActionRunner(object): | 31 class ActionRunner(object): |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 synthetic_gesture_source: the source input device type for the | 352 synthetic_gesture_source: the source input device type for the |
352 synthetic gesture: 'DEFAULT', 'TOUCH' or 'MOUSE'. | 353 synthetic gesture: 'DEFAULT', 'TOUCH' or 'MOUSE'. |
353 """ | 354 """ |
354 assert synthetic_gesture_source in SUPPORTED_GESTURE_SOURCES | 355 assert synthetic_gesture_source in SUPPORTED_GESTURE_SOURCES |
355 self._RunAction(ScrollAction( | 356 self._RunAction(ScrollAction( |
356 left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio, | 357 left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio, |
357 direction=direction, distance=distance, distance_expr=distance_expr, | 358 direction=direction, distance=distance, distance_expr=distance_expr, |
358 speed_in_pixels_per_second=speed_in_pixels_per_second, | 359 speed_in_pixels_per_second=speed_in_pixels_per_second, |
359 use_touch=use_touch, synthetic_gesture_source=synthetic_gesture_source)) | 360 use_touch=use_touch, synthetic_gesture_source=synthetic_gesture_source)) |
360 | 361 |
| 362 def RepeatableBrowserDrivenScroll(self, x_scroll_distance_ratio=0.0, |
| 363 y_scroll_distance_ratio=0.5, |
| 364 repeat_count=0, |
| 365 repeat_delay_ms=250): |
| 366 """Perform a browser driven repeatable scroll gesture. |
| 367 |
| 368 The scroll gesture is driven from the browser, this is useful because the |
| 369 main thread often isn't resposive but the browser process usually is, so the |
| 370 delay between the scroll gestures should be consistent. |
| 371 |
| 372 Args: |
| 373 x_scroll_distance_ratio: The horizontal lenght of the scroll as a fraction |
| 374 of the screen width. |
| 375 y_scroll_distance_ratio: The vertical lenght of the scroll as a fraction |
| 376 of the screen height. |
| 377 repeat_count: The number of additional times to repeat the gesture. |
| 378 repeat_delay_ms: The delay in milliseconds between each scroll gesture. |
| 379 """ |
| 380 self._RunAction(RepeatableScrollAction( |
| 381 x_scroll_distance_ratio=x_scroll_distance_ratio, |
| 382 y_scroll_distance_ratio=y_scroll_distance_ratio, |
| 383 repeat_count=repeat_count, |
| 384 repeat_delay_ms=repeat_delay_ms)) |
| 385 |
361 def ScrollElement(self, selector=None, text=None, element_function=None, | 386 def ScrollElement(self, selector=None, text=None, element_function=None, |
362 left_start_ratio=0.5, top_start_ratio=0.5, | 387 left_start_ratio=0.5, top_start_ratio=0.5, |
363 direction='down', distance=None, distance_expr=None, | 388 direction='down', distance=None, distance_expr=None, |
364 speed_in_pixels_per_second=800, use_touch=False, | 389 speed_in_pixels_per_second=800, use_touch=False, |
365 synthetic_gesture_source=GESTURE_SOURCE_DEFAULT): | 390 synthetic_gesture_source=GESTURE_SOURCE_DEFAULT): |
366 """Perform scroll gesture on the element. | 391 """Perform scroll gesture on the element. |
367 | 392 |
368 The element may be selected via selector, text, or element_function. | 393 The element may be selected via selector, text, or element_function. |
369 Only one of these arguments must be specified. | 394 Only one of these arguments must be specified. |
370 | 395 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 self._action_runner.ExecuteJavaScript('console.time("%s");' % | 704 self._action_runner.ExecuteJavaScript('console.time("%s");' % |
680 timeline_interaction_record.GetJavaScriptMarker( | 705 timeline_interaction_record.GetJavaScriptMarker( |
681 self._label, self._flags)) | 706 self._label, self._flags)) |
682 | 707 |
683 def End(self): | 708 def End(self): |
684 assert self._started | 709 assert self._started |
685 self._started = False | 710 self._started = False |
686 self._action_runner.ExecuteJavaScript('console.timeEnd("%s");' % | 711 self._action_runner.ExecuteJavaScript('console.timeEnd("%s");' % |
687 timeline_interaction_record.GetJavaScriptMarker( | 712 timeline_interaction_record.GetJavaScriptMarker( |
688 self._label, self._flags)) | 713 self._label, self._flags)) |
OLD | NEW |