Chromium Code Reviews| Index: tools/telemetry/telemetry/page/actions/action_runner.py |
| diff --git a/tools/telemetry/telemetry/page/actions/action_runner.py b/tools/telemetry/telemetry/page/actions/action_runner.py |
| index 50f2999a175cc055e7fe1d147b9cd33c2578c036..6467a6c9bd7da50557173c57551ae7cd37968642 100644 |
| --- a/tools/telemetry/telemetry/page/actions/action_runner.py |
| +++ b/tools/telemetry/telemetry/page/actions/action_runner.py |
| @@ -5,6 +5,7 @@ |
| from telemetry.page.actions import page_action |
| from telemetry.page.actions.javascript_click import ClickElementAction |
| from telemetry.page.actions.navigate import NavigateAction |
| +from telemetry.page.actions.swipe import SwipeAction |
| from telemetry.page.actions.tap import TapAction |
| from telemetry.page.actions.wait import WaitAction |
| from telemetry.web_perf import timeline_interaction_record as tir_module |
| @@ -192,6 +193,59 @@ class ActionRunner(object): |
| _FillElementSelector(attr, selector, text, element_function) |
| self.RunAction(ClickElementAction(attr)) |
| + def SwipePage(self, left_start_ratio=0.5, top_start_ratio=0.5, |
| + direction='left', distance=100, speed=800): |
| + """Perform swipe gesture on the page. |
| + |
| + Args: |
| + left_start_ratio: The horizontal starting coordinate of the |
| + gesture, as a ratio of the visible bounding rectangle for |
| + document.body. |
| + top_start_ratio: The vertical starting coordinate of the |
| + gesture, as a ratio of the visible bounding rectangle for |
| + document.body. |
| + direction: The direction of swipe, either 'left', 'right', |
| + 'up', or 'down' |
| + distance: The distance to swipe (in pixel). |
| + speed: The speed of the gesture. |
| + """ |
| + self.RunAction(SwipeAction( |
| + left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio, |
| + direction=direction, distance=distance, speed=speed)) |
| + |
| + # TODO(chrishenry): This should also accept selector, text, |
| + # element_function (like ClickElement/TapElement. However, rather |
|
nednguyen
2014/06/14 17:12:13
I am a little confused by this TODO. Looking at th
chrishenry
2014/06/14 17:30:51
Old TODO before I changed the code (this patch was
|
| + # than duplicating the logic right now, I'm looking into refactoring |
| + # the element finding step. This code should be converted to use |
| + # that code when that happens (it will get support for selector, |
| + # text, element_function for almost free). |
| + 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=800): |
| + """Perform swipe gesture on the element. |
| + |
| + Args: |
| + selector: A CSS selector describing the element. |
| + text: The element must contains this exact text. |
| + element_function: A JavaScript function (as string) that is used |
| + to retrieve the element. For example: |
| + 'function() { return foo.element; }'. |
| + left_start_ratio: The horizontal starting coordinate of the |
| + gesture, as a ratio of the visible bounding rectangle for |
| + the element. |
| + top_start_ratio: The vertical starting coordinate of the |
| + gesture, as a ratio of the visible bounding rectangle for |
| + the element. |
| + direction: The direction of swipe, either 'left', 'right', |
| + 'up', or 'down' |
| + distance: The distance to swipe (in pixel). |
| + speed: The speed of the gesture. |
| + """ |
| + 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=speed)) |
| + |
| def _FillElementSelector(attr, selector=None, text=None, element_function=None): |
| count = 0 |