OLD | NEW |
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 import os | 4 import os |
5 | 5 |
6 from telemetry.internal.actions import page_action | 6 from telemetry.internal.actions import page_action |
7 | 7 |
8 | 8 |
9 class PinchAction(page_action.PageAction): | 9 class PinchAction(page_action.PageAction): |
10 def __init__(self, selector=None, text=None, element_function=None, | 10 def __init__(self, selector=None, text=None, element_function=None, |
(...skipping 25 matching lines...) Expand all Loading... |
36 if not tab.EvaluateJavaScript('window.__PinchAction_SupportedByBrowser()'): | 36 if not tab.EvaluateJavaScript('window.__PinchAction_SupportedByBrowser()'): |
37 raise page_action.PageActionNotSupported( | 37 raise page_action.PageActionNotSupported( |
38 'Synthetic pinch not supported for this browser') | 38 'Synthetic pinch not supported for this browser') |
39 | 39 |
40 # TODO(dominikg): Remove once JS interface changes have rolled into stable. | 40 # TODO(dominikg): Remove once JS interface changes have rolled into stable. |
41 if not tab.EvaluateJavaScript('chrome.gpuBenchmarking.newPinchInterface'): | 41 if not tab.EvaluateJavaScript('chrome.gpuBenchmarking.newPinchInterface'): |
42 raise page_action.PageActionNotSupported( | 42 raise page_action.PageActionNotSupported( |
43 'This version of the browser doesn\'t support the new JS interface ' | 43 'This version of the browser doesn\'t support the new JS interface ' |
44 'for pinch gestures.') | 44 'for pinch gestures.') |
45 | 45 |
46 if (self._synthetic_gesture_source == | |
47 'chrome.gpuBenchmarking.MOUSE_INPUT'): | |
48 raise page_action.PageActionNotSupported( | |
49 'Pinch page action does not support mouse input') | |
50 | |
51 if not page_action.IsGestureSourceTypeSupported(tab, 'touch'): | |
52 raise page_action.PageActionNotSupported( | |
53 'Touch input not supported for this browser') | |
54 | |
55 done_callback = 'function() { window.__pinchActionDone = true; }' | 46 done_callback = 'function() { window.__pinchActionDone = true; }' |
56 tab.ExecuteJavaScript(""" | 47 tab.ExecuteJavaScript(""" |
57 window.__pinchActionDone = false; | 48 window.__pinchActionDone = false; |
58 window.__pinchAction = new __PinchAction(%s);""" | 49 window.__pinchAction = new __PinchAction(%s);""" |
59 % done_callback) | 50 % done_callback) |
60 | 51 |
61 @staticmethod | 52 @staticmethod |
62 def _GetDefaultScaleFactorForPage(tab): | 53 def _GetDefaultScaleFactorForPage(tab): |
63 current_scale_factor = tab.EvaluateJavaScript( | 54 current_scale_factor = tab.EvaluateJavaScript( |
64 'window.outerWidth / window.innerWidth') | 55 'window.outerWidth / window.innerWidth') |
(...skipping 15 matching lines...) Expand all Loading... |
80 speed: %s | 71 speed: %s |
81 }); | 72 }); |
82 }''' % (self._left_anchor_ratio, | 73 }''' % (self._left_anchor_ratio, |
83 self._top_anchor_ratio, | 74 self._top_anchor_ratio, |
84 scale_factor, | 75 scale_factor, |
85 self._speed) | 76 self._speed) |
86 page_action.EvaluateCallbackWithElement( | 77 page_action.EvaluateCallbackWithElement( |
87 tab, code, selector=self._selector, text=self._text, | 78 tab, code, selector=self._selector, text=self._text, |
88 element_function=self._element_function) | 79 element_function=self._element_function) |
89 tab.WaitForJavaScriptExpression('window.__pinchActionDone', 60) | 80 tab.WaitForJavaScriptExpression('window.__pinchActionDone', 60) |
OLD | NEW |