| 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 class PolymerPage(page_module.Page): | 7 class PolymerPage(page_module.Page): |
| 8 | 8 |
| 9 def __init__(self, url, page_set, run_no_page_interactions): | 9 def __init__(self, url, page_set, run_no_page_interactions): |
| 10 """ Base class for all polymer pages. | 10 """ Base class for all polymer pages. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 super(PolymerCalculatorPage, self).__init__( | 46 super(PolymerCalculatorPage, self).__init__( |
| 47 url=('http://www.polymer-project.org/components/paper-calculator/' | 47 url=('http://www.polymer-project.org/components/paper-calculator/' |
| 48 'demo.html'), | 48 'demo.html'), |
| 49 page_set=page_set, run_no_page_interactions=run_no_page_interactions) | 49 page_set=page_set, run_no_page_interactions=run_no_page_interactions) |
| 50 | 50 |
| 51 def PerformPageInteractions(self, action_runner): | 51 def PerformPageInteractions(self, action_runner): |
| 52 self.TapButton(action_runner) | 52 self.TapButton(action_runner) |
| 53 self.SlidePanel(action_runner) | 53 self.SlidePanel(action_runner) |
| 54 | 54 |
| 55 def TapButton(self, action_runner): | 55 def TapButton(self, action_runner): |
| 56 with action_runner.CreateInteraction('Action_TapAction'): | 56 with action_runner.CreateInteraction('PolymerAnimation', repeatable=True): |
| 57 action_runner.TapElement(element_function=''' | 57 action_runner.TapElement(element_function=''' |
| 58 document.querySelector( | 58 document.querySelector( |
| 59 'body /deep/ #outerPanels' | 59 'body /deep/ #outerPanels' |
| 60 ).querySelector( | 60 ).querySelector( |
| 61 '#standard' | 61 '#standard' |
| 62 ).shadowRoot.querySelector( | 62 ).shadowRoot.querySelector( |
| 63 'paper-calculator-key[label="5"]' | 63 'paper-calculator-key[label="5"]' |
| 64 )''') | 64 )''') |
| 65 action_runner.Wait(2) | 65 action_runner.Wait(2) |
| 66 | 66 |
| 67 def SlidePanel(self, action_runner): | 67 def SlidePanel(self, action_runner): |
| 68 # only bother with this interaction if the drawer is hidden | 68 # only bother with this interaction if the drawer is hidden |
| 69 opened = action_runner.EvaluateJavaScript(''' | 69 opened = action_runner.EvaluateJavaScript(''' |
| 70 (function() { | 70 (function() { |
| 71 var outer = document.querySelector("body /deep/ #outerPanels"); | 71 var outer = document.querySelector("body /deep/ #outerPanels"); |
| 72 return outer.opened || outer.wideMode; | 72 return outer.opened || outer.wideMode; |
| 73 }());''') | 73 }());''') |
| 74 if not opened: | 74 if not opened: |
| 75 with action_runner.CreateInteraction('Action_SwipeAction'): | 75 with action_runner.CreateInteraction('PolymerAnimation', repeatable=True): |
| 76 action_runner.SwipeElement( | 76 action_runner.SwipeElement( |
| 77 left_start_ratio=0.1, top_start_ratio=0.2, | 77 left_start_ratio=0.1, top_start_ratio=0.2, |
| 78 direction='left', distance=300, speed_in_pixels_per_second=5000, | 78 direction='left', distance=300, speed_in_pixels_per_second=5000, |
| 79 element_function=''' | 79 element_function=''' |
| 80 document.querySelector( | 80 document.querySelector( |
| 81 'body /deep/ #outerPanels' | 81 'body /deep/ #outerPanels' |
| 82 ).querySelector( | 82 ).querySelector( |
| 83 '#advanced' | 83 '#advanced' |
| 84 ).shadowRoot.querySelector( | 84 ).shadowRoot.querySelector( |
| 85 '.handle-bar' | 85 '.handle-bar' |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 for p in SCROLLABLE_PAGES: | 248 for p in SCROLLABLE_PAGES: |
| 249 self.AddUserStory(PolymerSampler( | 249 self.AddUserStory(PolymerSampler( |
| 250 self, p, run_no_page_interactions=run_no_page_interactions, | 250 self, p, run_no_page_interactions=run_no_page_interactions, |
| 251 scrolling_page=True)) | 251 scrolling_page=True)) |
| 252 | 252 |
| 253 for page in self: | 253 for page in self: |
| 254 assert (page.__class__.RunPageInteractions == | 254 assert (page.__class__.RunPageInteractions == |
| 255 PolymerPage.RunPageInteractions), ( | 255 PolymerPage.RunPageInteractions), ( |
| 256 'Pages in this page set must not override PolymerPage\' ' | 256 'Pages in this page set must not override PolymerPage\' ' |
| 257 'RunPageInteractions method.') | 257 'RunPageInteractions method.') |
| OLD | NEW |