Chromium Code Reviews| 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): | |
|
Sami
2015/03/06 15:02:04
nit: Start this name with an underscore since it's
ssid
2015/03/06 16:45:55
Done.
| |
| 82 display_height = float(action_runner.EvaluateJavaScript( | |
|
Sami
2015/03/06 15:02:04
I think you want .clientHeight here (and also rena
ssid
2015/03/06 16:45:55
Done.
| |
| 83 'window.__scrollableElementForTelemetry.offsetHeight')) | |
| 84 page_height = float(action_runner.EvaluateJavaScript( | |
|
Sami
2015/03/06 15:02:04
nit: content_height?
ssid
2015/03/06 16:45:55
Done.
| |
| 85 'window.__scrollableElementForTelemetry.scrollHeight')) | |
| 86 display_width = float(action_runner.EvaluateJavaScript( | |
| 87 'window.__scrollableElementForTelemetry.offsetWidth')) | |
| 88 scrollbar_width = float(action_runner.EvaluateJavaScript(''' | |
|
Sami
2015/03/06 15:02:04
Add a comment here that this only works if the scr
ssid
2015/03/06 16:45:55
Done.
| |
| 89 window.__scrollableElementForTelemetry.offsetWidth - | |
| 90 window.__scrollableElementForTelemetry.scrollWidth''')) | |
| 91 | |
| 92 scrollbar_start_mid_y = display_height / (2 * page_height) | |
| 93 scrollbar_end_mid_y = 1 - scrollbar_start_mid_y | |
| 94 scrollbar_mid_x_offset = scrollbar_width / (2 * display_width) | |
| 95 scrollbar_mid_x = 1 - scrollbar_mid_x_offset | |
| 96 return scrollbar_mid_x, scrollbar_start_mid_y, scrollbar_end_mid_y | |
| 97 | |
| 98 | |
| 56 class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): | 99 class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): |
| 57 | 100 |
| 58 """ Why: productivity, top google properties """ | 101 """ Why: productivity, top google properties """ |
| 59 | 102 |
| 60 def RunPageInteractions(self, action_runner): | 103 def RunPageInteractions(self, action_runner): |
| 61 interaction = action_runner.BeginGestureInteraction( | 104 interaction = action_runner.BeginGestureInteraction( |
| 62 'ScrollAction', is_smooth=True) | 105 'ScrollAction', is_smooth=True) |
| 63 action_runner.ScrollElement(selector='#scrolltimedeventswk') | 106 action_runner.ScrollElement(selector='#scrolltimedeventswk') |
| 64 interaction.End() | 107 interaction.End() |
| 65 | 108 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 154 |
| 112 def __init__(self): | 155 def __init__(self): |
| 113 super(Top25SmoothPageSet, self).__init__( | 156 super(Top25SmoothPageSet, self).__init__( |
| 114 user_agent_type='desktop', | 157 user_agent_type='desktop', |
| 115 archive_data_file='data/top_25_smooth.json', | 158 archive_data_file='data/top_25_smooth.json', |
| 116 bucket=page_set_module.PARTNER_BUCKET) | 159 bucket=page_set_module.PARTNER_BUCKET) |
| 117 | 160 |
| 118 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 161 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 119 top_pages.GoogleWebSearchPage)(self)) | 162 top_pages.GoogleWebSearchPage)(self)) |
| 120 self.AddUserStory(GmailSmoothPage(self)) | 163 self.AddUserStory(GmailSmoothPage(self)) |
| 164 self.AddUserStory(GmailMouseScrollPage(self)) | |
| 121 self.AddUserStory(GoogleCalendarSmoothPage(self)) | 165 self.AddUserStory(GoogleCalendarSmoothPage(self)) |
| 122 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 166 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 123 top_pages.GoogleImageSearchPage)(self)) | 167 top_pages.GoogleImageSearchPage)(self)) |
| 124 self.AddUserStory(GoogleDocSmoothPage(self)) | 168 self.AddUserStory(GoogleDocSmoothPage(self)) |
| 125 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 169 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 126 top_pages.GooglePlusPage)(self)) | 170 top_pages.GooglePlusPage)(self)) |
| 127 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 171 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 128 top_pages.YoutubePage)(self)) | 172 top_pages.YoutubePage)(self)) |
| 129 self.AddUserStory(_CreatePageClassWithSmoothInteractions( | 173 self.AddUserStory(_CreatePageClassWithSmoothInteractions( |
| 130 top_pages.BlogspotPage)(self)) | 174 top_pages.BlogspotPage)(self)) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 # Why: #1 Alexa reference | 206 # Why: #1 Alexa reference |
| 163 'http://answers.yahoo.com', | 207 'http://answers.yahoo.com', |
| 164 # Why: #1 Alexa sports | 208 # Why: #1 Alexa sports |
| 165 'http://sports.yahoo.com/', | 209 'http://sports.yahoo.com/', |
| 166 # Why: top tech blog | 210 # Why: top tech blog |
| 167 'http://techcrunch.com' | 211 'http://techcrunch.com' |
| 168 ] | 212 ] |
| 169 | 213 |
| 170 for url in other_urls: | 214 for url in other_urls: |
| 171 self.AddUserStory(TopSmoothPage(url, self)) | 215 self.AddUserStory(TopSmoothPage(url, self)) |
| OLD | NEW |