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 |
11 | 11 |
12 def _WaitForLocationChange(action_runner, old_href): | 12 def _WaitForLocationChange(action_runner, old_href): |
13 action_runner.WaitForJavaScriptCondition( | 13 action_runner.WaitForJavaScriptCondition( |
14 'document.location.href != "%s"' % old_href) | 14 'document.location.href != "%s"' % old_href) |
15 | 15 |
16 | 16 |
17 class Top7StressPage(page_module.Page): | 17 class Top7StressPage(page_module.Page): |
18 | 18 |
19 def __init__(self, url, page_set, name=''): | 19 def __init__(self, url, page_set, name=''): |
20 super(Top7StressPage, self).__init__( | 20 super(Top7StressPage, self).__init__( |
21 url=url, page_set=page_set, name=name, | 21 url=url, page_set=page_set, name=name, |
22 credentials_path = 'data/credentials.json') | 22 credentials_path = 'data/credentials.json') |
23 self.user_agent_type = 'desktop' | 23 self.user_agent_type = 'desktop' |
24 self.archive_data_file = 'data/top_25.json' | 24 self.archive_data_file = 'data/top_7_stress.json' |
25 | 25 |
26 def RunPageInteractions(self, action_runner): | 26 def RunPageInteractions(self, action_runner): |
27 raise NotImplementedError() | 27 raise NotImplementedError() |
28 | 28 |
29 | 29 |
30 class GoogleWebSearchPage(Top7StressPage): | 30 class GoogleWebSearchPage(Top7StressPage): |
31 | 31 |
32 """ Why: top google property; a google tab is often open """ | 32 """ Why: top google property; a google tab is often open """ |
33 | 33 |
34 def __init__(self, page_set): | 34 def __init__(self, page_set): |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 url='http://www.facebook.com/barackobama', | 302 url='http://www.facebook.com/barackobama', |
303 page_set=page_set, | 303 page_set=page_set, |
304 name='Facebook') | 304 name='Facebook') |
305 self.credentials = 'facebook' | 305 self.credentials = 'facebook' |
306 | 306 |
307 def RunNavigateSteps(self, action_runner): | 307 def RunNavigateSteps(self, action_runner): |
308 action_runner.NavigateToPage(self) | 308 action_runner.NavigateToPage(self) |
309 action_runner.WaitForElement(text='About') | 309 action_runner.WaitForElement(text='About') |
310 | 310 |
311 def RunPageInteractions(self, action_runner): | 311 def RunPageInteractions(self, action_runner): |
312 action_runner.ClickElement(text='About') | 312 # Scroll and wait for the next page to be loaded. |
313 action_runner.WaitForNavigate() | 313 interaction = action_runner.BeginGestureInteraction( |
314 action_runner.ClickElement(text='The Audacity of Hope') | 314 'ScrollAction', is_smooth=True) |
315 action_runner.WaitForNavigate() | 315 action_runner.ScrollPage() |
316 action_runner.ClickElement(text='Back to Barack Obama\'s Timeline') | 316 interaction.End() |
317 action_runner.WaitForNavigate() | 317 action_runner.WaitForJavaScriptCondition( |
318 action_runner.ClickElement(text='About') | 318 'document.documentElement.scrollHeight - window.innerHeight - ' |
319 action_runner.WaitForNavigate() | 319 'window.pageYOffset > 0') |
320 action_runner.ClickElement(text='Elected to U.S. Senate') | |
321 action_runner.WaitForNavigate() | |
322 action_runner.ClickElement(text='Home') | |
323 action_runner.WaitForNavigate() | |
324 | 320 |
| 321 # Scroll and wait again. |
| 322 interaction = action_runner.BeginGestureInteraction( |
| 323 'ScrollAction', is_smooth=True) |
| 324 action_runner.ScrollPage() |
| 325 interaction.End() |
| 326 action_runner.WaitForJavaScriptCondition( |
| 327 'document.documentElement.scrollHeight - window.innerHeight - ' |
| 328 'window.pageYOffset > 0') |
325 | 329 |
326 class Top7StressPageSet(page_set_module.PageSet): | 330 class Top7StressPageSet(page_set_module.PageSet): |
327 | 331 |
328 """ Pages hand-picked for stress testing. """ | 332 """ Pages hand-picked for stress testing. """ |
329 | 333 |
330 def __init__(self): | 334 def __init__(self): |
331 super(Top7StressPageSet, self).__init__( | 335 super(Top7StressPageSet, self).__init__( |
332 user_agent_type='desktop', | 336 user_agent_type='desktop', |
333 archive_data_file='data/top_25.json', | 337 archive_data_file='data/top_7_stress.json', |
334 bucket=page_set_module.PARTNER_BUCKET) | 338 bucket=page_set_module.PARTNER_BUCKET) |
335 | 339 |
336 self.AddUserStory(GoogleWebSearchPage(self)) | 340 self.AddUserStory(GoogleWebSearchPage(self)) |
337 self.AddUserStory(GmailPage(self)) | 341 self.AddUserStory(GmailPage(self)) |
338 self.AddUserStory(GoogleCalendarPage(self)) | 342 self.AddUserStory(GoogleCalendarPage(self)) |
339 self.AddUserStory(GooglePlusPage(self)) | 343 self.AddUserStory(GooglePlusPage(self)) |
340 self.AddUserStory(BlogspotPage(self)) | 344 self.AddUserStory(BlogspotPage(self)) |
341 self.AddUserStory(WordpressPage(self)) | 345 self.AddUserStory(WordpressPage(self)) |
342 self.AddUserStory(FacebookPage(self)) | 346 self.AddUserStory(FacebookPage(self)) |
OLD | NEW |