Commit aef5aa59 authored by dominikg@chromium.org's avatar dominikg@chromium.org

Telemetry: Add speed parameters to swipe and scroll actions.

The synthetic swipe and scroll gestures have a parameter that controls the speed
of the gesture (in pixels per second). This patch exposes that parameter to the
corresponding page actions in Telemetry.

BUG=326522

Review URL: https://codereview.chromium.org/128073002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243861 0039d316-1c4b-4281-b951-d872f2087c98
parent bbb18405
......@@ -17,12 +17,14 @@
this.left_start_percentage_ = opt_options.left_start_percentage;
this.top_start_percentage_ = opt_options.top_start_percentage;
this.direction_ = opt_options.direction;
this.speed_ = opt_options.speed;
this.gesture_source_type_ = opt_options.gesture_source_type;
} else {
this.element_ = document.body;
this.left_start_percentage_ = 0.5;
this.top_start_percentage_ = 0.5;
this.direction_ = 'down';
this.speed_ = 800;
this.gesture_source_type_ = chrome.gpuBenchmarking.DEFAULT_INPUT;
}
}
......@@ -98,7 +100,8 @@
rect.top + rect.height * this.options_.top_start_percentage_;
chrome.gpuBenchmarking.smoothScrollBy(
distance, this.onGestureComplete_.bind(this), start_left, start_top,
this.options_.gesture_source_type, this.options_.direction_);
this.options_.gesture_source_type, this.options_.direction_,
this.options_.speed_);
};
ScrollAction.prototype.onGestureComplete_ = function() {
......
......@@ -51,6 +51,7 @@ class ScrollAction(gesture_action.GestureAction):
left_start_percentage = 0.5
top_start_percentage = 0.5
direction = 'down'
speed = 800
gesture_source_type = 'chrome.gpuBenchmarking.DEFAULT_INPUT'
if hasattr(self, 'left_start_percentage'):
left_start_percentage = self.left_start_percentage
......@@ -61,6 +62,8 @@ class ScrollAction(gesture_action.GestureAction):
if direction not in ['down', 'up', 'left', 'right']:
raise page_action.PageActionNotSupported(
'Invalid scroll direction: %s' % direction)
if hasattr(self, 'speed'):
speed = self.speed
if hasattr(self, 'scroll_requires_touch') and self.scroll_requires_touch:
gesture_source_type = 'chrome.gpuBenchmarking.TOUCH_INPUT'
if hasattr(self, 'scrollable_element_function'):
......@@ -70,11 +73,13 @@ class ScrollAction(gesture_action.GestureAction):
left_start_percentage: %s,
top_start_percentage: %s,
direction: '%s',
speed: %s,
gesture_source_type: %s })
});""" % (self.scrollable_element_function,
left_start_percentage,
top_start_percentage,
direction,
speed,
gesture_source_type))
else:
tab.ExecuteJavaScript("""
......@@ -83,10 +88,12 @@ class ScrollAction(gesture_action.GestureAction):
left_start_percentage: %s,
top_start_percentage: %s,
direction: '%s',
speed: %s,
gesture_source_type: %s });"""
% (left_start_percentage,
top_start_percentage,
direction,
speed,
gesture_source_type))
tab.WaitForJavaScriptExpression('window.__scrollActionDone', 60)
......
......@@ -12,12 +12,14 @@
this.top_start_percentage_ = opt_options.top_start_percentage;
this.direction_ = opt_options.direction;
this.distance_ = opt_options.distance;
this.speed_ = opt_options.speed;
} else {
this.element_ = document.body;
this.left_start_percentage_ = 0.5;
this.top_start_percentage_ = 0.5;
this.direction_ = 'left';
this.distance_ = 0;
this.speed_ = 800;
}
}
......@@ -56,7 +58,8 @@
chrome.gpuBenchmarking.swipe(this.options_.direction_,
this.options_.distance_,
this.onGestureComplete_.bind(this),
start_left, start_top);
start_left, start_top,
this.options_.speed_);
};
SwipeAction.prototype.onGestureComplete_ = function() {
......
......@@ -36,6 +36,7 @@ class SwipeAction(gesture_action.GestureAction):
top_start_percentage = 0.5
direction = 'left'
distance = 100
speed = 800
if hasattr(self, 'left_start_percentage'):
left_start_percentage = self.left_start_percentage
if hasattr(self, 'top_start_percentage'):
......@@ -47,6 +48,8 @@ class SwipeAction(gesture_action.GestureAction):
'Invalid swipe direction: %s' % direction)
if hasattr(self, 'distance'):
distance = self.distance
if hasattr(self, 'speed'):
speed = self.speed
if hasattr(self, 'element_function'):
tab.ExecuteJavaScript("""
(%s)(function(element) { window.__swipeAction.start(
......@@ -54,12 +57,14 @@ class SwipeAction(gesture_action.GestureAction):
left_start_percentage: %s,
top_start_percentage: %s,
direction: '%s',
distance: %s })
distance: %s,
speed: %s })
});""" % (self.element_function,
left_start_percentage,
top_start_percentage,
direction,
distance))
distance,
speed))
else:
tab.ExecuteJavaScript("""
window.__swipeAction.start(
......@@ -67,11 +72,13 @@ class SwipeAction(gesture_action.GestureAction):
left_start_percentage: %s,
top_start_percentage: %s,
direction: '%s',
distance: %s });"""
distance: %s,
speed: %s });"""
% (left_start_percentage,
top_start_percentage,
direction,
distance))
distance,
speed))
tab.WaitForJavaScriptExpression('window.__swipeActionDone', 60)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment