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