| 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 top_pages | 7 from page_sets import top_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 RunSmoothness(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 TopSmoothPage(page_module.Page): | 25 class TopSmoothPage(page_module.Page): |
| 26 | 26 |
| 27 def __init__(self, url, page_set, name='', credentials=None): | 27 def __init__(self, url, page_set, name='', credentials=None): |
| 28 super(TopSmoothPage, self).__init__( | 28 super(TopSmoothPage, self).__init__( |
| 29 url=url, page_set=page_set, name=name, | 29 url=url, page_set=page_set, name=name, |
| 30 credentials_path='data/credentials.json') | 30 credentials_path='data/credentials.json') |
| 31 self.user_agent_type = 'desktop' | 31 self.user_agent_type = 'desktop' |
| 32 self.credentials = credentials | 32 self.credentials = credentials |
| 33 | 33 |
| 34 def RunSmoothness(self, action_runner): | 34 def RunPageInteractions(self, action_runner): |
| 35 _IssueMarkerAndScroll(action_runner) | 35 _IssueMarkerAndScroll(action_runner) |
| 36 | 36 |
| 37 | 37 |
| 38 class GmailSmoothPage(top_pages.GmailPage): | 38 class GmailSmoothPage(top_pages.GmailPage): |
| 39 | 39 |
| 40 """ Why: productivity, top google properties """ | 40 """ Why: productivity, top google properties """ |
| 41 | 41 |
| 42 def RunSmoothness(self, action_runner): | 42 def RunPageInteractions(self, action_runner): |
| 43 action_runner.ExecuteJavaScript(''' | 43 action_runner.ExecuteJavaScript(''' |
| 44 gmonkey.load('2.0', function(api) { | 44 gmonkey.load('2.0', function(api) { |
| 45 window.__scrollableElementForTelemetry = api.getScrollableElement(); | 45 window.__scrollableElementForTelemetry = api.getScrollableElement(); |
| 46 });''') | 46 });''') |
| 47 action_runner.WaitForJavaScriptCondition( | 47 action_runner.WaitForJavaScriptCondition( |
| 48 'window.__scrollableElementForTelemetry != null') | 48 'window.__scrollableElementForTelemetry != null') |
| 49 interaction = action_runner.BeginGestureInteraction( | 49 interaction = action_runner.BeginGestureInteraction( |
| 50 'ScrollAction', is_smooth=True) | 50 'ScrollAction', is_smooth=True) |
| 51 action_runner.ScrollElement( | 51 action_runner.ScrollElement( |
| 52 element_function='window.__scrollableElementForTelemetry') | 52 element_function='window.__scrollableElementForTelemetry') |
| 53 interaction.End() | 53 interaction.End() |
| 54 | 54 |
| 55 | 55 |
| 56 class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): | 56 class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): |
| 57 | 57 |
| 58 """ Why: productivity, top google properties """ | 58 """ Why: productivity, top google properties """ |
| 59 | 59 |
| 60 def RunSmoothness(self, action_runner): | 60 def RunPageInteractions(self, action_runner): |
| 61 interaction = action_runner.BeginGestureInteraction( | 61 interaction = action_runner.BeginGestureInteraction( |
| 62 'ScrollAction', is_smooth=True) | 62 'ScrollAction', is_smooth=True) |
| 63 action_runner.ScrollElement(selector='#scrolltimedeventswk') | 63 action_runner.ScrollElement(selector='#scrolltimedeventswk') |
| 64 interaction.End() | 64 interaction.End() |
| 65 | 65 |
| 66 | 66 |
| 67 class GoogleDocSmoothPage(top_pages.GoogleDocPage): | 67 class GoogleDocSmoothPage(top_pages.GoogleDocPage): |
| 68 | 68 |
| 69 """ Why: productivity, top google properties; Sample doc in the link """ | 69 """ Why: productivity, top google properties; Sample doc in the link """ |
| 70 | 70 |
| 71 def RunSmoothness(self, action_runner): | 71 def RunPageInteractions(self, action_runner): |
| 72 interaction = action_runner.BeginGestureInteraction( | 72 interaction = action_runner.BeginGestureInteraction( |
| 73 'ScrollAction', is_smooth=True) | 73 'ScrollAction', is_smooth=True) |
| 74 action_runner.ScrollElement(selector='.kix-appview-editor') | 74 action_runner.ScrollElement(selector='.kix-appview-editor') |
| 75 interaction.End() | 75 interaction.End() |
| 76 | 76 |
| 77 | 77 |
| 78 class ESPNSmoothPage(top_pages.ESPNPage): | 78 class ESPNSmoothPage(top_pages.ESPNPage): |
| 79 | 79 |
| 80 """ Why: #1 sports """ | 80 """ Why: #1 sports """ |
| 81 | 81 |
| 82 def RunSmoothness(self, action_runner): | 82 def RunPageInteractions(self, action_runner): |
| 83 interaction = action_runner.BeginGestureInteraction( | 83 interaction = action_runner.BeginGestureInteraction( |
| 84 'ScrollAction', is_smooth=True) | 84 'ScrollAction', is_smooth=True) |
| 85 action_runner.ScrollPage(left_start_ratio=0.1) | 85 action_runner.ScrollPage(left_start_ratio=0.1) |
| 86 interaction.End() | 86 interaction.End() |
| 87 | 87 |
| 88 | 88 |
| 89 class Top25SmoothPageSet(page_set_module.PageSet): | 89 class Top25SmoothPageSet(page_set_module.PageSet): |
| 90 | 90 |
| 91 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """ | 91 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """ |
| 92 | 92 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 # Why: #1 Alexa reference | 142 # Why: #1 Alexa reference |
| 143 'http://answers.yahoo.com', | 143 'http://answers.yahoo.com', |
| 144 # Why: #1 Alexa sports | 144 # Why: #1 Alexa sports |
| 145 'http://sports.yahoo.com/', | 145 'http://sports.yahoo.com/', |
| 146 # Why: top tech blog | 146 # Why: top tech blog |
| 147 'http://techcrunch.com' | 147 'http://techcrunch.com' |
| 148 ] | 148 ] |
| 149 | 149 |
| 150 for url in other_urls: | 150 for url in other_urls: |
| 151 self.AddUserStory(TopSmoothPage(url, self)) | 151 self.AddUserStory(TopSmoothPage(url, self)) |
| OLD | NEW |