OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 from telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
5 from telemetry.page import page_set as page_set_module | 5 from telemetry.page import page_set as page_set_module |
6 | 6 |
7 | 7 |
8 def _GetCurrentLocation(action_runner): | 8 def _GetCurrentLocation(action_runner): |
9 return action_runner.EvaluateJavaScript('document.location.href') | 9 return action_runner.EvaluateJavaScript('document.location.href') |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 def __init__(self, page_set): | 34 def __init__(self, page_set): |
35 super(GoogleWebSearchPage, self).__init__( | 35 super(GoogleWebSearchPage, self).__init__( |
36 url='https://www.google.com/#hl=en&q=barack+obama', | 36 url='https://www.google.com/#hl=en&q=barack+obama', |
37 page_set=page_set) | 37 page_set=page_set) |
38 | 38 |
39 def RunNavigateSteps(self, action_runner): | 39 def RunNavigateSteps(self, action_runner): |
40 super(GoogleWebSearchPage, self).RunNavigateSteps(action_runner) | 40 super(GoogleWebSearchPage, self).RunNavigateSteps(action_runner) |
41 action_runner.WaitForElement(text='Next') | 41 action_runner.WaitForElement(text='Next') |
42 | 42 |
43 def RunPageInteractions(self, action_runner): | 43 def RunPageInteractions(self, action_runner): |
44 interaction = action_runner.BeginGestureInteraction( | 44 with action_runner.CreateGestureInteraction('ScrollAction'): |
45 'ScrollAction') | 45 action_runner.ScrollPage() |
46 action_runner.ScrollPage() | |
47 interaction.End() | |
48 old_href = _GetCurrentLocation(action_runner) | 46 old_href = _GetCurrentLocation(action_runner) |
49 action_runner.ClickElement(text='Next') | 47 action_runner.ClickElement(text='Next') |
50 _WaitForLocationChange(action_runner, old_href) | 48 _WaitForLocationChange(action_runner, old_href) |
51 action_runner.WaitForElement(text='Next') | 49 action_runner.WaitForElement(text='Next') |
52 interaction = action_runner.BeginGestureInteraction( | 50 with action_runner.CreateGestureInteraction('ScrollAction'): |
53 'ScrollAction') | 51 action_runner.ScrollPage() |
54 action_runner.ScrollPage() | |
55 interaction.End() | |
56 old_href = _GetCurrentLocation(action_runner) | 52 old_href = _GetCurrentLocation(action_runner) |
57 action_runner.ClickElement(text='Next') | 53 action_runner.ClickElement(text='Next') |
58 _WaitForLocationChange(action_runner, old_href) | 54 _WaitForLocationChange(action_runner, old_href) |
59 action_runner.WaitForElement(text='Next') | 55 action_runner.WaitForElement(text='Next') |
60 interaction = action_runner.BeginGestureInteraction( | 56 with action_runner.CreateGestureInteraction('ScrollAction'): |
61 'ScrollAction') | 57 action_runner.ScrollPage() |
62 action_runner.ScrollPage() | |
63 interaction.End() | |
64 old_href = _GetCurrentLocation(action_runner) | 58 old_href = _GetCurrentLocation(action_runner) |
65 action_runner.ClickElement(text='Next') | 59 action_runner.ClickElement(text='Next') |
66 _WaitForLocationChange(action_runner, old_href) | 60 _WaitForLocationChange(action_runner, old_href) |
67 action_runner.WaitForElement(text='Previous') | 61 action_runner.WaitForElement(text='Previous') |
68 interaction = action_runner.BeginGestureInteraction( | 62 with action_runner.CreateGestureInteraction('ScrollAction'): |
69 'ScrollAction') | 63 action_runner.ScrollPage() |
70 action_runner.ScrollPage() | |
71 interaction.End() | |
72 old_href = _GetCurrentLocation(action_runner) | 64 old_href = _GetCurrentLocation(action_runner) |
73 action_runner.ClickElement(text='Previous') | 65 action_runner.ClickElement(text='Previous') |
74 _WaitForLocationChange(action_runner, old_href) | 66 _WaitForLocationChange(action_runner, old_href) |
75 action_runner.WaitForElement(text='Previous') | 67 action_runner.WaitForElement(text='Previous') |
76 interaction = action_runner.BeginGestureInteraction( | 68 with action_runner.CreateGestureInteraction('ScrollAction'): |
77 'ScrollAction') | 69 action_runner.ScrollPage() |
78 action_runner.ScrollPage() | |
79 interaction.End() | |
80 old_href = _GetCurrentLocation(action_runner) | 70 old_href = _GetCurrentLocation(action_runner) |
81 action_runner.ClickElement(text='Previous') | 71 action_runner.ClickElement(text='Previous') |
82 _WaitForLocationChange(action_runner, old_href) | 72 _WaitForLocationChange(action_runner, old_href) |
83 action_runner.WaitForElement(text='Previous') | 73 action_runner.WaitForElement(text='Previous') |
84 interaction = action_runner.BeginGestureInteraction( | 74 with action_runner.CreateGestureInteraction('ScrollAction'): |
85 'ScrollAction') | 75 action_runner.ScrollPage() |
86 action_runner.ScrollPage() | |
87 interaction.End() | |
88 old_href = _GetCurrentLocation(action_runner) | 76 old_href = _GetCurrentLocation(action_runner) |
89 action_runner.ClickElement(text='Previous') | 77 action_runner.ClickElement(text='Previous') |
90 _WaitForLocationChange(action_runner, old_href) | 78 _WaitForLocationChange(action_runner, old_href) |
91 action_runner.WaitForElement(text='Images') | 79 action_runner.WaitForElement(text='Images') |
92 interaction = action_runner.BeginGestureInteraction( | 80 with action_runner.CreateGestureInteraction('ScrollAction'): |
93 'ScrollAction') | 81 action_runner.ScrollPage() |
94 action_runner.ScrollPage() | |
95 interaction.End() | |
96 old_href = _GetCurrentLocation(action_runner) | 82 old_href = _GetCurrentLocation(action_runner) |
97 action_runner.ClickElement(text='Images') | 83 action_runner.ClickElement(text='Images') |
98 _WaitForLocationChange(action_runner, old_href) | 84 _WaitForLocationChange(action_runner, old_href) |
99 action_runner.WaitForElement(text='Images') | 85 action_runner.WaitForElement(text='Images') |
100 | 86 |
101 | 87 |
102 class GmailPage(Top7StressPage): | 88 class GmailPage(Top7StressPage): |
103 | 89 |
104 """ Why: productivity, top google properties """ | 90 """ Why: productivity, top google properties """ |
105 | 91 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 page_set=page_set, | 208 page_set=page_set, |
223 name='Blogger') | 209 name='Blogger') |
224 | 210 |
225 def RunNavigateSteps(self, action_runner): | 211 def RunNavigateSteps(self, action_runner): |
226 super(BlogspotPage, self).RunNavigateSteps(action_runner) | 212 super(BlogspotPage, self).RunNavigateSteps(action_runner) |
227 action_runner.WaitForElement(text='accessibility') | 213 action_runner.WaitForElement(text='accessibility') |
228 | 214 |
229 def RunPageInteractions(self, action_runner): | 215 def RunPageInteractions(self, action_runner): |
230 action_runner.ClickElement(text='accessibility') | 216 action_runner.ClickElement(text='accessibility') |
231 action_runner.WaitForNavigate() | 217 action_runner.WaitForNavigate() |
232 interaction = action_runner.BeginGestureInteraction( | 218 with action_runner.CreateGestureInteraction('ScrollAction'): |
233 'ScrollAction') | 219 action_runner.ScrollPage() |
234 action_runner.ScrollPage() | |
235 interaction.End() | |
236 # Insert 300ms wait to simulate user finger movement, | 220 # Insert 300ms wait to simulate user finger movement, |
237 # and ensure scheduling of idle tasks. | 221 # and ensure scheduling of idle tasks. |
238 action_runner.Wait(0.3) | 222 action_runner.Wait(0.3) |
239 action_runner.ClickElement(text='advanced') | 223 action_runner.ClickElement(text='advanced') |
240 action_runner.WaitForNavigate() | 224 action_runner.WaitForNavigate() |
241 interaction = action_runner.BeginGestureInteraction( | 225 with action_runner.CreateGestureInteraction('ScrollAction'): |
242 'ScrollAction') | 226 action_runner.ScrollPage() |
243 action_runner.ScrollPage() | |
244 interaction.End() | |
245 action_runner.Wait(0.3) | 227 action_runner.Wait(0.3) |
246 action_runner.ClickElement(text='beginner') | 228 action_runner.ClickElement(text='beginner') |
247 action_runner.WaitForNavigate() | 229 action_runner.WaitForNavigate() |
248 interaction = action_runner.BeginGestureInteraction( | 230 with action_runner.CreateGestureInteraction('ScrollAction'): |
249 'ScrollAction') | 231 action_runner.ScrollPage() |
250 action_runner.ScrollPage() | |
251 interaction.End() | |
252 action_runner.Wait(0.3) | 232 action_runner.Wait(0.3) |
253 action_runner.ClickElement(text='Home') | 233 action_runner.ClickElement(text='Home') |
254 action_runner.WaitForNavigate() | 234 action_runner.WaitForNavigate() |
255 | 235 |
256 | 236 |
257 class WordpressPage(Top7StressPage): | 237 class WordpressPage(Top7StressPage): |
258 | 238 |
259 """ Why: #18 (Alexa global), Picked an interesting post """ | 239 """ Why: #18 (Alexa global), Picked an interesting post """ |
260 | 240 |
261 def __init__(self, page_set): | 241 def __init__(self, page_set): |
262 super(WordpressPage, self).__init__( | 242 super(WordpressPage, self).__init__( |
263 # pylint: disable=C0301 | 243 # pylint: disable=C0301 |
264 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks
-for-august-2012/', | 244 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks
-for-august-2012/', |
265 page_set=page_set, | 245 page_set=page_set, |
266 name='Wordpress') | 246 name='Wordpress') |
267 | 247 |
268 def RunNavigateSteps(self, action_runner): | 248 def RunNavigateSteps(self, action_runner): |
269 super(WordpressPage, self).RunNavigateSteps(action_runner) | 249 super(WordpressPage, self).RunNavigateSteps(action_runner) |
270 action_runner.WaitForElement( | 250 action_runner.WaitForElement( |
271 # pylint: disable=C0301 | 251 # pylint: disable=C0301 |
272 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sig
ht/"]') | 252 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sig
ht/"]') |
273 | 253 |
274 def RunPageInteractions(self, action_runner): | 254 def RunPageInteractions(self, action_runner): |
275 interaction = action_runner.BeginGestureInteraction( | 255 with action_runner.CreateGestureInteraction('ScrollAction'): |
276 'ScrollAction') | 256 action_runner.ScrollPage() |
277 action_runner.ScrollPage() | |
278 interaction.End() | |
279 # Insert 300ms wait to simulate user finger movement, | 257 # Insert 300ms wait to simulate user finger movement, |
280 # and ensure scheduling of idle tasks. | 258 # and ensure scheduling of idle tasks. |
281 action_runner.Wait(0.3) | 259 action_runner.Wait(0.3) |
282 action_runner.ClickElement( | 260 action_runner.ClickElement( |
283 # pylint: disable=C0301 | 261 # pylint: disable=C0301 |
284 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sig
ht/"]') | 262 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sig
ht/"]') |
285 action_runner.WaitForNavigate() | 263 action_runner.WaitForNavigate() |
286 interaction = action_runner.BeginGestureInteraction( | 264 with action_runner.CreateGestureInteraction('ScrollAction'): |
287 'ScrollAction') | 265 action_runner.ScrollPage() |
288 action_runner.ScrollPage() | |
289 interaction.End() | |
290 action_runner.Wait(0.3) | 266 action_runner.Wait(0.3) |
291 action_runner.ClickElement(text='Features') | 267 action_runner.ClickElement(text='Features') |
292 action_runner.WaitForNavigate() | 268 action_runner.WaitForNavigate() |
293 interaction = action_runner.BeginGestureInteraction( | 269 with action_runner.CreateGestureInteraction('ScrollAction'): |
294 'ScrollAction') | 270 action_runner.ScrollPage() |
295 action_runner.ScrollPage() | |
296 interaction.End() | |
297 action_runner.Wait(0.3) | 271 action_runner.Wait(0.3) |
298 action_runner.ClickElement(text='News') | 272 action_runner.ClickElement(text='News') |
299 action_runner.WaitForNavigate() | 273 action_runner.WaitForNavigate() |
300 interaction = action_runner.BeginGestureInteraction( | 274 with action_runner.CreateGestureInteraction('ScrollAction'): |
301 'ScrollAction') | 275 action_runner.ScrollPage() |
302 action_runner.ScrollPage() | |
303 interaction.End() | |
304 | 276 |
305 | 277 |
306 class FacebookPage(Top7StressPage): | 278 class FacebookPage(Top7StressPage): |
307 | 279 |
308 """ Why: top social,Public profile """ | 280 """ Why: top social,Public profile """ |
309 | 281 |
310 def __init__(self, page_set): | 282 def __init__(self, page_set): |
311 super(FacebookPage, self).__init__( | 283 super(FacebookPage, self).__init__( |
312 url='https://www.facebook.com/barackobama', | 284 url='https://www.facebook.com/barackobama', |
313 page_set=page_set, | 285 page_set=page_set, |
314 name='Facebook') | 286 name='Facebook') |
315 self.credentials = 'facebook2' | 287 self.credentials = 'facebook2' |
316 | 288 |
317 def RunNavigateSteps(self, action_runner): | 289 def RunNavigateSteps(self, action_runner): |
318 super(FacebookPage, self).RunNavigateSteps(action_runner) | 290 super(FacebookPage, self).RunNavigateSteps(action_runner) |
319 action_runner.WaitForElement(text='About') | 291 action_runner.WaitForElement(text='About') |
320 | 292 |
321 def RunPageInteractions(self, action_runner): | 293 def RunPageInteractions(self, action_runner): |
322 # Scroll and wait for the next page to be loaded. | 294 # Scroll and wait for the next page to be loaded. |
323 interaction = action_runner.BeginGestureInteraction( | 295 with action_runner.CreateGestureInteraction('ScrollAction'): |
324 'ScrollAction') | 296 action_runner.ScrollPage() |
325 action_runner.ScrollPage() | |
326 interaction.End() | |
327 action_runner.WaitForJavaScriptCondition( | 297 action_runner.WaitForJavaScriptCondition( |
328 'document.documentElement.scrollHeight - window.innerHeight - ' | 298 'document.documentElement.scrollHeight - window.innerHeight - ' |
329 'window.pageYOffset > 0') | 299 'window.pageYOffset > 0') |
330 | 300 |
331 # Scroll and wait again. | 301 # Scroll and wait again. |
332 interaction = action_runner.BeginGestureInteraction( | 302 with action_runner.CreateGestureInteraction('ScrollAction'): |
333 'ScrollAction') | 303 action_runner.ScrollPage() |
334 action_runner.ScrollPage() | |
335 interaction.End() | |
336 action_runner.WaitForJavaScriptCondition( | 304 action_runner.WaitForJavaScriptCondition( |
337 'document.documentElement.scrollHeight - window.innerHeight - ' | 305 'document.documentElement.scrollHeight - window.innerHeight - ' |
338 'window.pageYOffset > 0') | 306 'window.pageYOffset > 0') |
339 | 307 |
340 class Top7StressPageSet(page_set_module.PageSet): | 308 class Top7StressPageSet(page_set_module.PageSet): |
341 | 309 |
342 """ Pages hand-picked for stress testing. """ | 310 """ Pages hand-picked for stress testing. """ |
343 | 311 |
344 def __init__(self): | 312 def __init__(self): |
345 super(Top7StressPageSet, self).__init__( | 313 super(Top7StressPageSet, self).__init__( |
346 user_agent_type='desktop', | 314 user_agent_type='desktop', |
347 archive_data_file='data/top_7_stress.json', | 315 archive_data_file='data/top_7_stress.json', |
348 bucket=page_set_module.PARTNER_BUCKET) | 316 bucket=page_set_module.PARTNER_BUCKET) |
349 | 317 |
350 self.AddUserStory(GoogleWebSearchPage(self)) | 318 self.AddUserStory(GoogleWebSearchPage(self)) |
351 self.AddUserStory(GmailPage(self)) | 319 self.AddUserStory(GmailPage(self)) |
352 self.AddUserStory(GoogleCalendarPage(self)) | 320 self.AddUserStory(GoogleCalendarPage(self)) |
353 self.AddUserStory(GooglePlusPage(self)) | 321 self.AddUserStory(GooglePlusPage(self)) |
354 self.AddUserStory(BlogspotPage(self)) | 322 self.AddUserStory(BlogspotPage(self)) |
355 self.AddUserStory(WordpressPage(self)) | 323 self.AddUserStory(WordpressPage(self)) |
356 self.AddUserStory(FacebookPage(self)) | 324 self.AddUserStory(FacebookPage(self)) |
OLD | NEW |