| 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): | 9 def __init__(self, url, page_set): |
| 10 super(PolymerPage, self).__init__( | 10 super(PolymerPage, self).__init__( |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 distance='900', | 138 distance='900', |
| 139 element_function=element_function) | 139 element_function=element_function) |
| 140 interaction.End() | 140 interaction.End() |
| 141 | 141 |
| 142 def TouchEverything(self, action_runner): | 142 def TouchEverything(self, action_runner): |
| 143 tappable_types = [ | 143 tappable_types = [ |
| 144 'paper-button', | 144 'paper-button', |
| 145 'paper-checkbox', | 145 'paper-checkbox', |
| 146 'paper-fab', | 146 'paper-fab', |
| 147 'paper-icon-button', | 147 'paper-icon-button', |
| 148 'paper-radio-button', | 148 # crbug.com/394756 |
| 149 # 'paper-radio-button', |
| 149 'paper-tab', | 150 'paper-tab', |
| 150 'paper-toggle-button', | 151 'paper-toggle-button', |
| 151 'x-shadow', | 152 'x-shadow', |
| 152 ] | 153 ] |
| 153 for tappable_type in tappable_types: | 154 for tappable_type in tappable_types: |
| 154 self.DoActionOnWidgetType(action_runner, tappable_type, self.TapWidget) | 155 self.DoActionOnWidgetType(action_runner, tappable_type, self.TapWidget) |
| 155 swipeable_types = ['paper-slider'] | 156 swipeable_types = ['paper-slider'] |
| 156 for swipeable_type in swipeable_types: | 157 for swipeable_type in swipeable_types: |
| 157 self.DoActionOnWidgetType(action_runner, swipeable_type, self.SwipeWidget) | 158 self.DoActionOnWidgetType(action_runner, swipeable_type, self.SwipeWidget) |
| 158 | 159 |
| 159 def DoActionOnWidgetType(self, action_runner, widget_type, action_function): | 160 def DoActionOnWidgetType(self, action_runner, widget_type, action_function): |
| 160 # Find all widgets of this type, but skip any that are disabled or are | 161 # Find all widgets of this type, but skip any that are disabled or are |
| 161 # currently active as they typically don't produce animation frames. | 162 # currently active as they typically don't produce animation frames. |
| 162 element_list_query = (self.iframe_js + | 163 element_list_query = (self.iframe_js + |
| 163 ('.contentDocument.querySelectorAll("body %s:not([disabled]):' | 164 ('.contentDocument.querySelectorAll("body %s:not([disabled]):' |
| 164 'not([active]):not([checked])")' % widget_type)) | 165 'not([active])")' % widget_type)) |
| 165 roles_count_query = element_list_query + '.length' | 166 roles_count_query = element_list_query + '.length' |
| 166 for i in range(action_runner.EvaluateJavaScript(roles_count_query)): | 167 for i in range(action_runner.EvaluateJavaScript(roles_count_query)): |
| 167 element_query = element_list_query + ("[%d]" % i) | 168 element_query = element_list_query + ("[%d]" % i) |
| 168 if action_runner.EvaluateJavaScript( | 169 if action_runner.EvaluateJavaScript( |
| 169 element_query + '.offsetParent != null'): | 170 element_query + '.offsetParent != null'): |
| 170 # Only try to tap on visible elements (offsetParent != null) | 171 # Only try to tap on visible elements (offsetParent != null) |
| 171 action_runner.ExecuteJavaScript(element_query + '.scrollIntoView()') | 172 action_runner.ExecuteJavaScript(element_query + '.scrollIntoView()') |
| 172 action_runner.Wait(1) # wait for page to settle after scrolling | 173 action_runner.Wait(1) # wait for page to settle after scrolling |
| 173 action_function(action_runner, element_query) | 174 action_function(action_runner, element_query) |
| 174 | 175 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 198 | 199 |
| 199 self.AddPage(PolymerCalculatorPage(self)) | 200 self.AddPage(PolymerCalculatorPage(self)) |
| 200 self.AddPage(PolymerShadowPage(self)) | 201 self.AddPage(PolymerShadowPage(self)) |
| 201 | 202 |
| 202 # Polymer Sampler subpages that are interesting to tap / swipe elements on | 203 # Polymer Sampler subpages that are interesting to tap / swipe elements on |
| 203 TAPPABLE_PAGES = [ | 204 TAPPABLE_PAGES = [ |
| 204 'paper-button', | 205 'paper-button', |
| 205 'paper-checkbox', | 206 'paper-checkbox', |
| 206 'paper-fab', | 207 'paper-fab', |
| 207 'paper-icon-button', | 208 'paper-icon-button', |
| 208 'paper-radio-button', | 209 # crbug.com/394756 |
| 210 # 'paper-radio-button', |
| 209 'paper-shadow', | 211 'paper-shadow', |
| 210 'paper-tabs', | 212 'paper-tabs', |
| 211 'paper-toggle-button', | 213 'paper-toggle-button', |
| 212 ] | 214 ] |
| 213 for p in TAPPABLE_PAGES: | 215 for p in TAPPABLE_PAGES: |
| 214 self.AddPage(PolymerSampler(self, p)) | 216 self.AddPage(PolymerSampler(self, p)) |
| 215 | 217 |
| 216 # Polymer Sampler subpages that are interesting to scroll | 218 # Polymer Sampler subpages that are interesting to scroll |
| 217 SCROLLABLE_PAGES = [ | 219 SCROLLABLE_PAGES = [ |
| 218 # crbug.com/394756 | 220 # crbug.com/394756 |
| 219 # 'core-scroll-header-panel', | 221 # 'core-scroll-header-panel', |
| 220 ] | 222 ] |
| 221 for p in SCROLLABLE_PAGES: | 223 for p in SCROLLABLE_PAGES: |
| 222 self.AddPage(PolymerSampler(self, p, scrolling_page=True)) | 224 self.AddPage(PolymerSampler(self, p, scrolling_page=True)) |
| OLD | NEW |