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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 """Page exercising interactions with a single Paper Sampler subpage. | 95 """Page exercising interactions with a single Paper Sampler subpage. |
96 | 96 |
97 Args: | 97 Args: |
98 page_set: Page set to inforporate this page into. | 98 page_set: Page set to inforporate this page into. |
99 anchor: string indicating which subpage to load (matches the element | 99 anchor: string indicating which subpage to load (matches the element |
100 type that page is displaying) | 100 type that page is displaying) |
101 scrolling_page: Whether scrolling the content pane is relevant to this | 101 scrolling_page: Whether scrolling the content pane is relevant to this |
102 content page or not. | 102 content page or not. |
103 """ | 103 """ |
104 super(PolymerSampler, self).__init__( | 104 super(PolymerSampler, self).__init__( |
105 url=('http://www.polymer-project.org/components/paper-elements/demo.html#' | 105 url=('http://www.polymer-project.org/components/%s/demo.html' % anchor), |
106 + anchor), | |
107 page_set=page_set) | 106 page_set=page_set) |
108 self.scrolling_page = scrolling_page | 107 self.scrolling_page = scrolling_page |
109 self.iframe_js = 'document.querySelector("sampler-scaffold").$.frame' | 108 self.iframe_js = 'document' |
Sami
2014/08/07 14:51:06
Are you planning to use this same code for the int
| |
110 | 109 |
111 def RunNavigateSteps(self, action_runner): | 110 def RunNavigateSteps(self, action_runner): |
112 #FIXME(wiltzius) workaround for crbug.com/391672 | 111 #FIXME(wiltzius) workaround for crbug.com/391672 |
113 action_runner.ExecuteJavaScript('window.location.href="about:blank";') | 112 #action_runner.ExecuteJavaScript('window.location.href="about:blank";') |
tonyg
2014/08/09 18:17:32
Don't we want to completely remove the above two l
| |
114 super(PolymerSampler, self).RunNavigateSteps(action_runner) | 113 super(PolymerSampler, self).RunNavigateSteps(action_runner) |
115 #FIXME(wiltzius) this should wait for iframe to load and all load | 114 #FIXME(wiltzius) this should wait for iframe to load and all load |
116 # animations to end | 115 # animations to end |
117 action_runner.Wait(5) | 116 action_runner.Wait(5) |
118 | 117 |
119 def RunSmoothness(self, action_runner): | 118 def RunSmoothness(self, action_runner): |
120 #TODO(wiltzius) Add interactions for input elements and shadow pages | 119 #TODO(wiltzius) Add interactions for input elements and shadow pages |
121 if self.scrolling_page: | 120 if self.scrolling_page: |
122 # Only bother scrolling the page if its been marked as worthwhile | 121 # Only bother scrolling the page if its been marked as worthwhile |
123 self.ScrollContentPane(action_runner) | 122 self.ScrollContentPane(action_runner) |
124 self.TouchEverything(action_runner) | 123 self.TouchEverything(action_runner) |
125 | 124 |
126 def ScrollContentPane(self, action_runner): | 125 def ScrollContentPane(self, action_runner): |
127 element_function = (self.iframe_js + '.contentDocument.querySelector(' | 126 element_function = (self.iframe_js + '.querySelector(' |
128 '"core-scroll-header-panel").$.mainContainer') | 127 '"core-scroll-header-panel").$.mainContainer') |
129 interaction = action_runner.BeginInteraction('Scroll_Page', is_smooth=True) | 128 interaction = action_runner.BeginInteraction('Scroll_Page', is_smooth=True) |
130 action_runner.ScrollElement(use_touch=True, | 129 action_runner.ScrollElement(use_touch=True, |
131 direction='down', | 130 direction='down', |
132 distance='900', | 131 distance='900', |
133 element_function=element_function) | 132 element_function=element_function) |
134 interaction.End() | 133 interaction.End() |
135 interaction = action_runner.BeginInteraction('Scroll_Page', is_smooth=True) | 134 interaction = action_runner.BeginInteraction('Scroll_Page', is_smooth=True) |
136 action_runner.ScrollElement(use_touch=True, | 135 action_runner.ScrollElement(use_touch=True, |
137 direction='up', | 136 direction='up', |
(...skipping 16 matching lines...) Expand all Loading... | |
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 ('.querySelectorAll("body %s:not([disabled]):' |
165 'not([active])")' % widget_type)) | 164 'not([active])")' % 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) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 # 'paper-radio-button', | 209 # 'paper-radio-button', |
211 'paper-shadow', | 210 'paper-shadow', |
212 'paper-tabs', | 211 'paper-tabs', |
213 'paper-toggle-button', | 212 'paper-toggle-button', |
214 ] | 213 ] |
215 for p in TAPPABLE_PAGES: | 214 for p in TAPPABLE_PAGES: |
216 self.AddPage(PolymerSampler(self, p)) | 215 self.AddPage(PolymerSampler(self, p)) |
217 | 216 |
218 # Polymer Sampler subpages that are interesting to scroll | 217 # Polymer Sampler subpages that are interesting to scroll |
219 SCROLLABLE_PAGES = [ | 218 SCROLLABLE_PAGES = [ |
220 # crbug.com/394756 | 219 'core-scroll-header-panel', |
221 # '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 |