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
3# found in the LICENSE file.
4import time
5
6from telemetry.internal.actions import page_action
7from telemetry.page import shared_page_state
8
9from page_sets.rendering import rendering_story
10from page_sets.rendering import story_tags
11
12
13class ToughFastScrollingPage(rendering_story.RenderingStory):
14  ABSTRACT_STORY = True
15  SPEED_IN_PIXELS_PER_SECOND = None
16  SYNTHETIC_GESTURE_SOURCE = page_action.GESTURE_SOURCE_DEFAULT
17  TAGS = [story_tags.GPU_RASTERIZATION, story_tags.TOUGH_SCROLLING]
18
19  def __init__(self,
20               page_set,
21               shared_page_state_class=shared_page_state.SharedPageState,
22               name_suffix='',
23               extra_browser_args=None):
24    super(ToughFastScrollingPage, self).__init__(
25        page_set=page_set,
26        shared_page_state_class=shared_page_state_class,
27        name_suffix=name_suffix,
28        extra_browser_args=extra_browser_args)
29
30  def RunPageInteractions(self, action_runner):
31    start = time.time()
32    with action_runner.CreateGestureInteraction('ScrollAction'):
33      direction = 'down'
34      # Some of the metrics the benchmark reports require the scroll to run for
35      # a few seconds (5+). Therefore, scroll the page for long enough that
36      # these metrics are accurately reported.
37      while time.time() - start < 15:
38        action_runner.ScrollPage(
39            direction=direction,
40            speed_in_pixels_per_second=self.SPEED_IN_PIXELS_PER_SECOND,
41            synthetic_gesture_source=self.SYNTHETIC_GESTURE_SOURCE)
42        direction = 'up' if direction == 'down' else 'down'
43
44
45class ScrollingText5000Page(ToughFastScrollingPage):
46  BASE_NAME = 'text_05000_pixels_per_second'
47  URL = 'file://../tough_scrolling_cases/text.html'
48  SPEED_IN_PIXELS_PER_SECOND = 5000
49
50
51class ScrollingText10000Page(ToughFastScrollingPage):
52  BASE_NAME = 'text_10000_pixels_per_second'
53  URL = 'file://../tough_scrolling_cases/text.html'
54  SPEED_IN_PIXELS_PER_SECOND = 10000
55  TAGS = ToughFastScrollingPage.TAGS + [story_tags.REPRESENTATIVE_MOBILE]
56
57
58class ScrollingText20000Page(ToughFastScrollingPage):
59  BASE_NAME = 'text_20000_pixels_per_second'
60  URL = 'file://../tough_scrolling_cases/text.html'
61  SPEED_IN_PIXELS_PER_SECOND = 20000
62
63
64class ScrollingText40000Page(ToughFastScrollingPage):
65  BASE_NAME = 'text_40000_pixels_per_second'
66  URL = 'file://../tough_scrolling_cases/text.html'
67  SPEED_IN_PIXELS_PER_SECOND = 40000
68
69
70class ScrollingText60000Page(ToughFastScrollingPage):
71  BASE_NAME = 'text_60000_pixels_per_second'
72  URL = 'file://../tough_scrolling_cases/text.html'
73  SPEED_IN_PIXELS_PER_SECOND = 60000
74
75
76class ScrollingText75000Page(ToughFastScrollingPage):
77  BASE_NAME = 'text_75000_pixels_per_second'
78  URL = 'file://../tough_scrolling_cases/text.html'
79  SPEED_IN_PIXELS_PER_SECOND = 75000
80
81
82class ScrollingText90000Page(ToughFastScrollingPage):
83  BASE_NAME = 'text_90000_pixels_per_second'
84  URL = 'file://../tough_scrolling_cases/text.html'
85  SPEED_IN_PIXELS_PER_SECOND = 90000
86
87
88class ScrollingTextHover5000Page(ToughFastScrollingPage):
89  BASE_NAME = 'text_hover_05000_pixels_per_second'
90  URL = 'file://../tough_scrolling_cases/text_hover.html'
91  SPEED_IN_PIXELS_PER_SECOND = 5000
92  SYNTHETIC_GESTURE_SOURCE = page_action.GESTURE_SOURCE_MOUSE
93
94
95class ScrollingTextHover10000Page(ToughFastScrollingPage):
96  BASE_NAME = 'text_hover_10000_pixels_per_second'
97  URL = 'file://../tough_scrolling_cases/text_hover.html'
98  SPEED_IN_PIXELS_PER_SECOND = 10000
99  SYNTHETIC_GESTURE_SOURCE = page_action.GESTURE_SOURCE_MOUSE
100
101
102class ScrollingTextHover20000Page(ToughFastScrollingPage):
103  BASE_NAME = 'text_hover_20000_pixels_per_second'
104  URL = 'file://../tough_scrolling_cases/text_hover.html'
105  SPEED_IN_PIXELS_PER_SECOND = 20000
106  SYNTHETIC_GESTURE_SOURCE = page_action.GESTURE_SOURCE_MOUSE
107
108
109class ScrollingTextHover40000Page(ToughFastScrollingPage):
110  BASE_NAME = 'text_hover_40000_pixels_per_second'
111  URL = 'file://../tough_scrolling_cases/text_hover.html'
112  SPEED_IN_PIXELS_PER_SECOND = 40000
113  SYNTHETIC_GESTURE_SOURCE = page_action.GESTURE_SOURCE_MOUSE
114
115
116class ScrollingTextHover60000Page(ToughFastScrollingPage):
117  BASE_NAME = 'text_hover_60000_pixels_per_second'
118  URL = 'file://../tough_scrolling_cases/text_hover.html'
119  SPEED_IN_PIXELS_PER_SECOND = 60000
120  SYNTHETIC_GESTURE_SOURCE = page_action.GESTURE_SOURCE_MOUSE
121
122
123class ScrollingTextHover75000Page(ToughFastScrollingPage):
124  BASE_NAME = 'text_hover_75000_pixels_per_second'
125  URL = 'file://../tough_scrolling_cases/text_hover.html'
126  SPEED_IN_PIXELS_PER_SECOND = 75000
127  SYNTHETIC_GESTURE_SOURCE = page_action.GESTURE_SOURCE_MOUSE
128
129
130class ScrollingTextHover90000Page(ToughFastScrollingPage):
131  BASE_NAME = 'text_hover_90000_pixels_per_second'
132  URL = 'file://../tough_scrolling_cases/text_hover.html'
133  SPEED_IN_PIXELS_PER_SECOND = 90000
134  SYNTHETIC_GESTURE_SOURCE = page_action.GESTURE_SOURCE_MOUSE
135
136
137class ScrollingTextRaster5000Page(ToughFastScrollingPage):
138  BASE_NAME = 'text_constant_full_page_raster_05000_pixels_per_second'
139  URL = 'file://../tough_scrolling_cases/text_constant_full_page_raster.html'
140  SPEED_IN_PIXELS_PER_SECOND = 5000
141
142
143class ScrollingTextRaster10000Page(ToughFastScrollingPage):
144  BASE_NAME = 'text_constant_full_page_raster_10000_pixels_per_second'
145  URL = 'file://../tough_scrolling_cases/text_constant_full_page_raster.html'
146  SPEED_IN_PIXELS_PER_SECOND = 10000
147
148
149class ScrollingTextRaster20000Page(ToughFastScrollingPage):
150  BASE_NAME = 'text_constant_full_page_raster_20000_pixels_per_second'
151  URL = 'file://../tough_scrolling_cases/text_constant_full_page_raster.html'
152  SPEED_IN_PIXELS_PER_SECOND = 20000
153
154
155class ScrollingTextRaster40000Page(ToughFastScrollingPage):
156  BASE_NAME = 'text_constant_full_page_raster_40000_pixels_per_second'
157  URL = 'file://../tough_scrolling_cases/text_constant_full_page_raster.html'
158  SPEED_IN_PIXELS_PER_SECOND = 40000
159
160
161class ScrollingTextRaster60000Page(ToughFastScrollingPage):
162  BASE_NAME = 'text_constant_full_page_raster_60000_pixels_per_second'
163  URL = 'file://../tough_scrolling_cases/text_constant_full_page_raster.html'
164  SPEED_IN_PIXELS_PER_SECOND = 60000
165
166
167class ScrollingTextRaster75000Page(ToughFastScrollingPage):
168  BASE_NAME = 'text_constant_full_page_raster_75000_pixels_per_second'
169  URL = 'file://../tough_scrolling_cases/text_constant_full_page_raster.html'
170  SPEED_IN_PIXELS_PER_SECOND = 75000
171
172
173class ScrollingTextRaster90000Page(ToughFastScrollingPage):
174  BASE_NAME = 'text_constant_full_page_raster_90000_pixels_per_second'
175  URL = 'file://../tough_scrolling_cases/text_constant_full_page_raster.html'
176  SPEED_IN_PIXELS_PER_SECOND = 90000
177
178
179class ScrollingCanvas5000Page(ToughFastScrollingPage):
180  BASE_NAME = 'canvas_05000_pixels_per_second'
181  URL = 'file://../tough_scrolling_cases/canvas.html'
182  SPEED_IN_PIXELS_PER_SECOND = 5000
183  TAGS = ToughFastScrollingPage.TAGS + [
184    story_tags.REPRESENTATIVE_MOBILE,
185    story_tags.REPRESENTATIVE_MAC_DESKTOP
186  ]
187
188
189class ScrollingCanvas10000Page(ToughFastScrollingPage):
190  BASE_NAME = 'canvas_10000_pixels_per_second'
191  URL = 'file://../tough_scrolling_cases/canvas.html'
192  SPEED_IN_PIXELS_PER_SECOND = 10000
193
194
195class ScrollingCanvas20000Page(ToughFastScrollingPage):
196  BASE_NAME = 'canvas_20000_pixels_per_second'
197  URL = 'file://../tough_scrolling_cases/canvas.html'
198  SPEED_IN_PIXELS_PER_SECOND = 20000
199
200
201class ScrollingCanvas40000Page(ToughFastScrollingPage):
202  BASE_NAME = 'canvas_40000_pixels_per_second'
203  URL = 'file://../tough_scrolling_cases/canvas.html'
204  SPEED_IN_PIXELS_PER_SECOND = 40000
205
206
207class ScrollingCanvas60000Page(ToughFastScrollingPage):
208  BASE_NAME = 'canvas_60000_pixels_per_second'
209  URL = 'file://../tough_scrolling_cases/canvas.html'
210  SPEED_IN_PIXELS_PER_SECOND = 60000
211
212
213class ScrollingCanvas75000Page(ToughFastScrollingPage):
214  BASE_NAME = 'canvas_75000_pixels_per_second'
215  URL = 'file://../tough_scrolling_cases/canvas.html'
216  SPEED_IN_PIXELS_PER_SECOND = 75000
217
218
219class ScrollingCanvas90000Page(ToughFastScrollingPage):
220  BASE_NAME = 'canvas_90000_pixels_per_second'
221  URL = 'file://../tough_scrolling_cases/canvas.html'
222  SPEED_IN_PIXELS_PER_SECOND = 90000
223