Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(958)

Unified Diff: telemetry/telemetry/internal/actions/action_runner.py

Issue 2754203005: touchpad swipe support added.
Patch Set: Comments on scroll and swipe directions. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: telemetry/telemetry/internal/actions/action_runner.py
diff --git a/telemetry/telemetry/internal/actions/action_runner.py b/telemetry/telemetry/internal/actions/action_runner.py
index ec2a5eac8e28db8da31ed2c215a0baed16a7f38d..ae77800f253de813a266568f6cea82354d0af910 100644
--- a/telemetry/telemetry/internal/actions/action_runner.py
+++ b/telemetry/telemetry/internal/actions/action_runner.py
@@ -418,6 +418,8 @@ class ActionRunner(object):
document.body.
direction: The direction of scroll, either 'left', 'right',
'up', 'down', 'upleft', 'upright', 'downleft', or 'downright'
+ Direction = 'down' with positive distance to scroll increases
rnephew (Reviews Here) 2017/03/28 20:04:18 Supernit: Direction -> direction So that its cons
nednguyen 2017/03/28 21:15:15 The documentation is also very out of place. Pleas
sahel 2017/04/25 18:03:54 Done.
+ scrollTop.
distance: The distance to scroll (in pixel).
distance_expr: A JavaScript expression (as string) that can be
evaluated to compute scroll distance. Example:
@@ -522,6 +524,8 @@ class ActionRunner(object):
the element.
direction: The direction of scroll, either 'left', 'right',
'up', 'down', 'upleft', 'upright', 'downleft', or 'downright'
+ Direction = 'down' with positive distance to scroll increases
+ scrollTop.
distance: The distance to scroll (in pixel).
distance_expr: A JavaScript expression (as string) that can be
evaluated to compute scroll distance. Example:
@@ -559,6 +563,8 @@ class ActionRunner(object):
document.body.
direction: The direction of scroll, either 'left', 'right',
'up', 'down', 'upleft', 'upright', 'downleft', or 'downright'
+ Direction = 'down' with positive distance to scroll increases
+ scrollTop.
distance: The distance to scroll (in pixel).
overscroll: The number of additional pixels to scroll back, in
addition to the givendistance.
@@ -598,6 +604,8 @@ class ActionRunner(object):
document.body.
direction: The direction of scroll, either 'left', 'right',
'up', 'down', 'upleft', 'upright', 'downleft', or 'downright'
+ Direction = 'down' with positive distance to scroll increases
+ scrollTop.
distance: The distance to scroll (in pixel).
overscroll: The number of additional pixels to scroll back, in
addition to the given distance.
@@ -620,7 +628,9 @@ class ActionRunner(object):
self._RunAction(MouseClickAction(selector=selector))
def SwipePage(self, left_start_ratio=0.5, top_start_ratio=0.5,
- direction='left', distance=100, speed_in_pixels_per_second=800):
+ direction='right', distance=100, speed_in_pixels_per_second=800,
+ synthetic_gesture_source=GESTURE_SOURCE_DEFAULT, velocity_x=0,
+ velocity_y=0):
nednguyen 2017/03/28 21:15:16 this is an API change, please: 1) Announce this ch
sahel 2017/04/25 18:03:54 1)Done. 2) The default behavior is not changed (it
"""Perform swipe gesture on the page.
Args:
@@ -632,18 +642,29 @@ class ActionRunner(object):
document.body.
direction: The direction of swipe, either 'left', 'right',
'up', or 'down'
+ Direction = 'right' with positive distance to scroll increases
+ scrollLeft.
distance: The distance to swipe (in pixel).
speed_in_pixels_per_second: The speed of the gesture (in pixels/s).
+ synthetic_gesture_source: the source input device type for the
+ synthetic gesture: 'DEFAULT', 'TOUCH' or 'MOUSE'.
+ velocity_x, velocity_y: Fling velocities for touchpad swipe
+ (source = 'MOUSE').
"""
+ assert synthetic_gesture_source in SUPPORTED_GESTURE_SOURCES
self._RunAction(SwipeAction(
left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio,
direction=direction, distance=distance,
- speed_in_pixels_per_second=speed_in_pixels_per_second))
+ speed_in_pixels_per_second=speed_in_pixels_per_second,
+ synthetic_gesture_source=synthetic_gesture_source,
+ velocity_x=velocity_x, velocity_y=velocity_y))
def SwipeElement(self, selector=None, text=None, element_function=None,
left_start_ratio=0.5, top_start_ratio=0.5,
- direction='left', distance=100,
- speed_in_pixels_per_second=800):
+ direction='right', distance=100,
+ speed_in_pixels_per_second=800,
+ synthetic_gesture_source=GESTURE_SOURCE_DEFAULT,
+ velocity_x=0, velocity_y=0):
"""Perform swipe gesture on the element.
The element may be selected via selector, text, or element_function.
@@ -663,14 +684,23 @@ class ActionRunner(object):
the element.
direction: The direction of swipe, either 'left', 'right',
'up', or 'down'
+ Direction = 'right' with positive distance to scroll increases
+ scrollLeft.
distance: The distance to swipe (in pixel).
speed_in_pixels_per_second: The speed of the gesture (in pixels/s).
+ synthetic_gesture_source: the source input device type for the
+ synthetic gesture: 'DEFAULT', 'TOUCH' or 'MOUSE'.
+ velocity_x, velocity_y: Fling velocities for touchpad swipe
+ (source = 'MOUSE').
"""
+ assert synthetic_gesture_source in SUPPORTED_GESTURE_SOURCES
self._RunAction(SwipeAction(
selector=selector, text=text, element_function=element_function,
left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio,
direction=direction, distance=distance,
- speed_in_pixels_per_second=speed_in_pixels_per_second))
+ speed_in_pixels_per_second=speed_in_pixels_per_second,
+ synthetic_gesture_source=synthetic_gesture_source,
+ velocity_x=velocity_x, velocity_y=velocity_y))
def PressKey(self, key, repeat_count=1, repeat_delay_ms=100, timeout=60):
"""Perform a key press.

Powered by Google App Engine
This is Rietveld 408576698