Commit c3cec45c authored by ssid's avatar ssid Committed by Commit bot

Telemetry benchmark key_desktop_move_pages.

This CL adds new benchmark to run drag gestures on gmail and maps page.
These pages are moved from top_25_smooth page set since this is desktop
specific. Please refer to crrev.com/985603003 and crrev.com/955653003
for motivation.

BUG=457148
BUG=464685

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

Cr-Commit-Position: refs/heads/master@{#322557}
parent 162e126f
...@@ -79,6 +79,16 @@ class SmoothnessMaps(benchmark.Benchmark): ...@@ -79,6 +79,16 @@ class SmoothnessMaps(benchmark.Benchmark):
return 'smoothness.maps' return 'smoothness.maps'
@benchmark.Disabled('android')
class SmoothnessKeyDesktopMoveCases(benchmark.Benchmark):
test = smoothness.Smoothness
page_set = page_sets.KeyDesktopMoveCasesPageSet
@classmethod
def Name(cls):
return 'smoothness.key_desktop_move_cases'
@benchmark.Enabled('android') @benchmark.Enabled('android')
class SmoothnessKeyMobileSites(benchmark.Benchmark): class SmoothnessKeyMobileSites(benchmark.Benchmark):
"""Measures rendering statistics while scrolling down the key mobile sites. """Measures rendering statistics while scrolling down the key mobile sites.
......
{
"description": "Describes the Web Page Replay archives for a user story set. Don't edit by hand! Use record_wpr for updating.",
"archives": {
"key_desktop_move_cases_001.wpr": [
"https://mail.google.com/mail/"
],
"key_desktop_move_cases_000.wpr": [
"Maps"
]
}
}
7982d4d8661f8e7bf33e4c4a68e41dd3b8dc7661
\ No newline at end of file
14033b38b9be98cbcafa9cbb49636a4b93256f46
\ No newline at end of file
...@@ -7,9 +7,6 @@ ...@@ -7,9 +7,6 @@
"top_25_001.wpr": [ "top_25_001.wpr": [
"https://plus.google.com/110031535020051778989/posts" "https://plus.google.com/110031535020051778989/posts"
], ],
"top_25_004.wpr": [
"Maps"
],
"top_25_002.wpr": [ "top_25_002.wpr": [
"https://www.google.com/search?q=cats&tbm=isch" "https://www.google.com/search?q=cats&tbm=isch"
], ],
......
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module
class KeyDesktopMoveCasesPage(page_module.Page):
def __init__(self, url, page_set, name='', credentials=None):
super(KeyDesktopMoveCasesPage, self).__init__(
url=url, page_set=page_set, name=name,
credentials_path='data/credentials.json')
self.archive_data_file = 'data/key_desktop_move_cases.json'
self.user_agent_type = 'desktop'
self.credentials = credentials
class GmailMouseScrollPage(KeyDesktopMoveCasesPage):
""" Why: productivity, top google properties """
def __init__(self, page_set):
super(GmailMouseScrollPage, self).__init__(
url='https://mail.google.com/mail/',
page_set=page_set)
self.scrollable_element_function = '''
function(callback) {
gmonkey.load('2.0', function(api) {
callback(api.getScrollableElement());
});
}'''
self.credentials = 'google'
def RunNavigateSteps(self, action_runner):
super(GmailMouseScrollPage, self).RunNavigateSteps(action_runner)
action_runner.WaitForJavaScriptCondition(
'window.gmonkey !== undefined &&'
'document.getElementById("gb") !== null')
# This check is needed for gmonkey to load completely.
action_runner.WaitForJavaScriptCondition(
'document.readyState == "complete"')
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')
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 _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).
# Calculating the mid point of start of scrollbar.
scrollbar_height_ratio = viewport_height / content_height
scrollbar_start_mid_y = scrollbar_height_ratio / 2
scrollbar_width_ratio = scrollbar_width / viewport_width
scrollbar_mid_x_right_offset = scrollbar_width_ratio / 2
scrollbar_mid_x = 1 - scrollbar_mid_x_right_offset
# The End point of scrollbar (x remains same).
scrollbar_end_mid_y = 1 - scrollbar_start_mid_y
return scrollbar_mid_x, scrollbar_start_mid_y, scrollbar_end_mid_y
class GoogleMapsPage(KeyDesktopMoveCasesPage):
""" Why: productivity, top google properties; Supports drag gesturee """
def __init__(self, page_set):
super(GoogleMapsPage, self).__init__(
url='https://www.google.co.uk/maps/@51.5043968,-0.1526806',
page_set=page_set,
name='Maps')
def RunNavigateSteps(self, action_runner):
super(GoogleMapsPage, self).RunNavigateSteps(action_runner)
action_runner.WaitForElement(selector='.widget-scene-canvas')
action_runner.WaitForElement(selector='.widget-zoom-in')
action_runner.WaitForElement(selector='.widget-zoom-out')
def RunPageInteractions(self, action_runner):
for _ in range(3):
action_runner.Wait(2)
interaction = action_runner.BeginGestureInteraction(
'DragAction', repeatable=True)
action_runner.DragPage(left_start_ratio=0.5, top_start_ratio=0.75,
left_end_ratio=0.75, top_end_ratio=0.5)
interaction.End()
# TODO(ssid): Add zoom gestures after fixing bug crbug.com/462214.
class KeyDesktopMoveCasesPageSet(page_set_module.PageSet):
""" Special cases for move gesture """
def __init__(self):
super(KeyDesktopMoveCasesPageSet, self).__init__(
archive_data_file='data/key_desktop_move_cases.json',
bucket=page_set_module.PARTNER_BUCKET)
self.AddUserStory(GmailMouseScrollPage(self))
self.AddUserStory(GoogleMapsPage(self))
...@@ -54,50 +54,6 @@ class GmailPage(TopPages): ...@@ -54,50 +54,6 @@ class GmailPage(TopPages):
action_runner.WaitForJavaScriptCondition( action_runner.WaitForJavaScriptCondition(
'window.gmonkey !== undefined &&' 'window.gmonkey !== undefined &&'
'document.getElementById("gb") !== null') 'document.getElementById("gb") !== null')
# This check is needed for gmonkey to load completely.
action_runner.WaitForJavaScriptCondition(
'document.readyState == "complete"')
class GmailMouseScrollPage(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')
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 _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 GoogleCalendarPage(TopPages): class GoogleCalendarPage(TopPages):
...@@ -142,21 +98,6 @@ class GoogleDocPage(TopPages): ...@@ -142,21 +98,6 @@ class GoogleDocPage(TopPages):
action_runner.WaitForJavaScriptCondition( action_runner.WaitForJavaScriptCondition(
'document.getElementsByClassName("kix-appview-editor").length') 'document.getElementsByClassName("kix-appview-editor").length')
class GoogleMapsPage(TopPages):
""" Why: productivity, top google properties; Supports drag gesturee """
def __init__(self, page_set):
super(GoogleMapsPage, self).__init__(
url='https://www.google.co.uk/maps/@51.5043968,-0.1526806',
page_set=page_set,
name='Maps')
def RunNavigateSteps(self, action_runner):
super(GoogleMapsPage, self).RunNavigateSteps(action_runner)
action_runner.WaitForElement(selector='.widget-scene-canvas')
action_runner.WaitForElement(selector='.widget-zoom-in')
action_runner.WaitForElement(selector='.widget-zoom-out')
class GooglePlusPage(TopPages): class GooglePlusPage(TopPages):
......
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