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

Side by Side Diff: telemetry/telemetry/internal/actions/tap.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 TapAction(page_action.PageAction): 9 class TapAction(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_position_percentage=0.5, top_position_percentage=0.5, 11 left_position_percentage=0.5, top_position_percentage=0.5,
13 duration_ms=50, 12 duration_ms=50,
14 synthetic_gesture_source=page_action.GESTURE_SOURCE_DEFAULT): 13 synthetic_gesture_source=page_action.GESTURE_SOURCE_DEFAULT):
15 super(TapAction, self).__init__() 14 super(TapAction, self).__init__()
16 self.selector = selector 15 self.selector = selector
17 self.text = text 16 self.text = text
18 self.element_function = element_function 17 self.element_function = element_function
19 self.left_position_percentage = left_position_percentage 18 self.left_position_percentage = left_position_percentage
20 self.top_position_percentage = top_position_percentage 19 self.top_position_percentage = top_position_percentage
21 self.duration_ms = duration_ms 20 self.duration_ms = duration_ms
22 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' % 21 self._synthetic_gesture_source = ('chrome.gpuBenchmarking.%s_INPUT' %
23 synthetic_gesture_source) 22 synthetic_gesture_source)
24 23
25 def WillRunAction(self, tab): 24 def WillRunAction(self, tab):
26 for js_file in ['gesture_common.js', 'tap.js']: 25 utils.InjectJavaScript(tab, 'gesture_common.js')
27 with open(os.path.join(os.path.dirname(__file__), js_file)) as f: 26 utils.InjectJavaScript(tab, 'tap.js')
28 js = f.read()
29 tab.ExecuteJavaScript(js)
30 27
31 # Fail if browser doesn't support synthetic tap gestures. 28 # Fail if browser doesn't support synthetic tap gestures.
32 if not tab.EvaluateJavaScript('window.__TapAction_SupportedByBrowser()'): 29 if not tab.EvaluateJavaScript('window.__TapAction_SupportedByBrowser()'):
33 raise page_action.PageActionNotSupported( 30 raise page_action.PageActionNotSupported(
34 'Synthetic tap not supported for this browser') 31 'Synthetic tap not supported for this browser')
35 32
36 done_callback = 'function() { window.__tapActionDone = true; }' 33 done_callback = 'function() { window.__tapActionDone = true; }'
37 tab.ExecuteJavaScript(""" 34 tab.ExecuteJavaScript("""
38 window.__tapActionDone = false; 35 window.__tapActionDone = false;
39 window.__tapAction = new __TapAction(%s);""" 36 window.__tapAction = new __TapAction(%s);"""
(...skipping 24 matching lines...) Expand all
64 if (!element) { 61 if (!element) {
65 throw Error('Cannot find element: ' + errorMsg); 62 throw Error('Cannot find element: ' + errorMsg);
66 } 63 }
67 %s; 64 %s;
68 }''' % tap_cmd 65 }''' % tap_cmd
69 66
70 page_action.EvaluateCallbackWithElement( 67 page_action.EvaluateCallbackWithElement(
71 tab, code, selector=self.selector, text=self.text, 68 tab, code, selector=self.selector, text=self.text,
72 element_function=self.element_function) 69 element_function=self.element_function)
73 tab.WaitForJavaScriptExpression('window.__tapActionDone', 60) 70 tab.WaitForJavaScriptExpression('window.__tapActionDone', 60)
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/actions/tap.js ('k') | telemetry/telemetry/internal/actions/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698