ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / tools / perf / page_sets / key_mobile_sites_smooth.py
blob918e46ddcddf911e16e733b5e51637addf9aa090
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
3 # found in the LICENSE file.
4 from telemetry.page import page as page_module
5 from telemetry.page import page_set as page_set_module
7 from page_sets import key_mobile_sites_pages
10 def _IssueMarkerAndScroll(action_runner):
11 interaction = action_runner.BeginGestureInteraction(
12 'ScrollAction', is_smooth=True)
13 action_runner.ScrollPage()
14 interaction.End()
17 def _CreatePageClassWithSmoothInteractions(page_cls):
18 class DerivedSmoothPage(page_cls): # pylint: disable=W0232
20 def RunPageInteractions(self, action_runner):
21 _IssueMarkerAndScroll(action_runner)
22 return DerivedSmoothPage
25 class KeyMobileSitesSmoothPage(page_module.Page):
27 def __init__(self, url, page_set, name='', labels=None,
28 action_on_load_complete=False):
29 super(KeyMobileSitesSmoothPage, self).__init__(
30 url=url, page_set=page_set, name=name,
31 credentials_path='data/credentials.json', labels=labels)
32 self.user_agent_type = 'mobile'
33 self.archive_data_file = 'data/key_mobile_sites.json'
34 self.action_on_load_complete = action_on_load_complete
36 def RunPageInteractions(self, action_runner):
37 if self.action_on_load_complete:
38 action_runner.WaitForJavaScriptCondition(
39 'document.readyState == "complete"', 30)
40 _IssueMarkerAndScroll(action_runner)
43 class GmailSmoothPage(key_mobile_sites_pages.GmailPage):
45 def RunPageInteractions(self, action_runner):
46 interaction = action_runner.BeginGestureInteraction(
47 'ScrollAction', is_smooth=True)
48 action_runner.ScrollElement(element_function=(
49 'document.getElementById("views").childNodes[1].firstChild'))
50 interaction.End()
51 interaction = action_runner.BeginGestureInteraction(
52 'ScrollAction', is_smooth=True)
53 action_runner.ScrollElement(element_function=(
54 'document.getElementById("views").childNodes[1].firstChild'))
55 interaction.End()
58 class GroupClonedSmoothPage(key_mobile_sites_pages.GroupClonedPage):
60 def RunPageInteractions(self, action_runner):
61 interaction = action_runner.BeginGestureInteraction(
62 'ScrollAction', is_smooth=True)
63 action_runner.ScrollPage(
64 distance_expr='''
65 Math.max(0, 1250 + document.getElementById("element-19")
66 .contentDocument
67 .getElementById("element-22")
68 .getBoundingClientRect().top);''',
69 use_touch=True)
70 interaction.End()
73 class GroupClonedListImagesPage(
74 key_mobile_sites_pages.GroupClonedListImagesPage):
76 def RunPageInteractions(self, action_runner):
77 interaction = action_runner.BeginGestureInteraction(
78 'ScrollAction', is_smooth=True)
79 action_runner.ScrollPage(
80 distance_expr='''
81 Math.max(0, 1250 +
82 document.getElementById("element-5")
83 .getBoundingClientRect().top);''',
84 use_touch=True)
85 interaction.End()
87 class GoogleNewsMobile2SmoothPage(
88 key_mobile_sites_pages.GoogleNewsMobile2Page):
90 def RunPageInteractions(self, action_runner):
91 interaction = action_runner.BeginGestureInteraction(
92 'ScrollAction', is_smooth=True)
93 action_runner.ScrollElement(
94 element_function='document.getElementById(":5")',
95 distance_expr='''
96 Math.max(0, 2500 +
97 document.getElementById(':h').getBoundingClientRect().top)''',
98 use_touch=True)
99 interaction.End()
102 class AmazonNicolasCageSmoothPage(
103 key_mobile_sites_pages.AmazonNicolasCagePage):
105 def RunPageInteractions(self, action_runner):
106 interaction = action_runner.BeginGestureInteraction(
107 'ScrollAction', is_smooth=True)
108 action_runner.ScrollElement(
109 selector='#search',
110 distance_expr='document.body.scrollHeight - window.innerHeight')
111 interaction.End()
114 class KeyMobileSitesSmoothPageSet(page_set_module.PageSet):
116 """ Key mobile sites with smooth interactions. """
118 def __init__(self):
119 super(KeyMobileSitesSmoothPageSet, self).__init__(
120 user_agent_type='mobile',
121 archive_data_file='data/key_mobile_sites_smooth.json',
122 bucket=page_set_module.PARTNER_BUCKET)
125 # Add pages with predefined classes that contain custom navigation logic.
126 predefined_page_classes = [
127 key_mobile_sites_pages.CapitolVolkswagenPage,
128 key_mobile_sites_pages.TheVergeArticlePage,
129 key_mobile_sites_pages.CnnArticlePage,
130 key_mobile_sites_pages.FacebookPage,
131 key_mobile_sites_pages.YoutubeMobilePage,
132 key_mobile_sites_pages.LinkedInPage,
133 key_mobile_sites_pages.YahooAnswersPage,
134 key_mobile_sites_pages.GoogleNewsMobilePage,
136 for page_class in predefined_page_classes:
137 self.AddUserStory(
138 _CreatePageClassWithSmoothInteractions(page_class)(self))
140 # Add pages with custom page interaction logic.
142 # Page behaves non-deterministically, replaced with test version for now.
143 # self.AddUserStory(GroupClonedSmoothPage(self))
144 # mean_input_event_latency cannot be tracked correctly for
145 # GroupClonedListImagesPage.
146 # See crbug.com/409086.
147 # self.AddUserStory(GroupClonedListImagesSmoothPage(self))
148 self.AddUserStory(GoogleNewsMobile2SmoothPage(self))
149 self.AddUserStory(AmazonNicolasCageSmoothPage(self))
151 # Add pages with custom labels.
153 # Why: Top news site.
154 self.AddUserStory(KeyMobileSitesSmoothPage(
155 url='http://nytimes.com/', page_set=self, labels=['fastpath']))
157 # Why: Image-heavy site.
158 self.AddUserStory(KeyMobileSitesSmoothPage(
159 url='http://cuteoverload.com', page_set=self, labels=['fastpath']))
161 # Why: #11 (Alexa global), google property; some blogger layouts
162 # have infinite scroll but more interesting.
163 self.AddUserStory(KeyMobileSitesSmoothPage(
164 url='http://googlewebmastercentral.blogspot.com/',
165 page_set=self, name='Blogger'))
167 # Why: #18 (Alexa global), Picked an interesting post """
168 self.AddUserStory(KeyMobileSitesSmoothPage(
169 # pylint: disable=line-too-long
170 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
171 page_set=self,
172 name='Wordpress'))
174 # Why: #6 (Alexa) most visited worldwide, picked an interesting page
175 self.AddUserStory(KeyMobileSitesSmoothPage(
176 url='http://en.wikipedia.org/wiki/Wikipedia',
177 page_set=self,
178 name='Wikipedia (1 tab)'))
180 # Why: Wikipedia page with a delayed scroll start
181 self.AddUserStory(KeyMobileSitesSmoothPage(
182 url='http://en.wikipedia.org/wiki/Wikipedia',
183 page_set=self,
184 name='Wikipedia (1 tab) - delayed scroll start',
185 action_on_load_complete=True))
187 # Why: #8 (Alexa global), picked an interesting page
188 # Forbidden (Rate Limit Exceeded)
189 # self.AddUserStory(KeyMobileSitesSmoothPage(
190 # url='http://twitter.com/katyperry', page_set=self, name='Twitter'))
192 # Why: #37 (Alexa global) """
193 self.AddUserStory(KeyMobileSitesSmoothPage(
194 url='http://pinterest.com',
195 page_set=self,
196 name='Pinterest'))
198 # Why: #1 sports.
199 # Fails often; crbug.com/249722'
200 # self.AddUserStory(KeyMobileSitesSmoothPage(
201 # url='http://espn.go.com', page_set=self, name='ESPN'))
202 # Why: crbug.com/231413
203 # Doesn't scroll; crbug.com/249736
204 # self.AddUserStory(KeyMobileSitesSmoothPage(
205 # url='http://forecast.io', page_set=self))
206 # Why: crbug.com/169827
207 self.AddUserStory(KeyMobileSitesSmoothPage(
208 url='http://slashdot.org/', page_set=self, labels=['fastpath']))
210 # Why: #5 Alexa news """
212 self.AddUserStory(KeyMobileSitesSmoothPage(
213 url='http://www.reddit.com/r/programming/comments/1g96ve',
214 page_set=self, labels=['fastpath']))
216 # Why: Problematic use of fixed position elements """
217 self.AddUserStory(KeyMobileSitesSmoothPage(
218 url='http://www.boingboing.net', page_set=self, labels=['fastpath']))
220 # Add simple pages with no custom navigation logic or labels.
221 urls_list = [
222 # Why: Social; top Google property; Public profile; infinite scrolls.
223 # pylint: disable=line-too-long
224 'https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
225 # Why: crbug.com/242544
226 ('http://www.androidpolice.com/2012/10/03/rumor-evidence-mounts-that-an-'
227 'lg-optimus-g-nexus-is-coming-along-with-a-nexus-phone-certification-'
228 'program/'),
229 # Why: crbug.com/149958
230 'http://gsp.ro',
231 # Why: Top tech blog
232 'http://theverge.com',
233 # Why: Top tech site
234 'http://digg.com',
235 # Why: Top Google property; a Google tab is often open
236 'https://www.google.com/#hl=en&q=barack+obama',
237 # Why: #1 news worldwide (Alexa global)
238 'http://news.yahoo.com',
239 # Why: #2 news worldwide
240 'http://www.cnn.com',
241 # Why: #1 commerce website by time spent by users in US
242 'http://shop.mobileweb.ebay.com/searchresults?kw=viking+helmet',
243 # Why: #1 Alexa recreation
244 # pylint: disable=line-too-long
245 'http://www.booking.com/searchresults.html?src=searchresults&latitude=65.0500&longitude=25.4667',
246 # Why: #1 Alexa sports
247 'http://sports.yahoo.com/',
248 # Why: Top tech blog
249 'http://techcrunch.com',
250 # Why: #6 Alexa sports
251 'http://mlb.com/',
252 # Why: #14 Alexa California
253 'http://www.sfgate.com/',
254 # Why: Non-latin character set
255 'http://worldjournal.com/',
256 # Why: Mobile wiki
257 'http://www.wowwiki.com/World_of_Warcraft:_Mists_of_Pandaria',
258 # Why: #15 Alexa news
259 'http://online.wsj.com/home-page',
260 # Why: Image-heavy mobile site
261 'http://www.deviantart.com/',
262 # Why: Top search engine
263 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&'
264 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'),
265 # Why: Top search engine
266 'http://www.bing.com/search?q=sloths',
267 # Why: Good example of poor initial scrolling
268 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans'
271 for url in urls_list:
272 self.AddUserStory(KeyMobileSitesSmoothPage(url, self))