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