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 page_set
as page_set_module
7 from page_sets
import top_pages
10 def _IssueMarkerAndScroll(action_runner
):
11 interaction
= action_runner
.BeginGestureInteraction(
12 'ScrollAction', is_smooth
=True)
13 action_runner
.ScrollPage()
17 def _CreatePageClassWithSmoothInteractions(page_cls
):
18 class DerivedSmoothPage(page_cls
): # pylint: disable=W0232
20 def RunSmoothness(self
, action_runner
):
21 _IssueMarkerAndScroll(action_runner
)
22 return DerivedSmoothPage
25 class TopSmoothPage(page_module
.Page
):
27 def __init__(self
, url
, page_set
, name
='', credentials
=None):
28 super(TopSmoothPage
, self
).__init
__(
29 url
=url
, page_set
=page_set
, name
=name
,
30 credentials_path
='data/credentials.json')
31 self
.user_agent_type
= 'desktop'
32 self
.credentials
= credentials
34 def RunSmoothness(self
, action_runner
):
35 _IssueMarkerAndScroll(action_runner
)
38 class GmailSmoothPage(top_pages
.GmailPage
):
40 """ Why: productivity, top google properties """
42 def RunSmoothness(self
, action_runner
):
43 action_runner
.ExecuteJavaScript('''
44 gmonkey.load('2.0', function(api) {
45 window.__scrollableElementForTelemetry = api.getScrollableElement();
47 action_runner
.WaitForJavaScriptCondition(
48 'window.__scrollableElementForTelemetry != null')
49 interaction
= action_runner
.BeginGestureInteraction(
50 'ScrollAction', is_smooth
=True)
51 action_runner
.ScrollElement(
52 element_function
='window.__scrollableElementForTelemetry')
56 class GoogleCalendarSmoothPage(top_pages
.GoogleCalendarPage
):
58 """ Why: productivity, top google properties """
60 def RunSmoothness(self
, action_runner
):
61 interaction
= action_runner
.BeginGestureInteraction(
62 'ScrollAction', is_smooth
=True)
63 action_runner
.ScrollElement(selector
='#scrolltimedeventswk')
67 class GoogleDocSmoothPage(top_pages
.GoogleDocPage
):
69 """ Why: productivity, top google properties; Sample doc in the link """
71 def RunSmoothness(self
, action_runner
):
72 interaction
= action_runner
.BeginGestureInteraction(
73 'ScrollAction', is_smooth
=True)
74 action_runner
.ScrollElement(selector
='.kix-appview-editor')
78 class ESPNSmoothPage(top_pages
.ESPNPage
):
80 """ Why: #1 sports """
82 def RunSmoothness(self
, action_runner
):
83 interaction
= action_runner
.BeginGestureInteraction(
84 'ScrollAction', is_smooth
=True)
85 action_runner
.ScrollPage(left_start_ratio
=0.1)
89 class Top25SmoothPageSet(page_set_module
.PageSet
):
91 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """
94 super(Top25SmoothPageSet
, self
).__init
__(
95 user_agent_type
='desktop',
96 archive_data_file
='data/top_25.json',
97 bucket
=page_set_module
.PARTNER_BUCKET
)
99 self
.AddPage(_CreatePageClassWithSmoothInteractions(
100 top_pages
.GoogleWebSearchPage
)(self
))
101 self
.AddPage(GmailSmoothPage(self
))
102 self
.AddPage(GoogleCalendarSmoothPage(self
))
103 self
.AddPage(_CreatePageClassWithSmoothInteractions(
104 top_pages
.GoogleImageSearchPage
)(self
))
105 self
.AddPage(GoogleDocSmoothPage(self
))
106 self
.AddPage(_CreatePageClassWithSmoothInteractions(
107 top_pages
.GooglePlusPage
)(self
))
108 self
.AddPage(_CreatePageClassWithSmoothInteractions(
109 top_pages
.YoutubePage
)(self
))
110 self
.AddPage(_CreatePageClassWithSmoothInteractions(
111 top_pages
.BlogspotPage
)(self
))
112 self
.AddPage(_CreatePageClassWithSmoothInteractions(
113 top_pages
.WordpressPage
)(self
))
114 self
.AddPage(_CreatePageClassWithSmoothInteractions(
115 top_pages
.FacebookPage
)(self
))
116 self
.AddPage(_CreatePageClassWithSmoothInteractions(
117 top_pages
.LinkedinPage
)(self
))
118 self
.AddPage(_CreatePageClassWithSmoothInteractions(
119 top_pages
.WikipediaPage
)(self
))
120 self
.AddPage(_CreatePageClassWithSmoothInteractions(
121 top_pages
.TwitterPage
)(self
))
122 self
.AddPage(_CreatePageClassWithSmoothInteractions(
123 top_pages
.PinterestPage
)(self
))
124 self
.AddPage(ESPNSmoothPage(self
))
125 self
.AddPage(_CreatePageClassWithSmoothInteractions(
126 top_pages
.WeatherPage
)(self
))
127 self
.AddPage(_CreatePageClassWithSmoothInteractions(
128 top_pages
.YahooGamesPage
)(self
))
131 # Why: #1 news worldwide (Alexa global)
132 'http://news.yahoo.com',
133 # Why: #2 news worldwide
134 'http://www.cnn.com',
135 # Why: #1 world commerce website by visits; #3 commerce in the US by
137 'http://www.amazon.com',
138 # Why: #1 commerce website by time spent by users in US
139 'http://www.ebay.com',
140 # Why: #1 Alexa recreation
141 'http://booking.com',
142 # Why: #1 Alexa reference
143 'http://answers.yahoo.com',
144 # Why: #1 Alexa sports
145 'http://sports.yahoo.com/',
147 'http://techcrunch.com'
150 for url
in other_urls
:
151 self
.AddPage(TopSmoothPage(url
, self
))