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 from page_sets import key_mobile_sites_pages | 7 from page_sets import key_mobile_sites_pages |
8 | 8 |
9 | 9 |
10 def _IssueMarkerAndScroll(action_runner): | 10 def _IssueMarkerAndScroll(action_runner): |
11 interaction = action_runner.BeginGestureInteraction( | 11 interaction = action_runner.BeginGestureInteraction( |
12 'ScrollAction', is_smooth=True) | 12 'ScrollAction', is_smooth=True) |
13 action_runner.ScrollPage() | 13 action_runner.ScrollPage() |
14 interaction.End() | 14 interaction.End() |
15 | 15 |
16 | 16 |
17 def _CreatePageClassWithSmoothInteractions(page_cls): | 17 def _CreatePageClassWithSmoothInteractions(page_cls): |
18 class DerivedSmoothPage(page_cls): # pylint: disable=W0232 | 18 class DerivedSmoothPage(page_cls): # pylint: disable=W0232 |
19 | 19 |
20 def RunPageInteractions(self, action_runner): | 20 def RunPageInteractions(self, action_runner): |
21 _IssueMarkerAndScroll(action_runner) | 21 _IssueMarkerAndScroll(action_runner) |
22 return DerivedSmoothPage | 22 return DerivedSmoothPage |
23 | 23 |
24 | 24 |
25 class KeyMobileSitesSmoothPage(page_module.Page): | 25 class KeyMobileSitesSmoothPage(page_module.Page): |
26 | 26 |
27 def __init__(self, url, page_set, name='', labels=None): | 27 def __init__(self, url, page_set, name='', labels=None, |
28 action_on_load_complete=False): | |
28 super(KeyMobileSitesSmoothPage, self).__init__( | 29 super(KeyMobileSitesSmoothPage, self).__init__( |
29 url=url, page_set=page_set, name=name, | 30 url=url, page_set=page_set, name=name, |
30 credentials_path='data/credentials.json', labels=labels) | 31 credentials_path='data/credentials.json', labels=labels) |
31 self.user_agent_type = 'mobile' | 32 self.user_agent_type = 'mobile' |
32 self.archive_data_file = 'data/key_mobile_sites.json' | 33 self.archive_data_file = 'data/key_mobile_sites.json' |
34 self.action_on_load_complete = action_on_load_complete | |
33 | 35 |
34 def RunPageInteractions(self, action_runner): | 36 def RunPageInteractions(self, action_runner): |
37 if self.action_on_load_complete: | |
38 action_runner.WaitForJavaScriptCondition( | |
39 'document.readyState == "complete"', 30) | |
35 _IssueMarkerAndScroll(action_runner) | 40 _IssueMarkerAndScroll(action_runner) |
36 | 41 |
37 | 42 |
38 class GmailSmoothPage(key_mobile_sites_pages.GmailPage): | 43 class GmailSmoothPage(key_mobile_sites_pages.GmailPage): |
39 | 44 |
40 def RunPageInteractions(self, action_runner): | 45 def RunPageInteractions(self, action_runner): |
41 interaction = action_runner.BeginGestureInteraction( | 46 interaction = action_runner.BeginGestureInteraction( |
42 'ScrollAction', is_smooth=True) | 47 'ScrollAction', is_smooth=True) |
43 action_runner.ScrollElement(element_function=( | 48 action_runner.ScrollElement(element_function=( |
44 'document.getElementById("views").childNodes[1].firstChild')) | 49 'document.getElementById("views").childNodes[1].firstChild')) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 url='http://googlewebmastercentral.blogspot.com/', | 164 url='http://googlewebmastercentral.blogspot.com/', |
160 page_set=self, name='Blogger')) | 165 page_set=self, name='Blogger')) |
161 | 166 |
162 # Why: #18 (Alexa global), Picked an interesting post """ | 167 # Why: #18 (Alexa global), Picked an interesting post """ |
163 self.AddUserStory(KeyMobileSitesSmoothPage( | 168 self.AddUserStory(KeyMobileSitesSmoothPage( |
164 # pylint: disable=line-too-long | 169 # pylint: disable=line-too-long |
165 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks -for-august-2012/', | 170 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks -for-august-2012/', |
166 page_set=self, | 171 page_set=self, |
167 name='Wordpress')) | 172 name='Wordpress')) |
168 | 173 |
169 # Why: #6 (Alexa) most visited worldwide, picked an interesting page | 174 # Why: #6 (Alexa) most visited worldwide, picked an interesting page |
170 self.AddUserStory(KeyMobileSitesSmoothPage( | 175 self.AddUserStory(KeyMobileSitesSmoothPage( |
171 url='http://en.wikipedia.org/wiki/Wikipedia', | 176 url='http://en.wikipedia.org/wiki/Wikipedia', |
172 page_set=self, | 177 page_set=self, |
173 name='Wikipedia (1 tab)')) | 178 name='Wikipedia (1 tab)')) |
jdduke (slow)
2015/02/05 21:51:29
What is this "1 tab" modifier all about?
Yufeng Shen (Slow to review)
2015/02/05 21:52:43
no idea, I guess just some historical naming.
| |
174 | 179 |
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)) | |
175 | 186 |
176 # Why: #8 (Alexa global), picked an interesting page | 187 # Why: #8 (Alexa global), picked an interesting page |
177 # Forbidden (Rate Limit Exceeded) | 188 # Forbidden (Rate Limit Exceeded) |
178 # self.AddUserStory(KeyMobileSitesSmoothPage( | 189 # self.AddUserStory(KeyMobileSitesSmoothPage( |
179 # url='http://twitter.com/katyperry', page_set=self, name='Twitter')) | 190 # url='http://twitter.com/katyperry', page_set=self, name='Twitter')) |
180 | 191 |
181 # Why: #37 (Alexa global) """ | 192 # Why: #37 (Alexa global) """ |
182 self.AddUserStory(KeyMobileSitesSmoothPage( | 193 self.AddUserStory(KeyMobileSitesSmoothPage( |
183 url='http://pinterest.com', | 194 url='http://pinterest.com', |
184 page_set=self, | 195 page_set=self, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&' | 263 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&' |
253 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'), | 264 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'), |
254 # Why: Top search engine | 265 # Why: Top search engine |
255 'http://www.bing.com/search?q=sloths', | 266 'http://www.bing.com/search?q=sloths', |
256 # Why: Good example of poor initial scrolling | 267 # Why: Good example of poor initial scrolling |
257 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans' | 268 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans' |
258 ] | 269 ] |
259 | 270 |
260 for url in urls_list: | 271 for url in urls_list: |
261 self.AddUserStory(KeyMobileSitesSmoothPage(url, self)) | 272 self.AddUserStory(KeyMobileSitesSmoothPage(url, self)) |
OLD | NEW |