Chromium Code Reviews| 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 class KeySilkCasesPage(page_module.Page): | 8 class KeySilkCasesPage(page_module.Page): |
| 9 | 9 |
| 10 def __init__(self, url, page_set): | 10 def __init__(self, url, page_set): |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 page_set=page_set) | 399 page_set=page_set) |
| 400 | 400 |
| 401 def RunSmoothness(self, action_runner): | 401 def RunSmoothness(self, action_runner): |
| 402 interaction = action_runner.BeginGestureInteraction( | 402 interaction = action_runner.BeginGestureInteraction( |
| 403 'ScrollAction', is_smooth=True) | 403 'ScrollAction', is_smooth=True) |
| 404 action_runner.ScrollElement( | 404 action_runner.ScrollElement( |
| 405 selector='#container', speed_in_pixels_per_second=5000) | 405 selector='#container', speed_in_pixels_per_second=5000) |
| 406 interaction.End() | 406 interaction.End() |
| 407 | 407 |
| 408 | 408 |
| 409 class Page21(KeySilkCasesPage): | 409 class GwsExpansionPage(KeySilkCasesPage): |
| 410 """Abstract base class for pages that expand Google knowledge panels.""" | |
| 410 | 411 |
| 411 def __init__(self, page_set): | 412 def NavigateWait(self, action_runner): |
|
Sami
2014/08/12 11:38:52
µ-nit: NavigateAndWait?
| |
| 412 super(Page21, self).__init__( | 413 action_runner.NavigateToPage(self) |
| 413 url='http://www.google.com/#q=google', | 414 action_runner.Wait(3) |
| 414 page_set=page_set) | |
| 415 | |
| 416 def ScrollKnowledgeCardToTop(self, action_runner): | |
| 417 # scroll until the knowledge card is at the top | |
| 418 action_runner.ScrollPage( | |
| 419 distance_expr=''' | |
| 420 (function() { | |
| 421 var el = document.getElementById('kno-result'); | |
| 422 var bound = el.getBoundingClientRect(); | |
| 423 return bound.top - document.body.scrollTop; | |
| 424 })()''') | |
| 425 | 415 |
| 426 def ExpandKnowledgeCard(self, action_runner): | 416 def ExpandKnowledgeCard(self, action_runner): |
| 427 # expand card | 417 # expand card |
| 428 interaction = action_runner.BeginInteraction( | 418 interaction = action_runner.BeginInteraction( |
| 429 'Action_TapAction', is_smooth=True) | 419 'Action_TapAction', is_smooth=True) |
| 430 action_runner.TapElement( | 420 action_runner.TapElement( |
| 431 element_function='document.getElementsByClassName("vk_arc")[0]') | 421 element_function='document.getElementsByClassName("vk_arc")[0]') |
| 432 action_runner.Wait(2) | 422 action_runner.Wait(2) |
| 433 interaction.End() | 423 interaction.End() |
| 434 | 424 |
| 435 | 425 def ScrollKnowledgeCardToTop(self, action_runner, card_id): |
| 436 def RunNavigateSteps(self, action_runner): | 426 # scroll until the knowledge card is at the top |
| 437 action_runner.NavigateToPage(self) | 427 action_runner.ExecuteJavaScript( |
| 438 action_runner.Wait(3) | 428 "document.getElementById('%s').scrollIntoView()" % card_id) |
|
Sami
2014/08/12 11:38:52
Do we need to pass in true here to make sure the e
| |
| 439 self.ScrollKnowledgeCardToTop(action_runner) | |
| 440 | 429 |
| 441 def RunSmoothness(self, action_runner): | 430 def RunSmoothness(self, action_runner): |
| 442 self.ExpandKnowledgeCard(action_runner) | 431 self.ExpandKnowledgeCard(action_runner) |
| 443 | 432 |
| 444 | 433 |
| 434 class GwsGoogleExpansion(GwsExpansionPage): | |
| 435 | |
| 436 """ Why: Animating height of a complex content card is common. """ | |
| 437 | |
| 438 def __init__(self, page_set): | |
| 439 super(GwsGoogleExpansion, self).__init__( | |
| 440 url='http://www.google.com/#q=google', | |
| 441 page_set=page_set) | |
| 442 | |
| 443 def RunNavigateSteps(self, action_runner): | |
| 444 self.NavigateWait(action_runner) | |
| 445 self.ScrollKnowledgeCardToTop(action_runner, 'kno-result') | |
| 446 | |
| 447 | |
| 448 class GwsBoogieExpansion(GwsExpansionPage): | |
| 449 | |
| 450 """ Why: Same case as Google expansion but text-heavy rather than image. """ | |
| 451 | |
| 452 def __init__(self, page_set): | |
| 453 super(GwsBoogieExpansion, self).__init__( | |
| 454 url='https://www.google.com/search?hl=en&q=define%3Aboogie', | |
| 455 page_set=page_set) | |
| 456 | |
| 457 def RunNavigateSteps(self, action_runner): | |
| 458 self.NavigateWait(action_runner) | |
| 459 self.ScrollKnowledgeCardToTop(action_runner, 'rso') | |
| 460 | |
| 461 | |
| 445 class Page22(KeySilkCasesPage): | 462 class Page22(KeySilkCasesPage): |
| 446 | 463 |
| 447 def __init__(self, page_set): | 464 def __init__(self, page_set): |
| 448 super(Page22, self).__init__( | 465 super(Page22, self).__init__( |
| 449 url='http://plus.google.com/app/basic/stream', | 466 url='http://plus.google.com/app/basic/stream', |
| 450 page_set=page_set) | 467 page_set=page_set) |
| 451 | 468 |
| 452 self.disabled = 'Times out on Windows; crbug.com/338838' | 469 self.disabled = 'Times out on Windows; crbug.com/338838' |
| 453 self.credentials = 'google' | 470 self.credentials = 'google' |
| 454 | 471 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 self.AddPage(Page11(self)) | 657 self.AddPage(Page11(self)) |
| 641 self.AddPage(Page12(self)) | 658 self.AddPage(Page12(self)) |
| 642 self.AddPage(Page13(self)) | 659 self.AddPage(Page13(self)) |
| 643 self.AddPage(Page14(self)) | 660 self.AddPage(Page14(self)) |
| 644 self.AddPage(Page15(self)) | 661 self.AddPage(Page15(self)) |
| 645 self.AddPage(Page16(self)) | 662 self.AddPage(Page16(self)) |
| 646 self.AddPage(Page17(self)) | 663 self.AddPage(Page17(self)) |
| 647 self.AddPage(Page18(self)) | 664 self.AddPage(Page18(self)) |
| 648 self.AddPage(Page19(self)) | 665 self.AddPage(Page19(self)) |
| 649 self.AddPage(Page20(self)) | 666 self.AddPage(Page20(self)) |
| 650 self.AddPage(Page21(self)) | 667 self.AddPage(GwsGoogleExpansion(self)) |
| 668 self.AddPage(GwsBoogieExpansion(self)) | |
| 651 self.AddPage(Page22(self)) | 669 self.AddPage(Page22(self)) |
| 652 self.AddPage(Page23(self)) | 670 self.AddPage(Page23(self)) |
| 653 self.AddPage(Page24(self)) | 671 self.AddPage(Page24(self)) |
| 654 self.AddPage(Page25(self)) | 672 self.AddPage(Page25(self)) |
| 655 self.AddPage(Page26(self)) | 673 self.AddPage(Page26(self)) |
| 656 self.AddPage(SVGIconRaster(self)) | 674 self.AddPage(SVGIconRaster(self)) |
| 657 self.AddPage(UpdateHistoryState(self)) | 675 self.AddPage(UpdateHistoryState(self)) |
| OLD | NEW |