Disable flaky AnimatedContentSamplerParameterizedTest.FrameTimestampsConvergeTowardsE...
[chromium-blink-merge.git] / tools / perf / page_sets / top_7_stress.py
blob79da3bed84a186ba6557e78b3d8a267f7f69512c
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_7_stress.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 super(GoogleWebSearchPage, self).RunNavigateSteps(action_runner)
41 action_runner.WaitForElement(text='Next')
43 def RunPageInteractions(self, action_runner):
44 with action_runner.CreateGestureInteraction('ScrollAction'):
45 action_runner.ScrollPage()
46 old_href = _GetCurrentLocation(action_runner)
47 action_runner.ClickElement(text='Next')
48 _WaitForLocationChange(action_runner, old_href)
49 action_runner.WaitForElement(text='Next')
50 with action_runner.CreateGestureInteraction('ScrollAction'):
51 action_runner.ScrollPage()
52 old_href = _GetCurrentLocation(action_runner)
53 action_runner.ClickElement(text='Next')
54 _WaitForLocationChange(action_runner, old_href)
55 action_runner.WaitForElement(text='Next')
56 with action_runner.CreateGestureInteraction('ScrollAction'):
57 action_runner.ScrollPage()
58 old_href = _GetCurrentLocation(action_runner)
59 action_runner.ClickElement(text='Next')
60 _WaitForLocationChange(action_runner, old_href)
61 action_runner.WaitForElement(text='Previous')
62 with action_runner.CreateGestureInteraction('ScrollAction'):
63 action_runner.ScrollPage()
64 old_href = _GetCurrentLocation(action_runner)
65 action_runner.ClickElement(text='Previous')
66 _WaitForLocationChange(action_runner, old_href)
67 action_runner.WaitForElement(text='Previous')
68 with action_runner.CreateGestureInteraction('ScrollAction'):
69 action_runner.ScrollPage()
70 old_href = _GetCurrentLocation(action_runner)
71 action_runner.ClickElement(text='Previous')
72 _WaitForLocationChange(action_runner, old_href)
73 action_runner.WaitForElement(text='Previous')
74 with action_runner.CreateGestureInteraction('ScrollAction'):
75 action_runner.ScrollPage()
76 old_href = _GetCurrentLocation(action_runner)
77 action_runner.ClickElement(text='Previous')
78 _WaitForLocationChange(action_runner, old_href)
79 action_runner.WaitForElement(text='Images')
80 with action_runner.CreateGestureInteraction('ScrollAction'):
81 action_runner.ScrollPage()
82 old_href = _GetCurrentLocation(action_runner)
83 action_runner.ClickElement(text='Images')
84 _WaitForLocationChange(action_runner, old_href)
85 action_runner.WaitForElement(text='Images')
88 class GmailPage(Top7StressPage):
90 """ Why: productivity, top google properties """
92 def __init__(self, page_set):
93 super(GmailPage, self).__init__(
94 url='https://mail.google.com/mail/',
95 page_set=page_set)
97 self.credentials = 'google'
99 def RunNavigateSteps(self, action_runner):
100 super(GmailPage, self).RunNavigateSteps(action_runner)
101 action_runner.WaitForJavaScriptCondition(
102 'window.gmonkey !== undefined &&'
103 'document.getElementById("gb") !== null')
105 def RunPageInteractions(self, action_runner):
106 old_href = _GetCurrentLocation(action_runner)
107 action_runner.ClickElement(
108 'a[href="https://mail.google.com/mail/u/0/?shva=1#starred"]')
109 _WaitForLocationChange(action_runner, old_href)
110 old_href = _GetCurrentLocation(action_runner)
111 action_runner.ClickElement(
112 'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]')
113 _WaitForLocationChange(action_runner, old_href)
116 class GoogleCalendarPage(Top7StressPage):
118 """ Why: productivity, top google properties """
120 def __init__(self, page_set):
121 super(GoogleCalendarPage, self).__init__(
122 url='https://www.google.com/calendar/',
123 page_set=page_set)
125 self.credentials = 'google'
127 def RunNavigateSteps(self, action_runner):
128 super(GoogleCalendarPage, self).RunNavigateSteps(action_runner)
129 action_runner.Wait(2)
130 action_runner.WaitForElement('div[class~="navForward"]')
131 action_runner.ExecuteJavaScript('''
132 (function() {
133 var elem = document.createElement('meta');
134 elem.name='viewport';
135 elem.content='initial-scale=1';
136 document.body.appendChild(elem);
137 })();''')
138 action_runner.Wait(1)
140 def RunPageInteractions(self, action_runner):
141 action_runner.ClickElement('div[class~="navForward"]')
142 action_runner.Wait(2)
143 action_runner.WaitForElement('div[class~="navForward"]')
144 action_runner.ClickElement('div[class~="navForward"]')
145 action_runner.Wait(2)
146 action_runner.WaitForElement('div[class~="navForward"]')
147 action_runner.ClickElement('div[class~="navForward"]')
148 action_runner.Wait(2)
149 action_runner.WaitForElement('div[class~="navForward"]')
150 action_runner.ClickElement('div[class~="navForward"]')
151 action_runner.Wait(2)
152 action_runner.WaitForElement('div[class~="navBack"]')
153 action_runner.ClickElement('div[class~="navBack"]')
154 action_runner.Wait(2)
155 action_runner.WaitForElement('div[class~="navBack"]')
156 action_runner.ClickElement('div[class~="navBack"]')
157 action_runner.Wait(2)
158 action_runner.WaitForElement('div[class~="navBack"]')
159 action_runner.ClickElement('div[class~="navBack"]')
160 action_runner.Wait(2)
161 action_runner.WaitForElement('div[class~="navBack"]')
162 action_runner.ClickElement('div[class~="navBack"]')
163 action_runner.Wait(2)
164 action_runner.WaitForElement('div[class~="navBack"]')
167 class GooglePlusPage(Top7StressPage):
169 """ Why: social; top google property; Public profile; infinite scrolls """
171 def __init__(self, page_set):
172 super(GooglePlusPage, self).__init__(
173 url='https://plus.google.com/110031535020051778989/posts',
174 page_set=page_set)
176 self.credentials = 'google'
178 def RunNavigateSteps(self, action_runner):
179 super(GooglePlusPage, self).RunNavigateSteps(action_runner)
180 action_runner.WaitForElement(text='Home')
182 def RunPageInteractions(self, action_runner):
183 action_runner.ClickElement(text='Home')
184 action_runner.Wait(2)
185 action_runner.WaitForElement(text='Profile')
186 action_runner.ClickElement(text='Profile')
187 action_runner.Wait(2)
188 action_runner.WaitForElement(text='Explore')
189 action_runner.ClickElement(text='Explore')
190 action_runner.Wait(2)
191 action_runner.WaitForElement(text='Events')
192 action_runner.ClickElement(text='Events')
193 action_runner.Wait(2)
194 action_runner.WaitForElement(text='Communities')
195 action_runner.ClickElement(text='Communities')
196 action_runner.Wait(2)
197 action_runner.WaitForElement(text='Home')
200 class BlogspotPage(Top7StressPage):
202 """ Why: #11 (Alexa global), google property; some blogger layouts have
203 infinite scroll but more interesting """
205 def __init__(self, page_set):
206 super(BlogspotPage, self).__init__(
207 url='http://googlewebmastercentral.blogspot.com/',
208 page_set=page_set,
209 name='Blogger')
211 def RunNavigateSteps(self, action_runner):
212 super(BlogspotPage, self).RunNavigateSteps(action_runner)
213 action_runner.WaitForElement(text='accessibility')
215 def RunPageInteractions(self, action_runner):
216 action_runner.ClickElement(text='accessibility')
217 action_runner.WaitForNavigate()
218 with action_runner.CreateGestureInteraction('ScrollAction'):
219 action_runner.ScrollPage()
220 # Insert 300ms wait to simulate user finger movement,
221 # and ensure scheduling of idle tasks.
222 action_runner.Wait(0.3)
223 action_runner.ClickElement(text='advanced')
224 action_runner.WaitForNavigate()
225 with action_runner.CreateGestureInteraction('ScrollAction'):
226 action_runner.ScrollPage()
227 action_runner.Wait(0.3)
228 action_runner.ClickElement(text='beginner')
229 action_runner.WaitForNavigate()
230 with action_runner.CreateGestureInteraction('ScrollAction'):
231 action_runner.ScrollPage()
232 action_runner.Wait(0.3)
233 action_runner.ClickElement(text='Home')
234 action_runner.WaitForNavigate()
237 class WordpressPage(Top7StressPage):
239 """ Why: #18 (Alexa global), Picked an interesting post """
241 def __init__(self, page_set):
242 super(WordpressPage, self).__init__(
243 # pylint: disable=C0301
244 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
245 page_set=page_set,
246 name='Wordpress')
248 def RunNavigateSteps(self, action_runner):
249 super(WordpressPage, self).RunNavigateSteps(action_runner)
250 action_runner.WaitForElement(
251 # pylint: disable=C0301
252 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/"]')
254 def RunPageInteractions(self, action_runner):
255 with action_runner.CreateGestureInteraction('ScrollAction'):
256 action_runner.ScrollPage()
257 # Insert 300ms wait to simulate user finger movement,
258 # and ensure scheduling of idle tasks.
259 action_runner.Wait(0.3)
260 action_runner.ClickElement(
261 # pylint: disable=C0301
262 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/"]')
263 action_runner.WaitForNavigate()
264 with action_runner.CreateGestureInteraction('ScrollAction'):
265 action_runner.ScrollPage()
266 action_runner.Wait(0.3)
267 action_runner.ClickElement(text='Features')
268 action_runner.WaitForNavigate()
269 with action_runner.CreateGestureInteraction('ScrollAction'):
270 action_runner.ScrollPage()
271 action_runner.Wait(0.3)
272 action_runner.ClickElement(text='News')
273 action_runner.WaitForNavigate()
274 with action_runner.CreateGestureInteraction('ScrollAction'):
275 action_runner.ScrollPage()
278 class FacebookPage(Top7StressPage):
280 """ Why: top social,Public profile """
282 def __init__(self, page_set):
283 super(FacebookPage, self).__init__(
284 url='https://www.facebook.com/barackobama',
285 page_set=page_set,
286 name='Facebook')
287 self.credentials = 'facebook2'
289 def RunNavigateSteps(self, action_runner):
290 super(FacebookPage, self).RunNavigateSteps(action_runner)
291 action_runner.WaitForElement(text='About')
293 def RunPageInteractions(self, action_runner):
294 # Scroll and wait for the next page to be loaded.
295 with action_runner.CreateGestureInteraction('ScrollAction'):
296 action_runner.ScrollPage()
297 action_runner.WaitForJavaScriptCondition(
298 'document.documentElement.scrollHeight - window.innerHeight - '
299 'window.pageYOffset > 0')
301 # Scroll and wait again.
302 with action_runner.CreateGestureInteraction('ScrollAction'):
303 action_runner.ScrollPage()
304 action_runner.WaitForJavaScriptCondition(
305 'document.documentElement.scrollHeight - window.innerHeight - '
306 'window.pageYOffset > 0')
308 class Top7StressPageSet(page_set_module.PageSet):
310 """ Pages hand-picked for stress testing. """
312 def __init__(self):
313 super(Top7StressPageSet, self).__init__(
314 user_agent_type='desktop',
315 archive_data_file='data/top_7_stress.json',
316 bucket=page_set_module.PARTNER_BUCKET)
318 self.AddUserStory(GoogleWebSearchPage(self))
319 self.AddUserStory(GmailPage(self))
320 self.AddUserStory(GoogleCalendarPage(self))
321 self.AddUserStory(GooglePlusPage(self))
322 self.AddUserStory(BlogspotPage(self))
323 self.AddUserStory(WordpressPage(self))
324 self.AddUserStory(FacebookPage(self))