[Android WebViewShell] Add inclusion test for webview exposed stable interfaces.
[chromium-blink-merge.git] / tools / perf / page_sets / top_7_stress.py
blob706fc2c7246b85179098cd6dd6a6930b961979ce
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 shared_page_state
6 from telemetry import story
9 def _GetCurrentLocation(action_runner):
10 return action_runner.EvaluateJavaScript('document.location.href')
13 def _WaitForLocationChange(action_runner, old_href):
14 action_runner.WaitForJavaScriptCondition(
15 'document.location.href != "%s"' % old_href)
18 class Top7StressPage(page_module.Page):
20 def __init__(self, url, page_set, name=''):
21 super(Top7StressPage, self).__init__(
22 url=url, page_set=page_set, name=name,
23 shared_page_state_class=shared_page_state.SharedDesktopPageState,
24 credentials_path = 'data/credentials.json')
25 self.archive_data_file = 'data/top_7_stress.json'
27 def RunPageInteractions(self, action_runner):
28 raise NotImplementedError()
31 class GoogleWebSearchPage(Top7StressPage):
33 """ Why: top google property; a google tab is often open """
35 def __init__(self, page_set):
36 super(GoogleWebSearchPage, self).__init__(
37 url='https://www.google.com/#hl=en&q=barack+obama',
38 page_set=page_set)
40 def RunNavigateSteps(self, action_runner):
41 super(GoogleWebSearchPage, self).RunNavigateSteps(action_runner)
42 action_runner.WaitForElement(text='Next')
44 def RunPageInteractions(self, action_runner):
45 with action_runner.CreateGestureInteraction('ScrollAction'):
46 action_runner.ScrollPage()
47 old_href = _GetCurrentLocation(action_runner)
48 action_runner.ClickElement(text='Next')
49 _WaitForLocationChange(action_runner, old_href)
50 action_runner.WaitForElement(text='Next')
51 with action_runner.CreateGestureInteraction('ScrollAction'):
52 action_runner.ScrollPage()
53 old_href = _GetCurrentLocation(action_runner)
54 action_runner.ClickElement(text='Next')
55 _WaitForLocationChange(action_runner, old_href)
56 action_runner.WaitForElement(text='Next')
57 with action_runner.CreateGestureInteraction('ScrollAction'):
58 action_runner.ScrollPage()
59 old_href = _GetCurrentLocation(action_runner)
60 action_runner.ClickElement(text='Next')
61 _WaitForLocationChange(action_runner, old_href)
62 action_runner.WaitForElement(text='Previous')
63 with action_runner.CreateGestureInteraction('ScrollAction'):
64 action_runner.ScrollPage()
65 old_href = _GetCurrentLocation(action_runner)
66 action_runner.ClickElement(text='Previous')
67 _WaitForLocationChange(action_runner, old_href)
68 action_runner.WaitForElement(text='Previous')
69 with action_runner.CreateGestureInteraction('ScrollAction'):
70 action_runner.ScrollPage()
71 old_href = _GetCurrentLocation(action_runner)
72 action_runner.ClickElement(text='Previous')
73 _WaitForLocationChange(action_runner, old_href)
74 action_runner.WaitForElement(text='Previous')
75 with action_runner.CreateGestureInteraction('ScrollAction'):
76 action_runner.ScrollPage()
77 old_href = _GetCurrentLocation(action_runner)
78 action_runner.ClickElement(text='Previous')
79 _WaitForLocationChange(action_runner, old_href)
80 action_runner.WaitForElement(text='Images')
81 with action_runner.CreateGestureInteraction('ScrollAction'):
82 action_runner.ScrollPage()
83 old_href = _GetCurrentLocation(action_runner)
84 action_runner.ClickElement(text='Images')
85 _WaitForLocationChange(action_runner, old_href)
86 action_runner.WaitForElement(text='Images')
89 class GmailPage(Top7StressPage):
91 """ Why: productivity, top google properties """
93 def __init__(self, page_set):
94 super(GmailPage, self).__init__(
95 url='https://mail.google.com/mail/',
96 page_set=page_set)
98 self.credentials = 'google'
100 def RunNavigateSteps(self, action_runner):
101 super(GmailPage, self).RunNavigateSteps(action_runner)
102 action_runner.WaitForJavaScriptCondition(
103 'window.gmonkey !== undefined &&'
104 'document.getElementById("gb") !== null')
106 def RunPageInteractions(self, action_runner):
107 old_href = _GetCurrentLocation(action_runner)
108 action_runner.ClickElement(
109 'a[href="https://mail.google.com/mail/u/0/?shva=1#starred"]')
110 _WaitForLocationChange(action_runner, old_href)
111 old_href = _GetCurrentLocation(action_runner)
112 action_runner.ClickElement(
113 'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]')
114 _WaitForLocationChange(action_runner, old_href)
117 class GoogleCalendarPage(Top7StressPage):
119 """ Why: productivity, top google properties """
121 def __init__(self, page_set):
122 super(GoogleCalendarPage, self).__init__(
123 url='https://www.google.com/calendar/',
124 page_set=page_set)
126 self.credentials = 'google'
128 def RunNavigateSteps(self, action_runner):
129 super(GoogleCalendarPage, self).RunNavigateSteps(action_runner)
130 action_runner.Wait(2)
131 action_runner.WaitForElement('div[class~="navForward"]')
132 action_runner.ExecuteJavaScript('''
133 (function() {
134 var elem = document.createElement('meta');
135 elem.name='viewport';
136 elem.content='initial-scale=1';
137 document.body.appendChild(elem);
138 })();''')
139 action_runner.Wait(1)
141 def RunPageInteractions(self, action_runner):
142 action_runner.ClickElement('div[class~="navForward"]')
143 action_runner.Wait(2)
144 action_runner.WaitForElement('div[class~="navForward"]')
145 action_runner.ClickElement('div[class~="navForward"]')
146 action_runner.Wait(2)
147 action_runner.WaitForElement('div[class~="navForward"]')
148 action_runner.ClickElement('div[class~="navForward"]')
149 action_runner.Wait(2)
150 action_runner.WaitForElement('div[class~="navForward"]')
151 action_runner.ClickElement('div[class~="navForward"]')
152 action_runner.Wait(2)
153 action_runner.WaitForElement('div[class~="navBack"]')
154 action_runner.ClickElement('div[class~="navBack"]')
155 action_runner.Wait(2)
156 action_runner.WaitForElement('div[class~="navBack"]')
157 action_runner.ClickElement('div[class~="navBack"]')
158 action_runner.Wait(2)
159 action_runner.WaitForElement('div[class~="navBack"]')
160 action_runner.ClickElement('div[class~="navBack"]')
161 action_runner.Wait(2)
162 action_runner.WaitForElement('div[class~="navBack"]')
163 action_runner.ClickElement('div[class~="navBack"]')
164 action_runner.Wait(2)
165 action_runner.WaitForElement('div[class~="navBack"]')
168 class GooglePlusPage(Top7StressPage):
170 """ Why: social; top google property; Public profile; infinite scrolls """
172 def __init__(self, page_set):
173 super(GooglePlusPage, self).__init__(
174 url='https://plus.google.com/110031535020051778989/posts',
175 page_set=page_set)
177 self.credentials = 'google'
179 def RunNavigateSteps(self, action_runner):
180 super(GooglePlusPage, self).RunNavigateSteps(action_runner)
181 action_runner.WaitForElement(text='Home')
183 def RunPageInteractions(self, action_runner):
184 action_runner.ClickElement(text='Home')
185 action_runner.Wait(2)
186 action_runner.WaitForElement(text='Profile')
187 action_runner.ClickElement(text='Profile')
188 action_runner.Wait(2)
189 action_runner.WaitForElement(text='Explore')
190 action_runner.ClickElement(text='Explore')
191 action_runner.Wait(2)
192 action_runner.WaitForElement(text='Events')
193 action_runner.ClickElement(text='Events')
194 action_runner.Wait(2)
195 action_runner.WaitForElement(text='Communities')
196 action_runner.ClickElement(text='Communities')
197 action_runner.Wait(2)
198 action_runner.WaitForElement(text='Home')
201 class BlogspotPage(Top7StressPage):
203 """ Why: #11 (Alexa global), google property; some blogger layouts have
204 infinite scroll but more interesting """
206 def __init__(self, page_set):
207 super(BlogspotPage, self).__init__(
208 url='http://googlewebmastercentral.blogspot.com/',
209 page_set=page_set,
210 name='Blogger')
212 def RunNavigateSteps(self, action_runner):
213 super(BlogspotPage, self).RunNavigateSteps(action_runner)
214 action_runner.WaitForElement(text='accessibility')
216 def RunPageInteractions(self, action_runner):
217 action_runner.ClickElement(text='accessibility')
218 action_runner.WaitForNavigate()
219 with action_runner.CreateGestureInteraction('ScrollAction'):
220 action_runner.ScrollPage()
221 # Insert 300ms wait to simulate user finger movement,
222 # and ensure scheduling of idle tasks.
223 action_runner.Wait(0.3)
224 action_runner.ClickElement(text='advanced')
225 action_runner.WaitForNavigate()
226 with action_runner.CreateGestureInteraction('ScrollAction'):
227 action_runner.ScrollPage()
228 action_runner.Wait(0.3)
229 action_runner.ClickElement(text='beginner')
230 action_runner.WaitForNavigate()
231 with action_runner.CreateGestureInteraction('ScrollAction'):
232 action_runner.ScrollPage()
233 action_runner.Wait(0.3)
234 action_runner.ClickElement(text='Home')
235 action_runner.WaitForNavigate()
238 class WordpressPage(Top7StressPage):
240 """ Why: #18 (Alexa global), Picked an interesting post """
242 def __init__(self, page_set):
243 super(WordpressPage, self).__init__(
244 # pylint: disable=C0301
245 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
246 page_set=page_set,
247 name='Wordpress')
249 def RunNavigateSteps(self, action_runner):
250 super(WordpressPage, self).RunNavigateSteps(action_runner)
251 action_runner.WaitForElement(
252 # pylint: disable=C0301
253 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/"]')
255 def RunPageInteractions(self, action_runner):
256 with action_runner.CreateGestureInteraction('ScrollAction'):
257 action_runner.ScrollPage()
258 # Insert 300ms wait to simulate user finger movement,
259 # and ensure scheduling of idle tasks.
260 action_runner.Wait(0.3)
261 action_runner.ClickElement(
262 # pylint: disable=C0301
263 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/"]')
264 action_runner.WaitForNavigate()
265 with action_runner.CreateGestureInteraction('ScrollAction'):
266 action_runner.ScrollPage()
267 action_runner.Wait(0.3)
268 action_runner.ClickElement(text='Features')
269 action_runner.WaitForNavigate()
270 with action_runner.CreateGestureInteraction('ScrollAction'):
271 action_runner.ScrollPage()
272 action_runner.Wait(0.3)
273 action_runner.ClickElement(text='News')
274 action_runner.WaitForNavigate()
275 with action_runner.CreateGestureInteraction('ScrollAction'):
276 action_runner.ScrollPage()
279 class FacebookPage(Top7StressPage):
281 """ Why: top social,Public profile """
283 def __init__(self, page_set):
284 super(FacebookPage, self).__init__(
285 url='https://www.facebook.com/barackobama',
286 page_set=page_set,
287 name='Facebook')
288 self.credentials = 'facebook2'
290 def RunNavigateSteps(self, action_runner):
291 super(FacebookPage, self).RunNavigateSteps(action_runner)
292 action_runner.WaitForElement(text='About')
294 def RunPageInteractions(self, action_runner):
295 # Scroll and wait for the next page to be loaded.
296 with action_runner.CreateGestureInteraction('ScrollAction'):
297 action_runner.ScrollPage()
298 action_runner.WaitForJavaScriptCondition(
299 'document.documentElement.scrollHeight - window.innerHeight - '
300 'window.pageYOffset > 0')
302 # Scroll and wait again.
303 with action_runner.CreateGestureInteraction('ScrollAction'):
304 action_runner.ScrollPage()
305 action_runner.WaitForJavaScriptCondition(
306 'document.documentElement.scrollHeight - window.innerHeight - '
307 'window.pageYOffset > 0')
309 class Top7StressPageSet(story.StorySet):
311 """ Pages hand-picked for stress testing. """
313 def __init__(self):
314 super(Top7StressPageSet, self).__init__(
315 archive_data_file='data/top_7_stress.json',
316 cloud_storage_bucket=story.PARTNER_BUCKET)
318 self.AddStory(GoogleWebSearchPage(self))
319 self.AddStory(GmailPage(self))
320 self.AddStory(GoogleCalendarPage(self))
321 self.AddStory(GooglePlusPage(self))
322 self.AddStory(BlogspotPage(self))
323 self.AddStory(WordpressPage(self))
324 self.AddStory(FacebookPage(self))