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.
4 from telemetry
.page
import page
as page_module
5 from telemetry
.page
import shared_page_state
6 from telemetry
import story
8 from page_sets
import top_pages
11 def _IssueMarkerAndScroll(action_runner
):
12 with action_runner
.CreateGestureInteraction('ScrollAction'):
13 action_runner
.ScrollPage()
16 def _CreatePageClassWithSmoothInteractions(page_cls
):
17 class DerivedSmoothPage(page_cls
): # pylint: disable=W0232
19 def RunPageInteractions(self
, action_runner
):
20 _IssueMarkerAndScroll(action_runner
)
21 return DerivedSmoothPage
24 class TopSmoothPage(page_module
.Page
):
26 def __init__(self
, url
, page_set
, name
='', credentials
=None):
27 super(TopSmoothPage
, self
).__init
__(
28 url
=url
, page_set
=page_set
, name
=name
,
29 shared_page_state_class
=shared_page_state
.SharedDesktopPageState
,
30 credentials_path
='data/credentials.json')
31 self
.credentials
= credentials
33 def RunPageInteractions(self
, action_runner
):
34 _IssueMarkerAndScroll(action_runner
)
37 class GmailSmoothPage(top_pages
.GmailPage
):
39 """ Why: productivity, top google properties """
41 def RunPageInteractions(self
, action_runner
):
42 action_runner
.ExecuteJavaScript('''
43 gmonkey.load('2.0', function(api) {
44 window.__scrollableElementForTelemetry = api.getScrollableElement();
46 action_runner
.WaitForJavaScriptCondition(
47 'window.__scrollableElementForTelemetry != null')
48 with action_runner
.CreateGestureInteraction('ScrollAction'):
49 action_runner
.ScrollElement(
50 element_function
='window.__scrollableElementForTelemetry')
53 class GoogleCalendarSmoothPage(top_pages
.GoogleCalendarPage
):
55 """ Why: productivity, top google properties """
57 def RunPageInteractions(self
, action_runner
):
58 with action_runner
.CreateGestureInteraction('ScrollAction'):
59 action_runner
.ScrollElement(selector
='#scrolltimedeventswk')
62 class GoogleDocSmoothPage(top_pages
.GoogleDocPage
):
64 """ Why: productivity, top google properties; Sample doc in the link """
66 def RunPageInteractions(self
, action_runner
):
67 with action_runner
.CreateGestureInteraction('ScrollAction'):
68 action_runner
.ScrollElement(selector
='.kix-appview-editor')
71 class ESPNSmoothPage(top_pages
.ESPNPage
):
73 """ Why: #1 sports """
75 def RunPageInteractions(self
, action_runner
):
76 with action_runner
.CreateGestureInteraction('ScrollAction'):
77 action_runner
.ScrollPage(left_start_ratio
=0.1)
80 class Top25SmoothPageSet(story
.StorySet
):
82 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """
85 super(Top25SmoothPageSet
, self
).__init
__(
86 archive_data_file
='data/top_25_smooth.json',
87 cloud_storage_bucket
=story
.PARTNER_BUCKET
)
89 desktop_state_class
= shared_page_state
.SharedDesktopPageState
91 self
.AddStory(_CreatePageClassWithSmoothInteractions(
92 top_pages
.GoogleWebSearchPage
)(self
, desktop_state_class
))
93 self
.AddStory(GmailSmoothPage(self
, desktop_state_class
))
94 self
.AddStory(GoogleCalendarSmoothPage(self
, desktop_state_class
))
95 self
.AddStory(_CreatePageClassWithSmoothInteractions(
96 top_pages
.GoogleImageSearchPage
)(self
, desktop_state_class
))
97 self
.AddStory(GoogleDocSmoothPage(self
, desktop_state_class
))
98 self
.AddStory(_CreatePageClassWithSmoothInteractions(
99 top_pages
.GooglePlusPage
)(self
, desktop_state_class
))
100 self
.AddStory(_CreatePageClassWithSmoothInteractions(
101 top_pages
.YoutubePage
)(self
, desktop_state_class
))
102 self
.AddStory(_CreatePageClassWithSmoothInteractions(
103 top_pages
.BlogspotPage
)(self
, desktop_state_class
))
104 self
.AddStory(_CreatePageClassWithSmoothInteractions(
105 top_pages
.WordpressPage
)(self
, desktop_state_class
))
106 self
.AddStory(_CreatePageClassWithSmoothInteractions(
107 top_pages
.FacebookPage
)(self
, desktop_state_class
))
108 self
.AddStory(_CreatePageClassWithSmoothInteractions(
109 top_pages
.LinkedinPage
)(self
, desktop_state_class
))
110 self
.AddStory(_CreatePageClassWithSmoothInteractions(
111 top_pages
.WikipediaPage
)(self
, desktop_state_class
))
112 self
.AddStory(_CreatePageClassWithSmoothInteractions(
113 top_pages
.TwitterPage
)(self
, desktop_state_class
))
114 self
.AddStory(_CreatePageClassWithSmoothInteractions(
115 top_pages
.PinterestPage
)(self
, desktop_state_class
))
116 self
.AddStory(ESPNSmoothPage(self
, desktop_state_class
))
117 self
.AddStory(_CreatePageClassWithSmoothInteractions(
118 top_pages
.WeatherPage
)(self
, desktop_state_class
))
119 self
.AddStory(_CreatePageClassWithSmoothInteractions(
120 top_pages
.YahooGamesPage
)(self
, desktop_state_class
))
123 # Why: #1 news worldwide (Alexa global)
124 'http://news.yahoo.com',
125 # Why: #2 news worldwide
127 #'http://www.cnn.com',
128 # Why: #1 world commerce website by visits; #3 commerce in the US by
130 'http://www.amazon.com',
131 # Why: #1 commerce website by time spent by users in US
132 'http://www.ebay.com',
133 # Why: #1 Alexa recreation
134 'http://booking.com',
135 # Why: #1 Alexa reference
136 'http://answers.yahoo.com',
137 # Why: #1 Alexa sports
138 'http://sports.yahoo.com/',
140 'http://techcrunch.com'
143 for url
in other_urls
:
144 self
.AddStory(TopSmoothPage(url
, self
))