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

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: rebase 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
« no previous file with comments | « tools/telemetry/telemetry/page/actions/pinch.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5a1f7e4d7418b8954e20c6486468a91b9247e3fd..d4a2b532c26ba86c03d9cd5815b3b10ed15cb489 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(
+ '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, 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)
« no previous file with comments | « tools/telemetry/telemetry/page/actions/pinch.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698