Plumb scroll elasticity layer from Blink to cc
[chromium-blink-merge.git] / tools / perf / page_sets / top_7_stress.py
blobae18deb237666ac08795c3b36533001b23d660a8
1 # Copyright 2014 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
8 def _GetCurrentLocation(action_runner):
9 return action_runner.EvaluateJavaScript('document.location.href')
12 def _WaitForLocationChange(action_runner, old_href):
13 action_runner.WaitForJavaScriptCondition(
14 'document.location.href != "%s"' % old_href)
17 class Top7StressPage(page_module.Page):
19 def __init__(self, url, page_set, name=''):
20 super(Top7StressPage, self).__init__(
21 url=url, page_set=page_set, name=name,
22 credentials_path = 'data/credentials.json')
23 self.user_agent_type = 'desktop'
24 self.archive_data_file = 'data/top_25.json'
26 def RunPageInteractions(self, action_runner):
27 raise NotImplementedError()
30 class GoogleWebSearchPage(Top7StressPage):
32 """ Why: top google property; a google tab is often open """
34 def __init__(self, page_set):
35 super(GoogleWebSearchPage, self).__init__(
36 url='https://www.google.com/#hl=en&q=barack+obama',
37 page_set=page_set)
39 def RunNavigateSteps(self, action_runner):
40 action_runner.NavigateToPage(self)
41 action_runner.WaitForElement(text='Next')
43 def RunPageInteractions(self, action_runner):
44 interaction = action_runner.BeginGestureInteraction(
45 'ScrollAction', is_smooth=True)
46 action_runner.ScrollPage()
47 interaction.End()
48 old_href = _GetCurrentLocation(action_runner)
49 action_runner.ClickElement(text='Next')
50 _WaitForLocationChange(action_runner, old_href)
51 action_runner.WaitForElement(text='Next')
52 interaction = action_runner.BeginGestureInteraction(
53 'ScrollAction', is_smooth=True)
54 action_runner.ScrollPage()
55 interaction.End()
56 old_href = _GetCurrentLocation(action_runner)
57 action_runner.ClickElement(text='Next')
58 _WaitForLocationChange(action_runner, old_href)
59 action_runner.WaitForElement(text='Next')
60 interaction = action_runner.BeginGestureInteraction(
61 'ScrollAction', is_smooth=True)
62 action_runner.ScrollPage()
63 interaction.End()
64 old_href = _GetCurrentLocation(action_runner)
65 action_runner.ClickElement(text='Next')
66 _WaitForLocationChange(action_runner, old_href)
67 action_runner.WaitForElement(text='Previous')
68 interaction = action_runner.BeginGestureInteraction(
69 'ScrollAction', is_smooth=True)
70 action_runner.ScrollPage()
71 interaction.End()
72 old_href = _GetCurrentLocation(action_runner)
73 action_runner.ClickElement(text='Previous')
74 _WaitForLocationChange(action_runner, old_href)
75 action_runner.WaitForElement(text='Previous')
76 interaction = action_runner.BeginGestureInteraction(
77 'ScrollAction', is_smooth=True)
78 action_runner.ScrollPage()
79 interaction.End()
80 old_href = _GetCurrentLocation(action_runner)
81 action_runner.ClickElement(text='Previous')
82 _WaitForLocationChange(action_runner, old_href)
83 action_runner.WaitForElement(text='Previous')
84 interaction = action_runner.BeginGestureInteraction(
85 'ScrollAction', is_smooth=True)
86 action_runner.ScrollPage()
87 interaction.End()
88 old_href = _GetCurrentLocation(action_runner)
89 action_runner.ClickElement(text='Previous')
90 _WaitForLocationChange(action_runner, old_href)
91 action_runner.WaitForElement(text='Images')
92 interaction = action_runner.BeginGestureInteraction(
93 'ScrollAction', is_smooth=True)
94 action_runner.ScrollPage()
95 interaction.End()
96 old_href = _GetCurrentLocation(action_runner)
97 action_runner.ClickElement(text='Images')
98 _WaitForLocationChange(action_runner, old_href)
99 action_runner.WaitForElement(text='Images')
102 class GmailPage(Top7StressPage):
104 """ Why: productivity, top google properties """
106 def __init__(self, page_set):
107 super(GmailPage, self).__init__(
108 url='https://mail.google.com/mail/',
109 page_set=page_set)
111 self.credentials = 'google'
113 def RunNavigateSteps(self, action_runner):
114 action_runner.NavigateToPage(self)
115 action_runner.WaitForJavaScriptCondition(
116 'window.gmonkey !== undefined &&'
117 'document.getElementById("gb") !== null')
119 def RunPageInteractions(self, action_runner):
120 old_href = _GetCurrentLocation(action_runner)
121 action_runner.ClickElement(
122 'a[href="https://mail.google.com/mail/u/0/?shva=1#starred"]')
123 _WaitForLocationChange(action_runner, old_href)
124 old_href = _GetCurrentLocation(action_runner)
125 action_runner.ClickElement(
126 'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]')
127 _WaitForLocationChange(action_runner, old_href)
130 class GoogleCalendarPage(Top7StressPage):
132 """ Why: productivity, top google properties """
134 def __init__(self, page_set):
135 super(GoogleCalendarPage, self).__init__(
136 url='https://www.google.com/calendar/',
137 page_set=page_set)
139 self.credentials = 'google'
141 def RunNavigateSteps(self, action_runner):
142 action_runner.NavigateToPage(self)
143 action_runner.Wait(2)
144 action_runner.WaitForElement('div[class~="navForward"]')
145 action_runner.ExecuteJavaScript('''
146 (function() {
147 var elem = document.createElement('meta');
148 elem.name='viewport';
149 elem.content='initial-scale=1';
150 document.body.appendChild(elem);
151 })();''')
152 action_runner.Wait(1)
154 def RunPageInteractions(self, action_runner):
155 action_runner.ClickElement('div[class~="navForward"]')
156 action_runner.Wait(2)
157 action_runner.WaitForElement('div[class~="navForward"]')
158 action_runner.ClickElement('div[class~="navForward"]')
159 action_runner.Wait(2)
160 action_runner.WaitForElement('div[class~="navForward"]')
161 action_runner.ClickElement('div[class~="navForward"]')
162 action_runner.Wait(2)
163 action_runner.WaitForElement('div[class~="navForward"]')
164 action_runner.ClickElement('div[class~="navForward"]')
165 action_runner.Wait(2)
166 action_runner.WaitForElement('div[class~="navBack"]')
167 action_runner.ClickElement('div[class~="navBack"]')
168 action_runner.Wait(2)
169 action_runner.WaitForElement('div[class~="navBack"]')
170 action_runner.ClickElement('div[class~="navBack"]')
171 action_runner.Wait(2)
172 action_runner.WaitForElement('div[class~="navBack"]')
173 action_runner.ClickElement('div[class~="navBack"]')
174 action_runner.Wait(2)
175 action_runner.WaitForElement('div[class~="navBack"]')
176 action_runner.ClickElement('div[class~="navBack"]')
177 action_runner.Wait(2)
178 action_runner.WaitForElement('div[class~="navBack"]')
181 class GooglePlusPage(Top7StressPage):
183 """ Why: social; top google property; Public profile; infinite scrolls """
185 def __init__(self, page_set):
186 super(GooglePlusPage, self).__init__(
187 url='https://plus.google.com/110031535020051778989/posts',
188 page_set=page_set)
190 self.credentials = 'google'
192 def RunNavigateSteps(self, action_runner):
193 action_runner.NavigateToPage(self)
194 action_runner.WaitForElement(text='Home')
196 def RunPageInteractions(self, action_runner):
197 action_runner.ClickElement(text='Home')
198 action_runner.Wait(2)
199 action_runner.WaitForElement(text='Profile')
200 action_runner.ClickElement(text='Profile')
201 action_runner.Wait(2)
202 action_runner.WaitForElement(text='Explore')
203 action_runner.ClickElement(text='Explore')
204 action_runner.Wait(2)
205 action_runner.WaitForElement(text='Events')
206 action_runner.ClickElement(text='Events')
207 action_runner.Wait(2)
208 action_runner.WaitForElement(text='Communities')
209 action_runner.ClickElement(text='Communities')
210 action_runner.Wait(2)
211 action_runner.WaitForElement(text='Home')
214 class BlogspotPage(Top7StressPage):
216 """ Why: #11 (Alexa global), google property; some blogger layouts have
217 infinite scroll but more interesting """
219 def __init__(self, page_set):
220 super(BlogspotPage, self).__init__(
221 url='http://googlewebmastercentral.blogspot.com/',
222 page_set=page_set,
223 name='Blogger')
225 def RunNavigateSteps(self, action_runner):
226 action_runner.NavigateToPage(self)
227 action_runner.WaitForElement(text='accessibility')
229 def RunPageInteractions(self, action_runner):
230 action_runner.ClickElement(text='accessibility')
231 action_runner.WaitForNavigate()
232 interaction = action_runner.BeginGestureInteraction(
233 'ScrollAction', is_smooth=True)
234 action_runner.ScrollPage()
235 interaction.End()
236 action_runner.ClickElement(text='advanced')
237 action_runner.WaitForNavigate()
238 interaction = action_runner.BeginGestureInteraction(
239 'ScrollAction', is_smooth=True)
240 action_runner.ScrollPage()
241 interaction.End()
242 action_runner.ClickElement(text='beginner')
243 action_runner.WaitForNavigate()
244 interaction = action_runner.BeginGestureInteraction(
245 'ScrollAction', is_smooth=True)
246 action_runner.ScrollPage()
247 interaction.End()
248 action_runner.ClickElement(text='Home')
249 action_runner.WaitForNavigate()
252 class WordpressPage(Top7StressPage):
254 """ Why: #18 (Alexa global), Picked an interesting post """
256 def __init__(self, page_set):
257 super(WordpressPage, self).__init__(
258 # pylint: disable=C0301
259 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
260 page_set=page_set,
261 name='Wordpress')
263 def RunNavigateSteps(self, action_runner):
264 action_runner.NavigateToPage(self)
265 action_runner.WaitForElement(
266 # pylint: disable=C0301
267 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/"]')
269 def RunPageInteractions(self, action_runner):
270 interaction = action_runner.BeginGestureInteraction(
271 'ScrollAction', is_smooth=True)
272 action_runner.ScrollPage()
273 interaction.End()
274 action_runner.ClickElement(
275 # pylint: disable=C0301
276 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/"]')
277 action_runner.WaitForNavigate()
278 interaction = action_runner.BeginGestureInteraction(
279 'ScrollAction', is_smooth=True)
280 action_runner.ScrollPage()
281 interaction.End()
282 action_runner.ClickElement(text='Features')
283 action_runner.WaitForNavigate()
284 interaction = action_runner.BeginGestureInteraction(
285 'ScrollAction', is_smooth=True)
286 action_runner.ScrollPage()
287 interaction.End()
288 action_runner.ClickElement(text='News')
289 action_runner.WaitForNavigate()
290 interaction = action_runner.BeginGestureInteraction(
291 'ScrollAction', is_smooth=True)
292 action_runner.ScrollPage()
293 interaction.End()
296 class FacebookPage(Top7StressPage):
298 """ Why: top social,Public profile """
300 def __init__(self, page_set):
301 super(FacebookPage, self).__init__(
302 url='http://www.facebook.com/barackobama',
303 page_set=page_set,
304 name='Facebook')
305 self.credentials = 'facebook'
307 def RunNavigateSteps(self, action_runner):
308 action_runner.NavigateToPage(self)
309 action_runner.WaitForElement(text='About')
311 def RunPageInteractions(self, action_runner):
312 action_runner.ClickElement(text='About')
313 action_runner.WaitForNavigate()
314 action_runner.ClickElement(text='The Audacity of Hope')
315 action_runner.WaitForNavigate()
316 action_runner.ClickElement(text='Back to Barack Obama\'s Timeline')
317 action_runner.WaitForNavigate()
318 action_runner.ClickElement(text='About')
319 action_runner.WaitForNavigate()
320 action_runner.ClickElement(text='Elected to U.S. Senate')
321 action_runner.WaitForNavigate()
322 action_runner.ClickElement(text='Home')
323 action_runner.WaitForNavigate()
326 class Top7StressPageSet(page_set_module.PageSet):
328 """ Pages hand-picked for stress testing. """
330 def __init__(self):
331 super(Top7StressPageSet, self).__init__(
332 user_agent_type='desktop',
333 archive_data_file='data/top_25.json',
334 bucket=page_set_module.PARTNER_BUCKET)
336 self.AddPage(GoogleWebSearchPage(self))
337 self.AddPage(GmailPage(self))
338 self.AddPage(GoogleCalendarPage(self))
339 self.AddPage(GooglePlusPage(self))
340 self.AddPage(BlogspotPage(self))
341 self.AddPage(WordpressPage(self))
342 self.AddPage(FacebookPage(self))