Commit 7b874423 authored by ssid's avatar ssid Committed by Commit bot

Adding telemetry test for page scroll using scrollbar drag.

This CL adds a telemetry benchmark to use gmail page and uses the
scrollbar and mouss drag action to scroll the page. The test calculates
the mid-point of scrollbar and drags it till the end of the page.

BUG=464685

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

Cr-Commit-Position: refs/heads/master@{#319629}
parent 0985fac1
...@@ -53,6 +53,51 @@ class GmailSmoothPage(top_pages.GmailPage): ...@@ -53,6 +53,51 @@ class GmailSmoothPage(top_pages.GmailPage):
interaction.End() interaction.End()
class GmailMouseScrollPage(top_pages.GmailPage):
""" Why: productivity, top google properties """
def RunPageInteractions(self, action_runner):
action_runner.ExecuteJavaScript('''
gmonkey.load('2.0', function(api) {
window.__scrollableElementForTelemetry = api.getScrollableElement();
});''')
action_runner.WaitForJavaScriptCondition(
'window.__scrollableElementForTelemetry != null')
scrollbar_x, start_y, end_y = self._CalculateScrollBarRatios(action_runner)
interaction = action_runner.BeginGestureInteraction(
'DragAction', is_smooth=True)
action_runner.DragPage(left_start_ratio=scrollbar_x,
top_start_ratio=start_y, left_end_ratio=scrollbar_x,
top_end_ratio=end_y, speed_in_pixels_per_second=100,
element_function='window.__scrollableElementForTelemetry')
interaction.End()
def CanRunOnBrowser(self, browser_info):
return (browser_info._browser._platform_backend.platform.GetOSName() !=
'android')
def _CalculateScrollBarRatios(self, action_runner):
viewport_height = float(action_runner.EvaluateJavaScript(
'window.__scrollableElementForTelemetry.clientHeight'))
content_height = float(action_runner.EvaluateJavaScript(
'window.__scrollableElementForTelemetry.scrollHeight'))
viewport_width = float(action_runner.EvaluateJavaScript(
'window.__scrollableElementForTelemetry.offsetWidth'))
scrollbar_width = float(action_runner.EvaluateJavaScript('''
window.__scrollableElementForTelemetry.offsetWidth -
window.__scrollableElementForTelemetry.scrollWidth'''))
# This calculation is correct only when the element doesn't have border or
# padding or scroll buttons (eg: gmail mail element).
scrollbar_start_mid_y = viewport_height / (2 * content_height)
scrollbar_end_mid_y = 1 - scrollbar_start_mid_y
scrollbar_mid_x_offset = scrollbar_width / (2 * viewport_width)
scrollbar_mid_x = 1 - scrollbar_mid_x_offset
return scrollbar_mid_x, scrollbar_start_mid_y, scrollbar_end_mid_y
class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage):
""" Why: productivity, top google properties """ """ Why: productivity, top google properties """
...@@ -118,6 +163,7 @@ class Top25SmoothPageSet(page_set_module.PageSet): ...@@ -118,6 +163,7 @@ class Top25SmoothPageSet(page_set_module.PageSet):
self.AddUserStory(_CreatePageClassWithSmoothInteractions( self.AddUserStory(_CreatePageClassWithSmoothInteractions(
top_pages.GoogleWebSearchPage)(self)) top_pages.GoogleWebSearchPage)(self))
self.AddUserStory(GmailSmoothPage(self)) self.AddUserStory(GmailSmoothPage(self))
self.AddUserStory(GmailMouseScrollPage(self))
self.AddUserStory(GoogleCalendarSmoothPage(self)) self.AddUserStory(GoogleCalendarSmoothPage(self))
self.AddUserStory(_CreatePageClassWithSmoothInteractions( self.AddUserStory(_CreatePageClassWithSmoothInteractions(
top_pages.GoogleImageSearchPage)(self)) top_pages.GoogleImageSearchPage)(self))
......
...@@ -241,7 +241,8 @@ class ActionRunner(object): ...@@ -241,7 +241,8 @@ class ActionRunner(object):
selector=selector, text=text, element_function=element_function)) selector=selector, text=text, element_function=element_function))
def DragPage(self, left_start_ratio, top_start_ratio, left_end_ratio, def DragPage(self, left_start_ratio, top_start_ratio, left_end_ratio,
top_end_ratio, speed_in_pixels_per_second=800, use_touch=False): top_end_ratio, speed_in_pixels_per_second=800, use_touch=False,
selector=None, text=None, element_function=None):
"""Perform a drag gesture on the page. """Perform a drag gesture on the page.
You should specify a start and an end point in ratios of page width and You should specify a start and an end point in ratios of page width and
...@@ -267,7 +268,8 @@ class ActionRunner(object): ...@@ -267,7 +268,8 @@ class ActionRunner(object):
left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio, left_start_ratio=left_start_ratio, top_start_ratio=top_start_ratio,
left_end_ratio=left_end_ratio, top_end_ratio=top_end_ratio, left_end_ratio=left_end_ratio, top_end_ratio=top_end_ratio,
speed_in_pixels_per_second=speed_in_pixels_per_second, speed_in_pixels_per_second=speed_in_pixels_per_second,
use_touch=use_touch)) use_touch=use_touch, selector=selector, text=text,
element_function=element_function))
def PinchPage(self, left_anchor_ratio=0.5, top_anchor_ratio=0.5, def PinchPage(self, left_anchor_ratio=0.5, top_anchor_ratio=0.5,
scale_factor=None, speed_in_pixels_per_second=800): scale_factor=None, speed_in_pixels_per_second=800):
......
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