| 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): |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 GmailMouseScrollPage(top_pages.GmailPage): |
| 57 |
| 58 """ Why: productivity, top google properties """ |
| 59 |
| 60 def RunPageInteractions(self, action_runner): |
| 61 action_runner.ExecuteJavaScript(''' |
| 62 gmonkey.load('2.0', function(api) { |
| 63 window.__scrollableElementForTelemetry = api.getScrollableElement(); |
| 64 });''') |
| 65 action_runner.WaitForJavaScriptCondition( |
| 66 'window.__scrollableElementForTelemetry != null') |
| 67 scrollbar_x, start_y, end_y = self._CalculateScrollBarRatios(action_runner) |
| 68 |
| 69 interaction = action_runner.BeginGestureInteraction( |
| 70 'DragAction', is_smooth=True) |
| 71 action_runner.DragPage(left_start_ratio=scrollbar_x, |
| 72 top_start_ratio=start_y, left_end_ratio=scrollbar_x, |
| 73 top_end_ratio=end_y, speed_in_pixels_per_second=100, |
| 74 element_function='window.__scrollableElementForTelemetry') |
| 75 interaction.End() |
| 76 |
| 77 def CanRunOnBrowser(self, browser_info): |
| 78 return (browser_info._browser._platform_backend.platform.GetOSName() != |
| 79 'android') |
| 80 |
| 81 def _CalculateScrollBarRatios(self, action_runner): |
| 82 viewport_height = float(action_runner.EvaluateJavaScript( |
| 83 'window.__scrollableElementForTelemetry.clientHeight')) |
| 84 content_height = float(action_runner.EvaluateJavaScript( |
| 85 'window.__scrollableElementForTelemetry.scrollHeight')) |
| 86 viewport_width = float(action_runner.EvaluateJavaScript( |
| 87 'window.__scrollableElementForTelemetry.offsetWidth')) |
| 88 scrollbar_width = float(action_runner.EvaluateJavaScript(''' |
| 89 window.__scrollableElementForTelemetry.offsetWidth - |
| 90 window.__scrollableElementForTelemetry.scrollWidth''')) |
| 91 |
| 92 # This calculation is correct only when the element doesn't have border or |
| 93 # padding or scroll buttons (eg: gmail mail element). |
| 94 scrollbar_start_mid_y = viewport_height / (2 * content_height) |
| 95 scrollbar_end_mid_y = 1 - scrollbar_start_mid_y |
| 96 scrollbar_mid_x_offset = scrollbar_width / (2 * viewport_width) |
| 97 scrollbar_mid_x = 1 - scrollbar_mid_x_offset |
| 98 return scrollbar_mid_x, scrollbar_start_mid_y, scrollbar_end_mid_y |
| 99 |
| 100 |
| 56 class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): | 101 class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): |
| 57 | 102 |
| 58 """ Why: productivity, top google properties """ | 103 """ Why: productivity, top google properties """ |
| 59 | 104 |
| 60 def RunPageInteractions(self, action_runner): | 105 def RunPageInteractions(self, action_runner): |
| 61 interaction = action_runner.BeginGestureInteraction( | 106 interaction = action_runner.BeginGestureInteraction( |
| 62 'ScrollAction', is_smooth=True) | 107 'ScrollAction', is_smooth=True) |
| 63 action_runner.ScrollElement(selector='#scrolltimedeventswk') | 108 action_runner.ScrollElement(selector='#scrolltimedeventswk') |
| 64 interaction.End() | 109 interaction.End() |
| 65 | 110 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 156 |
| 112 def __init__(self): | 157 def __init__(self): |
| 113 super(Top25SmoothPageSet, self).__init__( | 158 super(Top25SmoothPageSet, self).__init__( |
| 114 user_agent_type='desktop', | 159 user_agent_type='desktop', |
| 115 archive_data_file='data/top_25_smooth.json', | 160 archive_data_file='data/top_25_smooth.json', |
| 116 bucket=page_set_module.PARTNER_BUCKET) | 161 bucket=page_set_module.PARTNER_BUCKET) |
| 117 | 162 |
| 118 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 163 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 119 top_pages.GoogleWebSearchPage)(self)) | 164 top_pages.GoogleWebSearchPage)(self)) |
| 120 self.AddUserStory(GmailSmoothPage(self)) | 165 self.AddUserStory(GmailSmoothPage(self)) |
| 166 self.AddUserStory(GmailMouseScrollPage(self)) |
| 121 self.AddUserStory(GoogleCalendarSmoothPage(self)) | 167 self.AddUserStory(GoogleCalendarSmoothPage(self)) |
| 122 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 168 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 123 top_pages.GoogleImageSearchPage)(self)) | 169 top_pages.GoogleImageSearchPage)(self)) |
| 124 self.AddUserStory(GoogleDocSmoothPage(self)) | 170 self.AddUserStory(GoogleDocSmoothPage(self)) |
| 125 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 171 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 126 top_pages.GooglePlusPage)(self)) | 172 top_pages.GooglePlusPage)(self)) |
| 127 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 173 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 128 top_pages.YoutubePage)(self)) | 174 top_pages.YoutubePage)(self)) |
| 129 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 175 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 130 top_pages.BlogspotPage)(self)) | 176 top_pages.BlogspotPage)(self)) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 # Why: #1 Alexa reference | 208 # Why: #1 Alexa reference |
| 163 'http://answers.yahoo.com', | 209 'http://answers.yahoo.com', |
| 164 # Why: #1 Alexa sports | 210 # Why: #1 Alexa sports |
| 165 'http://sports.yahoo.com/', | 211 'http://sports.yahoo.com/', |
| 166 # Why: top tech blog | 212 # Why: top tech blog |
| 167 'http://techcrunch.com' | 213 'http://techcrunch.com' |
| 168 ] | 214 ] |
| 169 | 215 |
| 170 for url in other_urls: | 216 for url in other_urls: |
| 171 self.AddUserStory(TopSmoothPage(url, self)) | 217 self.AddUserStory(TopSmoothPage(url, self)) |
| OLD | NEW |