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 shared_page_state | 5 from telemetry.page import shared_page_state |
6 from telemetry import story | 6 from telemetry import story |
7 | 7 |
8 | 8 |
9 class KeySilkCasesPage(page_module.Page): | 9 class KeySilkCasesPage(page_module.Page): |
10 | 10 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 411 |
412 def ExpandKnowledgeCard(self, action_runner): | 412 def ExpandKnowledgeCard(self, action_runner): |
413 # expand card | 413 # expand card |
414 with action_runner.CreateInteraction('Action_TapAction'): | 414 with action_runner.CreateInteraction('Action_TapAction'): |
415 action_runner.TapElement( | 415 action_runner.TapElement( |
416 element_function='document.getElementsByClassName("vk_arc")[0]') | 416 element_function='document.getElementsByClassName("vk_arc")[0]') |
417 action_runner.Wait(2) | 417 action_runner.Wait(2) |
418 | 418 |
419 def ScrollKnowledgeCardToTop(self, action_runner, card_id): | 419 def ScrollKnowledgeCardToTop(self, action_runner, card_id): |
420 # scroll until the knowledge card is at the top | 420 # scroll until the knowledge card is at the top |
421 # TODO(catapult:#3028): Fix interpolation of JavaScript values. | |
422 action_runner.ExecuteJavaScript( | 421 action_runner.ExecuteJavaScript( |
423 "document.getElementById('%s').scrollIntoView()" % card_id) | 422 "document.getElementById({{ card_id }}).scrollIntoView()", |
| 423 card_id=card_id) |
424 | 424 |
425 def PerformPageInteractions(self, action_runner): | 425 def PerformPageInteractions(self, action_runner): |
426 self.ExpandKnowledgeCard(action_runner) | 426 self.ExpandKnowledgeCard(action_runner) |
427 | 427 |
428 | 428 |
429 class GwsGoogleExpansion(GwsExpansionPage): | 429 class GwsGoogleExpansion(GwsExpansionPage): |
430 | 430 |
431 """ Why: Animating height of a complex content card is common. """ | 431 """ Why: Animating height of a complex content card is common. """ |
432 | 432 |
433 def __init__(self, page_set, run_no_page_interactions): | 433 def __init__(self, page_set, run_no_page_interactions): |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 def __init__(self, page_set, run_no_page_interactions): | 641 def __init__(self, page_set, run_no_page_interactions): |
642 super(PolymerTopeka, self).__init__( | 642 super(PolymerTopeka, self).__init__( |
643 url='https://polymer-topeka.appspot.com/', | 643 url='https://polymer-topeka.appspot.com/', |
644 page_set=page_set, run_no_page_interactions=run_no_page_interactions) | 644 page_set=page_set, run_no_page_interactions=run_no_page_interactions) |
645 | 645 |
646 def PerformPageInteractions(self, action_runner): | 646 def PerformPageInteractions(self, action_runner): |
647 profile = 'html /deep/ topeka-profile /deep/ ' | 647 profile = 'html /deep/ topeka-profile /deep/ ' |
648 first_name = profile + 'paper-input#first /deep/ input' | 648 first_name = profile + 'paper-input#first /deep/ input' |
649 action_runner.WaitForElement(selector=first_name) | 649 action_runner.WaitForElement(selector=first_name) |
650 # Input First Name: | 650 # Input First Name: |
651 # TODO(catapult:#3028): Fix interpolation of JavaScript values. | |
652 action_runner.ExecuteJavaScript(''' | 651 action_runner.ExecuteJavaScript(''' |
653 var fn = document.querySelector('%s'); | 652 var fn = document.querySelector({{ first_name }}); |
654 fn.value = 'Chrome'; | 653 fn.value = 'Chrome'; |
655 fn.fire('input');''' % first_name) | 654 fn.fire('input');''', |
| 655 first_name=first_name) |
656 # Input Last Initial: | 656 # Input Last Initial: |
657 # TODO(catapult:#3028): Fix interpolation of JavaScript values. | |
658 action_runner.ExecuteJavaScript(''' | 657 action_runner.ExecuteJavaScript(''' |
659 var li = document.querySelector('%s paper-input#last /deep/ input'); | 658 var li = document.querySelector({{ selector }}); |
660 li.value = 'E'; | 659 li.value = 'E'; |
661 li.fire('input');''' % profile) | 660 li.fire('input');''', |
| 661 selector='%s paper-input#last /deep/ input' % profile) |
662 with action_runner.CreateInteraction('animation_interaction'): | 662 with action_runner.CreateInteraction('animation_interaction'): |
663 # Click the check-mark to login: | 663 # Click the check-mark to login: |
664 # TODO(catapult:#3028): Fix interpolation of JavaScript values. | |
665 action_runner.ExecuteJavaScript(''' | 664 action_runner.ExecuteJavaScript(''' |
666 window.topeka_page_transitions = 0; | 665 window.topeka_page_transitions = 0; |
667 [].forEach.call(document.querySelectorAll( | 666 [].forEach.call(document.querySelectorAll( |
668 'html /deep/ core-animated-pages'), function(p){ | 667 'html /deep/ core-animated-pages'), function(p){ |
669 p.addEventListener( | 668 p.addEventListener( |
670 'core-animated-pages-transition-end', function(e) { | 669 'core-animated-pages-transition-end', function(e) { |
671 window.topeka_page_transitions++; | 670 window.topeka_page_transitions++; |
672 }); | 671 }); |
673 }); | 672 }); |
674 document.querySelector('%s paper-fab').fire('tap')''' % profile) | 673 document.querySelector({{ selector }}).fire('tap')''', |
| 674 selector='%s paper-fab' % profile) |
675 # Wait for category list to animate in: | 675 # Wait for category list to animate in: |
676 action_runner.WaitForJavaScriptCondition(''' | 676 action_runner.WaitForJavaScriptCondition(''' |
677 window.topeka_page_transitions === 1''') | 677 window.topeka_page_transitions === 1''') |
678 # Click a category to start a quiz: | 678 # Click a category to start a quiz: |
679 action_runner.ExecuteJavaScript(''' | 679 action_runner.ExecuteJavaScript(''' |
680 document.querySelector('\ | 680 document.querySelector('\ |
681 html /deep/ core-selector.category-list').fire( | 681 html /deep/ core-selector.category-list').fire( |
682 'tap',1,document.querySelector('html /deep/ \ | 682 'tap',1,document.querySelector('html /deep/ \ |
683 div.category-item.red-theme'));''') | 683 div.category-item.red-theme'));''') |
684 # Wait for the category splash to animate in: | 684 # Wait for the category splash to animate in: |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 self.AddStory(SilkFinance(self, run_no_page_interactions)) | 759 self.AddStory(SilkFinance(self, run_no_page_interactions)) |
760 # Flaky interaction steps on Android; crbug.com/507865 | 760 # Flaky interaction steps on Android; crbug.com/507865 |
761 # self.AddStory(PolymerTopeka(self, run_no_page_interactions)) | 761 # self.AddStory(PolymerTopeka(self, run_no_page_interactions)) |
762 self.AddStory(Masonry(self, run_no_page_interactions)) | 762 self.AddStory(Masonry(self, run_no_page_interactions)) |
763 | 763 |
764 for page in self: | 764 for page in self: |
765 assert (page.__class__.RunPageInteractions == | 765 assert (page.__class__.RunPageInteractions == |
766 KeySilkCasesPage.RunPageInteractions), ( | 766 KeySilkCasesPage.RunPageInteractions), ( |
767 'Pages in this page set must not override KeySilkCasesPage\' ' | 767 'Pages in this page set must not override KeySilkCasesPage\' ' |
768 'RunPageInteractions method.') | 768 'RunPageInteractions method.') |
OLD | NEW |