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

Unified Diff: tools/telemetry/telemetry/page/actions/pinch.py

Issue 293683002: Synthetic pinch gesture take scale factor as parameter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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: tools/telemetry/telemetry/page/actions/pinch.py
diff --git a/tools/telemetry/telemetry/page/actions/pinch.py b/tools/telemetry/telemetry/page/actions/pinch.py
index b7085c5622b710f7ece677882041446e3775bc76..c0b09c2f8af4362409c393a9aa5842c8026572f9 100644
--- a/tools/telemetry/telemetry/page/actions/pinch.py
+++ b/tools/telemetry/telemetry/page/actions/pinch.py
@@ -21,6 +21,12 @@ class PinchAction(GestureAction):
raise page_action.PageActionNotSupported(
'Synthetic pinch not supported for this browser')
+ # TODO(dominikg): Remove once JS interface changes have rolled into stable.
+ if not tab.EvaluateJavaScript('chrome.gpuBenchmarking.newPinchInterface'):
+ raise page_action.PageActionNotSupported("""
Sami 2014/05/19 14:49:04 Nit: use single instead of triple quotes since oth
Dominik Grewe 2014/05/19 17:31:43 Done.
+ This version of the browser doesn't support the new JS interface for
+ pinch gestures.""")
+
if (GestureAction.GetGestureSourceTypeFromOptions(tab) ==
'chrome.gpuBenchmarking.MOUSE_INPUT'):
raise page_action.PageActionNotSupported(
@@ -36,11 +42,17 @@ class PinchAction(GestureAction):
window.__pinchAction = new __PinchAction(%s);"""
% done_callback)
+ @staticmethod
+ def _GetDefaultScaleFactorForPage(tab):
+ current_scale_factor = tab.EvaluateJavaScript(
+ 'window.outerWidth / window.innerWidth')
+ return 3.0 / current_scale_factor
+
def RunGesture(self, page, tab):
left_anchor_percentage = getattr(self, 'left_anchor_percentage', 0.5)
top_anchor_percentage = getattr(self, 'top_anchor_percentage', 0.5)
- zoom_in = getattr(self, 'zoom_in', True)
- pixels_to_cover = getattr(self, 'pixels_to_cover', 500)
+ scale_factor = getattr(self, 'scale_factor',
+ PinchAction._GetDefaultScaleFactorForPage(tab))
speed = getattr(self, 'speed', 800)
if hasattr(self, 'element_function'):
@@ -49,14 +61,12 @@ class PinchAction(GestureAction):
{ element: element,
left_anchor_percentage: %s,
top_anchor_percentage: %s,
- zoom_in: %s,
- pixels_to_cover: %s,
+ scale_factor: %s,
speed: %s })
});""" % (self.element_function,
left_anchor_percentage,
top_anchor_percentage,
- 'true' if zoom_in else 'false',
- pixels_to_cover,
+ scale_factor,
speed))
else:
tab.ExecuteJavaScript("""
@@ -64,13 +74,11 @@ class PinchAction(GestureAction):
{ element: document.body,
left_anchor_percentage: %s,
top_anchor_percentage: %s,
- zoom_in: %s,
- pixels_to_cover: %s,
+ scale_factor: %s,
speed: %s });"""
% (left_anchor_percentage,
top_anchor_percentage,
- 'true' if zoom_in else 'false',
- pixels_to_cover,
+ scale_factor,
speed))
tab.WaitForJavaScriptExpression('window.__pinchActionDone', 60)

Powered by Google App Engine
This is Rietveld 408576698