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

Side by Side Diff: telemetry/telemetry/internal/actions/swipe.py

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 os
6
7 from telemetry.internal.actions import page_action 5 from telemetry.internal.actions import page_action
6 from telemetry.internal.actions import utils
8 7
9 8
10 class SwipeAction(page_action.PageAction): 9 class SwipeAction(page_action.PageAction):
11 def __init__(self, selector=None, text=None, element_function=None, 10 def __init__(self, selector=None, text=None, element_function=None,
12 left_start_ratio=0.5, top_start_ratio=0.5, 11 left_start_ratio=0.5, top_start_ratio=0.5,
13 direction='left', distance=100, speed_in_pixels_per_second=800, 12 direction='left', distance=100, speed_in_pixels_per_second=800,
14 synthetic_gesture_source=page_action.GESTURE_SOURCE_DEFAULT): 13 synthetic_gesture_source=page_action.GESTURE_SOURCE_DEFAULT):
15 super(SwipeAction, self).__init__() 14 super(SwipeAction, self).__init__()
16 if direction not in ['down', 'up', 'left', 'right']: 15 if direction not in ['down', 'up', 'left', 'right']:
17 raise page_action.PageActionNotSupported( 16 raise page_action.PageActionNotSupported(
18 'Invalid swipe direction: %s' % self.direction) 17 'Invalid swipe direction: %s' % self.direction)
19 self._selector = selector 18 self._selector = selector
20 self._text = text 19 self._text = text
21 self._element_function = element_function 20 self._element_function = element_function
22 self._left_start_ratio = left_start_ratio 21 self._left_start_ratio = left_start_ratio
23 self._top_start_ratio = top_start_ratio 22 self._top_start_ratio = top_start_ratio
24 self._direction = direction 23 self._direction = direction
25 self._distance = distance 24 self._distance = distance
26 self._speed = speed_in_pixels_per_second 25 self._speed = speed_in_pixels_per_second
27 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' % 26 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' %
28 synthetic_gesture_source) 27 synthetic_gesture_source)
29 28
30 def WillRunAction(self, tab): 29 def WillRunAction(self, tab):
31 for js_file in ['gesture_common.js', 'swipe.js']: 30 utils.InjectJavaScript(tab, 'gesture_common.js')
32 with open(os.path.join(os.path.dirname(__file__), js_file)) as f: 31 utils.InjectJavaScript(tab, 'swipe.js')
33 js = f.read()
34 tab.ExecuteJavaScript(js)
35 32
36 # Fail if browser doesn't support synthetic swipe gestures. 33 # Fail if browser doesn't support synthetic swipe gestures.
37 if not tab.EvaluateJavaScript('window.__SwipeAction_SupportedByBrowser()'): 34 if not tab.EvaluateJavaScript('window.__SwipeAction_SupportedByBrowser()'):
38 raise page_action.PageActionNotSupported( 35 raise page_action.PageActionNotSupported(
39 'Synthetic swipe not supported for this browser') 36 'Synthetic swipe not supported for this browser')
40 37
41 if (self._synthetic_gesture_source == 38 if (self._synthetic_gesture_source ==
42 'chrome.gpuBenchmarking.MOUSE_INPUT'): 39 'chrome.gpuBenchmarking.MOUSE_INPUT'):
43 raise page_action.PageActionNotSupported( 40 raise page_action.PageActionNotSupported(
44 'Swipe page action does not support mouse input') 41 'Swipe page action does not support mouse input')
(...skipping 27 matching lines...) Expand all
72 }); 69 });
73 }''' % (self._left_start_ratio, 70 }''' % (self._left_start_ratio,
74 self._top_start_ratio, 71 self._top_start_ratio,
75 self._direction, 72 self._direction,
76 self._distance, 73 self._distance,
77 self._speed) 74 self._speed)
78 page_action.EvaluateCallbackWithElement( 75 page_action.EvaluateCallbackWithElement(
79 tab, code, selector=self._selector, text=self._text, 76 tab, code, selector=self._selector, text=self._text,
80 element_function=self._element_function) 77 element_function=self._element_function)
81 tab.WaitForJavaScriptExpression('window.__swipeActionDone', 60) 78 tab.WaitForJavaScriptExpression('window.__swipeActionDone', 60)
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/actions/swipe.js ('k') | telemetry/telemetry/internal/actions/tap.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698