| 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') | 50 'ScrollAction') |
| 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') | |
| 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 | |
| 101 class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): | 56 class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): |
| 102 | 57 |
| 103 """ Why: productivity, top google properties """ | 58 """ Why: productivity, top google properties """ |
| 104 | 59 |
| 105 def RunPageInteractions(self, action_runner): | 60 def RunPageInteractions(self, action_runner): |
| 106 interaction = action_runner.BeginGestureInteraction( | 61 interaction = action_runner.BeginGestureInteraction( |
| 107 'ScrollAction') | 62 'ScrollAction') |
| 108 action_runner.ScrollElement(selector='#scrolltimedeventswk') | 63 action_runner.ScrollElement(selector='#scrolltimedeventswk') |
| 109 interaction.End() | 64 interaction.End() |
| 110 | 65 |
| 111 | 66 |
| 112 class GoogleDocSmoothPage(top_pages.GoogleDocPage): | 67 class GoogleDocSmoothPage(top_pages.GoogleDocPage): |
| 113 | 68 |
| 114 """ Why: productivity, top google properties; Sample doc in the link """ | 69 """ Why: productivity, top google properties; Sample doc in the link """ |
| 115 | 70 |
| 116 def RunPageInteractions(self, action_runner): | 71 def RunPageInteractions(self, action_runner): |
| 117 interaction = action_runner.BeginGestureInteraction( | 72 interaction = action_runner.BeginGestureInteraction( |
| 118 'ScrollAction') | 73 'ScrollAction') |
| 119 action_runner.ScrollElement(selector='.kix-appview-editor') | 74 action_runner.ScrollElement(selector='.kix-appview-editor') |
| 120 interaction.End() | 75 interaction.End() |
| 121 | 76 |
| 122 | 77 |
| 123 class GoogleMapsPage(top_pages.GoogleMapsPage): | |
| 124 | |
| 125 """ Why: productivity, top google properties; Supports drag gestures """ | |
| 126 | |
| 127 def RunPageInteractions(self, action_runner): | |
| 128 interaction = action_runner.BeginGestureInteraction( | |
| 129 'DragAction', repeatable=True) | |
| 130 action_runner.DragPage(left_start_ratio=0.5, top_start_ratio=0.75, | |
| 131 left_end_ratio=0.75, top_end_ratio=0.5) | |
| 132 interaction.End() | |
| 133 action_runner.Wait(2) | |
| 134 interaction = action_runner.BeginGestureInteraction( | |
| 135 'DragAction', repeatable=True) | |
| 136 action_runner.DragPage(left_start_ratio=0.5, top_start_ratio=0.5, | |
| 137 left_end_ratio=0.35, top_end_ratio=0.75) | |
| 138 interaction.End() | |
| 139 # TODO(ssid): Add zoom gestures after fixing bug crbug.com/462214. | |
| 140 | |
| 141 | |
| 142 class ESPNSmoothPage(top_pages.ESPNPage): | 78 class ESPNSmoothPage(top_pages.ESPNPage): |
| 143 | 79 |
| 144 """ Why: #1 sports """ | 80 """ Why: #1 sports """ |
| 145 | 81 |
| 146 def RunPageInteractions(self, action_runner): | 82 def RunPageInteractions(self, action_runner): |
| 147 interaction = action_runner.BeginGestureInteraction( | 83 interaction = action_runner.BeginGestureInteraction( |
| 148 'ScrollAction') | 84 'ScrollAction') |
| 149 action_runner.ScrollPage(left_start_ratio=0.1) | 85 action_runner.ScrollPage(left_start_ratio=0.1) |
| 150 interaction.End() | 86 interaction.End() |
| 151 | 87 |
| 152 | 88 |
| 153 class Top25SmoothPageSet(page_set_module.PageSet): | 89 class Top25SmoothPageSet(page_set_module.PageSet): |
| 154 | 90 |
| 155 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """ | 91 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """ |
| 156 | 92 |
| 157 def __init__(self): | 93 def __init__(self): |
| 158 super(Top25SmoothPageSet, self).__init__( | 94 super(Top25SmoothPageSet, self).__init__( |
| 159 user_agent_type='desktop', | 95 user_agent_type='desktop', |
| 160 archive_data_file='data/top_25_smooth.json', | 96 archive_data_file='data/top_25_smooth.json', |
| 161 bucket=page_set_module.PARTNER_BUCKET) | 97 bucket=page_set_module.PARTNER_BUCKET) |
| 162 | 98 |
| 163 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 99 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 164 top_pages.GoogleWebSearchPage)(self)) | 100 top_pages.GoogleWebSearchPage)(self)) |
| 165 self.AddUserStory(GmailSmoothPage(self)) | 101 self.AddUserStory(GmailSmoothPage(self)) |
| 166 self.AddUserStory(GmailMouseScrollPage(self)) | |
| 167 self.AddUserStory(GoogleCalendarSmoothPage(self)) | 102 self.AddUserStory(GoogleCalendarSmoothPage(self)) |
| 168 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 103 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 169 top_pages.GoogleImageSearchPage)(self)) | 104 top_pages.GoogleImageSearchPage)(self)) |
| 170 self.AddUserStory(GoogleDocSmoothPage(self)) | 105 self.AddUserStory(GoogleDocSmoothPage(self)) |
| 171 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 106 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 172 top_pages.GooglePlusPage)(self)) | 107 top_pages.GooglePlusPage)(self)) |
| 173 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 108 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 174 top_pages.YoutubePage)(self)) | 109 top_pages.YoutubePage)(self)) |
| 175 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 110 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 176 top_pages.BlogspotPage)(self)) | 111 top_pages.BlogspotPage)(self)) |
| 177 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 112 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 178 top_pages.WordpressPage)(self)) | 113 top_pages.WordpressPage)(self)) |
| 179 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 114 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 180 top_pages.FacebookPage)(self)) | 115 top_pages.FacebookPage)(self)) |
| 181 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 116 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 182 top_pages.LinkedinPage)(self)) | 117 top_pages.LinkedinPage)(self)) |
| 183 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 118 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 184 top_pages.WikipediaPage)(self)) | 119 top_pages.WikipediaPage)(self)) |
| 185 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 120 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 186 top_pages.TwitterPage)(self)) | 121 top_pages.TwitterPage)(self)) |
| 187 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 122 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 188 top_pages.PinterestPage)(self)) | 123 top_pages.PinterestPage)(self)) |
| 189 self.AddUserStory(ESPNSmoothPage(self)) | 124 self.AddUserStory(ESPNSmoothPage(self)) |
| 190 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 125 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 191 top_pages.WeatherPage)(self)) | 126 top_pages.WeatherPage)(self)) |
| 192 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 127 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 193 top_pages.YahooGamesPage)(self)) | 128 top_pages.YahooGamesPage)(self)) |
| 194 self.AddUserStory(GoogleMapsPage(self)) | |
| 195 | 129 |
| 196 other_urls = [ | 130 other_urls = [ |
| 197 # Why: #1 news worldwide (Alexa global) | 131 # Why: #1 news worldwide (Alexa global) |
| 198 'http://news.yahoo.com', | 132 'http://news.yahoo.com', |
| 199 # Why: #2 news worldwide | 133 # Why: #2 news worldwide |
| 200 'http://www.cnn.com', | 134 'http://www.cnn.com', |
| 201 # Why: #1 world commerce website by visits; #3 commerce in the US by | 135 # Why: #1 world commerce website by visits; #3 commerce in the US by |
| 202 # time spent | 136 # time spent |
| 203 'http://www.amazon.com', | 137 'http://www.amazon.com', |
| 204 # Why: #1 commerce website by time spent by users in US | 138 # Why: #1 commerce website by time spent by users in US |
| 205 'http://www.ebay.com', | 139 'http://www.ebay.com', |
| 206 # Why: #1 Alexa recreation | 140 # Why: #1 Alexa recreation |
| 207 'http://booking.com', | 141 'http://booking.com', |
| 208 # Why: #1 Alexa reference | 142 # Why: #1 Alexa reference |
| 209 'http://answers.yahoo.com', | 143 'http://answers.yahoo.com', |
| 210 # Why: #1 Alexa sports | 144 # Why: #1 Alexa sports |
| 211 'http://sports.yahoo.com/', | 145 'http://sports.yahoo.com/', |
| 212 # Why: top tech blog | 146 # Why: top tech blog |
| 213 'http://techcrunch.com' | 147 'http://techcrunch.com' |
| 214 ] | 148 ] |
| 215 | 149 |
| 216 for url in other_urls: | 150 for url in other_urls: |
| 217 self.AddUserStory(TopSmoothPage(url, self)) | 151 self.AddUserStory(TopSmoothPage(url, self)) |
| OLD | NEW |