| 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 shared_page_state | 5 from telemetry.page import shared_page_state |
| 6 from telemetry import story | 6 from telemetry import story |
| 7 | 7 |
| 8 from page_sets import key_mobile_sites_pages | 8 from page_sets import key_mobile_sites_pages |
| 9 | 9 |
| 10 | 10 |
| 11 def _IssueMarkerAndScroll(action_runner): | 11 def _IssueMarkerAndScroll(action_runner): |
| 12 with action_runner.CreateGestureInteraction('ScrollAction'): | 12 with action_runner.CreateGestureInteraction('ScrollAction'): |
| 13 action_runner.ScrollPage() | 13 action_runner.ScrollPage() |
| 14 | 14 |
| 15 | 15 |
| 16 def _CreatePageClassWithSmoothInteractions(page_cls): | 16 def _CreatePageClassWithSmoothInteractions(page_cls): |
| 17 class DerivedSmoothPage(page_cls): # pylint: disable=no-init | 17 class DerivedSmoothPage(page_cls): # pylint: disable=no-init |
| 18 | 18 |
| 19 def RunPageInteractions(self, action_runner): | 19 def RunPageInteractions(self, action_runner): |
| 20 _IssueMarkerAndScroll(action_runner) | 20 _IssueMarkerAndScroll(action_runner) |
| 21 return DerivedSmoothPage | 21 return DerivedSmoothPage |
| 22 | 22 |
| 23 | 23 |
| 24 class KeyMobileSitesSmoothPage(page_module.Page): | 24 class KeyMobileSitesSmoothPage(page_module.Page): |
| 25 | 25 |
| 26 def __init__(self, url, page_set, name='', tags=None, | 26 def __init__(self, url, page_set, name='', tags=None, |
| 27 action_on_load_complete=False): | 27 action_on_load_complete=False): |
| 28 if name == '': |
| 29 name = url |
| 28 super(KeyMobileSitesSmoothPage, self).__init__( | 30 super(KeyMobileSitesSmoothPage, self).__init__( |
| 29 url=url, page_set=page_set, name=name, | 31 url=url, page_set=page_set, name=name, |
| 30 credentials_path='data/credentials.json', tags=tags, | 32 credentials_path='data/credentials.json', tags=tags, |
| 31 shared_page_state_class=shared_page_state.SharedMobilePageState) | 33 shared_page_state_class=shared_page_state.SharedMobilePageState) |
| 32 self.archive_data_file = 'data/key_mobile_sites.json' | 34 self.archive_data_file = 'data/key_mobile_sites.json' |
| 33 self.action_on_load_complete = action_on_load_complete | 35 self.action_on_load_complete = action_on_load_complete |
| 34 | 36 |
| 35 def RunPageInteractions(self, action_runner): | 37 def RunPageInteractions(self, action_runner): |
| 36 if self.action_on_load_complete: | 38 if self.action_on_load_complete: |
| 37 action_runner.WaitForJavaScriptCondition( | 39 action_runner.WaitForJavaScriptCondition( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 # will not be in the root scroller. | 136 # will not be in the root scroller. |
| 135 action_runner.ScrollPage(top_start_ratio=0.01) | 137 action_runner.ScrollPage(top_start_ratio=0.01) |
| 136 | 138 |
| 137 class KeyMobileSitesSmoothPageSet(story.StorySet): | 139 class KeyMobileSitesSmoothPageSet(story.StorySet): |
| 138 | 140 |
| 139 """ Key mobile sites with smooth interactions. """ | 141 """ Key mobile sites with smooth interactions. """ |
| 140 | 142 |
| 141 def __init__(self): | 143 def __init__(self): |
| 142 super(KeyMobileSitesSmoothPageSet, self).__init__( | 144 super(KeyMobileSitesSmoothPageSet, self).__init__( |
| 143 archive_data_file='data/key_mobile_sites_smooth.json', | 145 archive_data_file='data/key_mobile_sites_smooth.json', |
| 144 cloud_storage_bucket=story.PARTNER_BUCKET) | 146 cloud_storage_bucket=story.PARTNER_BUCKET, |
| 147 verify_names=True) |
| 145 | 148 |
| 146 | 149 |
| 147 # Add pages with predefined classes that contain custom navigation logic. | 150 # Add pages with predefined classes that contain custom navigation logic. |
| 148 predefined_page_classes = [ | 151 predefined_page_classes = [ |
| 149 key_mobile_sites_pages.CapitolVolkswagenPage, | 152 key_mobile_sites_pages.CapitolVolkswagenPage, |
| 150 key_mobile_sites_pages.TheVergeArticlePage, | 153 key_mobile_sites_pages.TheVergeArticlePage, |
| 151 key_mobile_sites_pages.FacebookPage, | 154 key_mobile_sites_pages.FacebookPage, |
| 152 key_mobile_sites_pages.YoutubeMobilePage, | 155 key_mobile_sites_pages.YoutubeMobilePage, |
| 153 key_mobile_sites_pages.YahooAnswersPage, | 156 key_mobile_sites_pages.YahooAnswersPage, |
| 154 key_mobile_sites_pages.GoogleNewsMobilePage, | 157 key_mobile_sites_pages.GoogleNewsMobilePage, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&' | 287 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&' |
| 285 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'), | 288 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'), |
| 286 # Why: Top search engine | 289 # Why: Top search engine |
| 287 'http://www.bing.com/search?q=sloths', | 290 'http://www.bing.com/search?q=sloths', |
| 288 # Why: Good example of poor initial scrolling | 291 # Why: Good example of poor initial scrolling |
| 289 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans' | 292 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans' |
| 290 ] | 293 ] |
| 291 | 294 |
| 292 for url in urls_list: | 295 for url in urls_list: |
| 293 self.AddStory(KeyMobileSitesSmoothPage(url, self)) | 296 self.AddStory(KeyMobileSitesSmoothPage(url, self)) |
| OLD | NEW |