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

Side by Side Diff: tools/perf/page_sets/key_desktop_move_cases.py

Issue 1037483004: Telemetry benchmark key_desktop_move_pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments. Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « tools/perf/page_sets/data/top_25_smooth.json ('k') | tools/perf/page_sets/top_pages.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 from telemetry.page import page as page_module
5 from telemetry.page import page_set as page_set_module
6
7
8 class KeyDesktopMoveCasesPage(page_module.Page):
9
10 def __init__(self, url, page_set, name='', credentials=None):
11 super(KeyDesktopMoveCasesPage, self).__init__(
12 url=url, page_set=page_set, name=name,
13 credentials_path='data/credentials.json')
14 self.archive_data_file = 'data/key_desktop_move_cases.json'
15 self.user_agent_type = 'desktop'
16 self.credentials = credentials
17
18
19 class GmailMouseScrollPage(KeyDesktopMoveCasesPage):
20
21 """ Why: productivity, top google properties """
22
23 def __init__(self, page_set):
24 super(GmailMouseScrollPage, self).__init__(
25 url='https://mail.google.com/mail/',
26 page_set=page_set)
27
28 self.scrollable_element_function = '''
29 function(callback) {
30 gmonkey.load('2.0', function(api) {
31 callback(api.getScrollableElement());
32 });
33 }'''
34 self.credentials = 'google'
35
36 def RunNavigateSteps(self, action_runner):
37 super(GmailMouseScrollPage, self).RunNavigateSteps(action_runner)
38 action_runner.WaitForJavaScriptCondition(
39 'window.gmonkey !== undefined &&'
40 'document.getElementById("gb") !== null')
41 # This check is needed for gmonkey to load completely.
42 action_runner.WaitForJavaScriptCondition(
43 'document.readyState == "complete"')
44
45 def RunPageInteractions(self, action_runner):
46 action_runner.ExecuteJavaScript('''
47 gmonkey.load('2.0', function(api) {
48 window.__scrollableElementForTelemetry = api.getScrollableElement();
49 });''')
50 action_runner.WaitForJavaScriptCondition(
51 'window.__scrollableElementForTelemetry != null')
52 scrollbar_x, start_y, end_y = self._CalculateScrollBarRatios(action_runner)
53
54 interaction = action_runner.BeginGestureInteraction(
55 'DragAction')
56 action_runner.DragPage(left_start_ratio=scrollbar_x,
57 top_start_ratio=start_y, left_end_ratio=scrollbar_x,
58 top_end_ratio=end_y, speed_in_pixels_per_second=100,
59 element_function='window.__scrollableElementForTelemetry')
60 interaction.End()
61
62 def _CalculateScrollBarRatios(self, action_runner):
63 viewport_height = float(action_runner.EvaluateJavaScript(
64 'window.__scrollableElementForTelemetry.clientHeight'))
65 content_height = float(action_runner.EvaluateJavaScript(
66 'window.__scrollableElementForTelemetry.scrollHeight'))
67 viewport_width = float(action_runner.EvaluateJavaScript(
68 'window.__scrollableElementForTelemetry.offsetWidth'))
69 scrollbar_width = float(action_runner.EvaluateJavaScript('''
70 window.__scrollableElementForTelemetry.offsetWidth -
71 window.__scrollableElementForTelemetry.scrollWidth'''))
72
73 # This calculation is correct only when the element doesn't have border or
74 # padding or scroll buttons (eg: gmail mail element).
75 # Calculating the mid point of start of scrollbar.
76 scrollbar_height_ratio = viewport_height / content_height
77 scrollbar_start_mid_y = scrollbar_height_ratio / 2
78 scrollbar_width_ratio = scrollbar_width / viewport_width
79 scrollbar_mid_x_right_offset = scrollbar_width_ratio / 2
80 scrollbar_mid_x = 1 - scrollbar_mid_x_right_offset
81
82 # The End point of scrollbar (x remains same).
83 scrollbar_end_mid_y = 1 - scrollbar_start_mid_y
84 return scrollbar_mid_x, scrollbar_start_mid_y, scrollbar_end_mid_y
85
86
87 class GoogleMapsPage(KeyDesktopMoveCasesPage):
88
89 """ Why: productivity, top google properties; Supports drag gesturee """
90
91 def __init__(self, page_set):
92 super(GoogleMapsPage, self).__init__(
93 url='https://www.google.co.uk/maps/@51.5043968,-0.1526806',
94 page_set=page_set,
95 name='Maps')
96
97 def RunNavigateSteps(self, action_runner):
98 super(GoogleMapsPage, self).RunNavigateSteps(action_runner)
99 action_runner.WaitForElement(selector='.widget-scene-canvas')
100 action_runner.WaitForElement(selector='.widget-zoom-in')
101 action_runner.WaitForElement(selector='.widget-zoom-out')
102
103 def RunPageInteractions(self, action_runner):
104 for _ in range(3):
105 action_runner.Wait(2)
106 interaction = action_runner.BeginGestureInteraction(
107 'DragAction', repeatable=True)
108 action_runner.DragPage(left_start_ratio=0.5, top_start_ratio=0.75,
109 left_end_ratio=0.75, top_end_ratio=0.5)
110 interaction.End()
111 # TODO(ssid): Add zoom gestures after fixing bug crbug.com/462214.
112
113
114 class KeyDesktopMoveCasesPageSet(page_set_module.PageSet):
115
116 """ Special cases for move gesture """
117
118 def __init__(self):
119 super(KeyDesktopMoveCasesPageSet, self).__init__(
120 archive_data_file='data/key_desktop_move_cases.json',
121 bucket=page_set_module.PARTNER_BUCKET)
122
123 self.AddUserStory(GmailMouseScrollPage(self))
124 self.AddUserStory(GoogleMapsPage(self))
OLDNEW
« no previous file with comments | « tools/perf/page_sets/data/top_25_smooth.json ('k') | tools/perf/page_sets/top_pages.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698