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') |
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 RunPageInteractions(self, action_runner): | 20 def RunPageInteractions(self, action_runner): |
21 _IssueMarkerAndScroll(action_runner) | 21 _IssueMarkerAndScroll(action_runner) |
22 return DerivedSmoothPage | 22 return DerivedSmoothPage |
(...skipping 17 matching lines...) Expand all Loading... |
40 """ Why: productivity, top google properties """ | 40 """ Why: productivity, top google properties """ |
41 | 41 |
42 def RunPageInteractions(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') |
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): | 56 class GmailMouseScrollPage(top_pages.GmailPage): |
57 | 57 |
58 """ Why: productivity, top google properties """ | 58 """ Why: productivity, top google properties """ |
59 | 59 |
60 def RunPageInteractions(self, action_runner): | 60 def RunPageInteractions(self, action_runner): |
61 action_runner.ExecuteJavaScript(''' | 61 action_runner.ExecuteJavaScript(''' |
62 gmonkey.load('2.0', function(api) { | 62 gmonkey.load('2.0', function(api) { |
63 window.__scrollableElementForTelemetry = api.getScrollableElement(); | 63 window.__scrollableElementForTelemetry = api.getScrollableElement(); |
64 });''') | 64 });''') |
65 action_runner.WaitForJavaScriptCondition( | 65 action_runner.WaitForJavaScriptCondition( |
66 'window.__scrollableElementForTelemetry != null') | 66 'window.__scrollableElementForTelemetry != null') |
67 scrollbar_x, start_y, end_y = self._CalculateScrollBarRatios(action_runner) | 67 scrollbar_x, start_y, end_y = self._CalculateScrollBarRatios(action_runner) |
68 | 68 |
69 interaction = action_runner.BeginGestureInteraction( | 69 interaction = action_runner.BeginGestureInteraction( |
70 'DragAction', is_smooth=True) | 70 'DragAction') |
71 action_runner.DragPage(left_start_ratio=scrollbar_x, | 71 action_runner.DragPage(left_start_ratio=scrollbar_x, |
72 top_start_ratio=start_y, left_end_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, | 73 top_end_ratio=end_y, speed_in_pixels_per_second=100, |
74 element_function='window.__scrollableElementForTelemetry') | 74 element_function='window.__scrollableElementForTelemetry') |
75 interaction.End() | 75 interaction.End() |
76 | 76 |
77 def CanRunOnBrowser(self, browser_info): | 77 def CanRunOnBrowser(self, browser_info): |
78 return (browser_info._browser._platform_backend.platform.GetOSName() != | 78 return (browser_info._browser._platform_backend.platform.GetOSName() != |
79 'android') | 79 'android') |
80 | 80 |
(...skipping 16 matching lines...) Expand all Loading... |
97 scrollbar_mid_x = 1 - scrollbar_mid_x_offset | 97 scrollbar_mid_x = 1 - scrollbar_mid_x_offset |
98 return scrollbar_mid_x, scrollbar_start_mid_y, scrollbar_end_mid_y | 98 return scrollbar_mid_x, scrollbar_start_mid_y, scrollbar_end_mid_y |
99 | 99 |
100 | 100 |
101 class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): | 101 class GoogleCalendarSmoothPage(top_pages.GoogleCalendarPage): |
102 | 102 |
103 """ Why: productivity, top google properties """ | 103 """ Why: productivity, top google properties """ |
104 | 104 |
105 def RunPageInteractions(self, action_runner): | 105 def RunPageInteractions(self, action_runner): |
106 interaction = action_runner.BeginGestureInteraction( | 106 interaction = action_runner.BeginGestureInteraction( |
107 'ScrollAction', is_smooth=True) | 107 'ScrollAction') |
108 action_runner.ScrollElement(selector='#scrolltimedeventswk') | 108 action_runner.ScrollElement(selector='#scrolltimedeventswk') |
109 interaction.End() | 109 interaction.End() |
110 | 110 |
111 | 111 |
112 class GoogleDocSmoothPage(top_pages.GoogleDocPage): | 112 class GoogleDocSmoothPage(top_pages.GoogleDocPage): |
113 | 113 |
114 """ Why: productivity, top google properties; Sample doc in the link """ | 114 """ Why: productivity, top google properties; Sample doc in the link """ |
115 | 115 |
116 def RunPageInteractions(self, action_runner): | 116 def RunPageInteractions(self, action_runner): |
117 interaction = action_runner.BeginGestureInteraction( | 117 interaction = action_runner.BeginGestureInteraction( |
118 'ScrollAction', is_smooth=True) | 118 'ScrollAction') |
119 action_runner.ScrollElement(selector='.kix-appview-editor') | 119 action_runner.ScrollElement(selector='.kix-appview-editor') |
120 interaction.End() | 120 interaction.End() |
121 | 121 |
122 | 122 |
123 class GoogleMapsPage(top_pages.GoogleMapsPage): | 123 class GoogleMapsPage(top_pages.GoogleMapsPage): |
124 | 124 |
125 """ Why: productivity, top google properties; Supports drag gestures """ | 125 """ Why: productivity, top google properties; Supports drag gestures """ |
126 | 126 |
127 def RunPageInteractions(self, action_runner): | 127 def RunPageInteractions(self, action_runner): |
128 interaction = action_runner.BeginGestureInteraction( | 128 interaction = action_runner.BeginGestureInteraction( |
129 'DragAction', is_smooth=True, repeatable=True) | 129 'DragAction', repeatable=True) |
130 action_runner.DragPage(left_start_ratio=0.5, top_start_ratio=0.75, | 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) | 131 left_end_ratio=0.75, top_end_ratio=0.5) |
132 interaction.End() | 132 interaction.End() |
133 action_runner.Wait(2) | 133 action_runner.Wait(2) |
134 interaction = action_runner.BeginGestureInteraction( | 134 interaction = action_runner.BeginGestureInteraction( |
135 'DragAction', is_smooth=True, repeatable=True) | 135 'DragAction', repeatable=True) |
136 action_runner.DragPage(left_start_ratio=0.5, top_start_ratio=0.5, | 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) | 137 left_end_ratio=0.35, top_end_ratio=0.75) |
138 interaction.End() | 138 interaction.End() |
139 # TODO(ssid): Add zoom gestures after fixing bug crbug.com/462214. | 139 # TODO(ssid): Add zoom gestures after fixing bug crbug.com/462214. |
140 | 140 |
141 | 141 |
142 class ESPNSmoothPage(top_pages.ESPNPage): | 142 class ESPNSmoothPage(top_pages.ESPNPage): |
143 | 143 |
144 """ Why: #1 sports """ | 144 """ Why: #1 sports """ |
145 | 145 |
146 def RunPageInteractions(self, action_runner): | 146 def RunPageInteractions(self, action_runner): |
147 interaction = action_runner.BeginGestureInteraction( | 147 interaction = action_runner.BeginGestureInteraction( |
148 'ScrollAction', is_smooth=True) | 148 'ScrollAction') |
149 action_runner.ScrollPage(left_start_ratio=0.1) | 149 action_runner.ScrollPage(left_start_ratio=0.1) |
150 interaction.End() | 150 interaction.End() |
151 | 151 |
152 | 152 |
153 class Top25SmoothPageSet(page_set_module.PageSet): | 153 class Top25SmoothPageSet(page_set_module.PageSet): |
154 | 154 |
155 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """ | 155 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """ |
156 | 156 |
157 def __init__(self): | 157 def __init__(self): |
158 super(Top25SmoothPageSet, self).__init__( | 158 super(Top25SmoothPageSet, self).__init__( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 # Why: #1 Alexa reference | 208 # Why: #1 Alexa reference |
209 'http://answers.yahoo.com', | 209 'http://answers.yahoo.com', |
210 # Why: #1 Alexa sports | 210 # Why: #1 Alexa sports |
211 'http://sports.yahoo.com/', | 211 'http://sports.yahoo.com/', |
212 # Why: top tech blog | 212 # Why: top tech blog |
213 'http://techcrunch.com' | 213 'http://techcrunch.com' |
214 ] | 214 ] |
215 | 215 |
216 for url in other_urls: | 216 for url in other_urls: |
217 self.AddUserStory(TopSmoothPage(url, self)) | 217 self.AddUserStory(TopSmoothPage(url, self)) |
OLD | NEW |