Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: tools/perf/page_sets/polymer.py

Issue 926213002: [Telemetry] Add run_no_page_interactions options to polymer page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/KeySilkCasesPage/PolymerPage/ Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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, run_no_page_interactions):
10 """ Base class for all polymer pages.
11
12 Args:
13 run_no_page_interactions: whether the page will run any interactions after
14 navigate steps.
15 """
10 super(PolymerPage, self).__init__( 16 super(PolymerPage, self).__init__(
11 url=url, 17 url=url,
12 page_set=page_set) 18 page_set=page_set)
13 self.script_to_evaluate_on_commit = ''' 19 self.script_to_evaluate_on_commit = '''
14 document.addEventListener("polymer-ready", function() { 20 document.addEventListener("polymer-ready", function() {
15 window.__polymer_ready = true; 21 window.__polymer_ready = true;
16 }); 22 });
17 ''' 23 '''
24 self._run_no_page_interactions = run_no_page_interactions
25
26 def RunPageInteraction(self, action_runner):
vmiura 2015/02/18 01:18:37 Shouldn't this be "RunPageInteractions"?
27 # If a polymer page wants to customize it actions, it should
28 # overrides the PerformPageInteractions method instead of this method.
29 if self._run_no_page_interactions:
30 return
31 self.PerformPageInteractions(action_runner)
32
33 def PerformPageInteractions(self, action_runner):
34 """ Override this to perform actions after the page has navigated. """
35 pass
18 36
19 def RunNavigateSteps(self, action_runner): 37 def RunNavigateSteps(self, action_runner):
20 super(PolymerPage, self).RunNavigateSteps(action_runner) 38 super(PolymerPage, self).RunNavigateSteps(action_runner)
21 action_runner.WaitForJavaScriptCondition( 39 action_runner.WaitForJavaScriptCondition(
22 'window.__polymer_ready') 40 'window.__polymer_ready')
23 41
24 42
25 class PolymerCalculatorPage(PolymerPage): 43 class PolymerCalculatorPage(PolymerPage):
26 44
27 def __init__(self, page_set): 45 def __init__(self, page_set, run_no_page_interactions):
28 super(PolymerCalculatorPage, self).__init__( 46 super(PolymerCalculatorPage, self).__init__(
29 url=('http://www.polymer-project.org/components/paper-calculator/' 47 url=('http://www.polymer-project.org/components/paper-calculator/'
30 'demo.html'), 48 'demo.html'),
31 page_set=page_set) 49 page_set=page_set, run_no_page_interactions=run_no_page_interactions)
32 50
33 def RunPageInteractions(self, action_runner): 51 def PerformPageInteractions(self, action_runner):
34 self.TapButton(action_runner) 52 self.TapButton(action_runner)
35 self.SlidePanel(action_runner) 53 self.SlidePanel(action_runner)
36 54
37 def TapButton(self, action_runner): 55 def TapButton(self, action_runner):
38 interaction = action_runner.BeginInteraction( 56 interaction = action_runner.BeginInteraction(
39 'Action_TapAction', is_smooth=True) 57 'Action_TapAction', is_smooth=True)
40 action_runner.TapElement(element_function=''' 58 action_runner.TapElement(element_function='''
41 document.querySelector( 59 document.querySelector(
42 'body /deep/ #outerPanels' 60 'body /deep/ #outerPanels'
43 ).querySelector( 61 ).querySelector(
(...skipping 26 matching lines...) Expand all
70 '.handle-bar' 88 '.handle-bar'
71 )''') 89 )''')
72 action_runner.WaitForJavaScriptCondition(''' 90 action_runner.WaitForJavaScriptCondition('''
73 var outer = document.querySelector("body /deep/ #outerPanels"); 91 var outer = document.querySelector("body /deep/ #outerPanels");
74 outer.opened || outer.wideMode;''') 92 outer.opened || outer.wideMode;''')
75 interaction.End() 93 interaction.End()
76 94
77 95
78 class PolymerShadowPage(PolymerPage): 96 class PolymerShadowPage(PolymerPage):
79 97
80 def __init__(self, page_set): 98 def __init__(self, page_set, run_no_page_interactions):
81 super(PolymerShadowPage, self).__init__( 99 super(PolymerShadowPage, self).__init__(
82 url='http://www.polymer-project.org/components/paper-shadow/demo.html', 100 url='http://www.polymer-project.org/components/paper-shadow/demo.html',
83 page_set=page_set) 101 page_set=page_set, run_no_page_interactions=run_no_page_interactions)
84 102
85 def RunPageInteractions(self, action_runner): 103 def PerformPageInteractions(self, action_runner):
86 action_runner.ExecuteJavaScript( 104 action_runner.ExecuteJavaScript(
87 "document.getElementById('fab').scrollIntoView()") 105 "document.getElementById('fab').scrollIntoView()")
88 action_runner.Wait(5) 106 action_runner.Wait(5)
89 self.AnimateShadow(action_runner, 'card') 107 self.AnimateShadow(action_runner, 'card')
90 #FIXME(wiltzius) disabling until this issue is fixed: 108 #FIXME(wiltzius) disabling until this issue is fixed:
91 # https://github.com/Polymer/paper-shadow/issues/12 109 # https://github.com/Polymer/paper-shadow/issues/12
92 #self.AnimateShadow(action_runner, 'fab') 110 #self.AnimateShadow(action_runner, 'fab')
93 111
94 def AnimateShadow(self, action_runner, eid): 112 def AnimateShadow(self, action_runner, eid):
95 for i in range(1, 6): 113 for i in range(1, 6):
96 action_runner.ExecuteJavaScript( 114 action_runner.ExecuteJavaScript(
97 'document.getElementById("{0}").z = {1}'.format(eid, i)) 115 'document.getElementById("{0}").z = {1}'.format(eid, i))
98 action_runner.Wait(1) 116 action_runner.Wait(1)
99 117
100 118
101 class PolymerSampler(PolymerPage): 119 class PolymerSampler(PolymerPage):
102 120
103 def __init__(self, page_set, anchor, scrolling_page=False): 121 def __init__(self, page_set, anchor, run_no_page_interactions,
122 scrolling_page=False):
104 """Page exercising interactions with a single Paper Sampler subpage. 123 """Page exercising interactions with a single Paper Sampler subpage.
105 124
106 Args: 125 Args:
107 page_set: Page set to inforporate this page into. 126 page_set: Page set to inforporate this page into.
108 anchor: string indicating which subpage to load (matches the element 127 anchor: string indicating which subpage to load (matches the element
109 type that page is displaying) 128 type that page is displaying)
110 scrolling_page: Whether scrolling the content pane is relevant to this 129 scrolling_page: Whether scrolling the content pane is relevant to this
111 content page or not. 130 content page or not.
112 """ 131 """
113 super(PolymerSampler, self).__init__( 132 super(PolymerSampler, self).__init__(
114 url=('http://www.polymer-project.org/components/%s/demo.html' % anchor), 133 url=('http://www.polymer-project.org/components/%s/demo.html' % anchor),
115 page_set=page_set) 134 page_set=page_set, run_no_page_interactions=run_no_page_interactions)
116 self.scrolling_page = scrolling_page 135 self.scrolling_page = scrolling_page
117 self.iframe_js = 'document' 136 self.iframe_js = 'document'
118 137
119 def RunNavigateSteps(self, action_runner): 138 def RunNavigateSteps(self, action_runner):
120 super(PolymerSampler, self).RunNavigateSteps(action_runner) 139 super(PolymerSampler, self).RunNavigateSteps(action_runner)
121 waitForLoadJS = """ 140 waitForLoadJS = """
122 window.Polymer.whenPolymerReady(function() { 141 window.Polymer.whenPolymerReady(function() {
123 %s.contentWindow.Polymer.whenPolymerReady(function() { 142 %s.contentWindow.Polymer.whenPolymerReady(function() {
124 window.__polymer_ready = true; 143 window.__polymer_ready = true;
125 }) 144 })
126 }); 145 });
127 """ % self.iframe_js 146 """ % self.iframe_js
128 action_runner.ExecuteJavaScript(waitForLoadJS) 147 action_runner.ExecuteJavaScript(waitForLoadJS)
129 action_runner.WaitForJavaScriptCondition( 148 action_runner.WaitForJavaScriptCondition(
130 'window.__polymer_ready') 149 'window.__polymer_ready')
131 150
132 def RunPageInteractions(self, action_runner): 151 def PerformPageInteractions(self, action_runner):
133 #TODO(wiltzius) Add interactions for input elements and shadow pages 152 #TODO(wiltzius) Add interactions for input elements and shadow pages
134 if self.scrolling_page: 153 if self.scrolling_page:
135 # Only bother scrolling the page if its been marked as worthwhile 154 # Only bother scrolling the page if its been marked as worthwhile
136 self.ScrollContentPane(action_runner) 155 self.ScrollContentPane(action_runner)
137 self.TouchEverything(action_runner) 156 self.TouchEverything(action_runner)
138 157
139 def ScrollContentPane(self, action_runner): 158 def ScrollContentPane(self, action_runner):
140 element_function = (self.iframe_js + '.querySelector(' 159 element_function = (self.iframe_js + '.querySelector('
141 '"core-scroll-header-panel").$.mainContainer') 160 '"core-scroll-header-panel").$.mainContainer')
142 interaction = action_runner.BeginInteraction('Scroll_Page', is_smooth=True) 161 interaction = action_runner.BeginInteraction('Scroll_Page', is_smooth=True)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 interaction = action_runner.BeginInteraction( 216 interaction = action_runner.BeginInteraction(
198 'Swipe_Widget', is_smooth=True) 217 'Swipe_Widget', is_smooth=True)
199 action_runner.SwipeElement(element_function=element_function, 218 action_runner.SwipeElement(element_function=element_function,
200 left_start_ratio=0.75, 219 left_start_ratio=0.75,
201 speed_in_pixels_per_second=300) 220 speed_in_pixels_per_second=300)
202 interaction.End() 221 interaction.End()
203 222
204 223
205 class PolymerPageSet(page_set_module.PageSet): 224 class PolymerPageSet(page_set_module.PageSet):
206 225
207 def __init__(self): 226 def __init__(self, run_no_page_interactions=False):
208 super(PolymerPageSet, self).__init__( 227 super(PolymerPageSet, self).__init__(
209 user_agent_type='mobile', 228 user_agent_type='mobile',
210 archive_data_file='data/polymer.json', 229 archive_data_file='data/polymer.json',
211 bucket=page_set_module.PUBLIC_BUCKET) 230 bucket=page_set_module.PUBLIC_BUCKET)
212 231
213 self.AddUserStory(PolymerCalculatorPage(self)) 232 self.AddUserStory(PolymerCalculatorPage(self, run_no_page_interactions))
214 self.AddUserStory(PolymerShadowPage(self)) 233 self.AddUserStory(PolymerShadowPage(self, run_no_page_interactions))
215 234
216 # Polymer Sampler subpages that are interesting to tap / swipe elements on 235 # Polymer Sampler subpages that are interesting to tap / swipe elements on
217 TAPPABLE_PAGES = [ 236 TAPPABLE_PAGES = [
218 'paper-button', 237 'paper-button',
219 'paper-checkbox', 238 'paper-checkbox',
220 'paper-fab', 239 'paper-fab',
221 'paper-icon-button', 240 'paper-icon-button',
222 # crbug.com/394756 241 # crbug.com/394756
223 # 'paper-radio-button', 242 # 'paper-radio-button',
224 #FIXME(wiltzius) Disabling x-shadow until this issue is fixed: 243 #FIXME(wiltzius) Disabling x-shadow until this issue is fixed:
225 # https://github.com/Polymer/paper-shadow/issues/12 244 # https://github.com/Polymer/paper-shadow/issues/12
226 #'paper-shadow', 245 #'paper-shadow',
227 'paper-tabs', 246 'paper-tabs',
228 'paper-toggle-button', 247 'paper-toggle-button',
229 ] 248 ]
230 for p in TAPPABLE_PAGES: 249 for p in TAPPABLE_PAGES:
231 self.AddUserStory(PolymerSampler(self, p)) 250 self.AddUserStory(PolymerSampler(
251 self, p, run_no_page_interactions=run_no_page_interactions))
232 252
233 # Polymer Sampler subpages that are interesting to scroll 253 # Polymer Sampler subpages that are interesting to scroll
234 SCROLLABLE_PAGES = [ 254 SCROLLABLE_PAGES = [
235 'core-scroll-header-panel', 255 'core-scroll-header-panel',
236 ] 256 ]
237 for p in SCROLLABLE_PAGES: 257 for p in SCROLLABLE_PAGES:
238 self.AddUserStory(PolymerSampler(self, p, scrolling_page=True)) 258 self.AddUserStory(PolymerSampler(
259 self, p, run_no_page_interactions=run_no_page_interactions,
260 scrolling_page=True))
261
262 for page in self:
263 assert (page.__class__.RunPageInteractions ==
264 PolymerPage.RunPageInteractions), (
265 'Pages in this page set must not override PolymerPage\' '
266 'RunPageInteractions method.')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698