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 with action_runner
.CreateGestureInteraction('ScrollAction'):
12 action_runner
.ScrollPage()
15 def _CreatePageClassWithSmoothInteractions(page_cls
):
16 class DerivedSmoothPage(page_cls
): # pylint: disable=W0232
18 def RunPageInteractions(self
, action_runner
):
19 _IssueMarkerAndScroll(action_runner
)
20 return DerivedSmoothPage
23 class TopSmoothPage(page_module
.Page
):
25 def __init__(self
, url
, page_set
, name
='', credentials
=None):
26 super(TopSmoothPage
, self
).__init
__(
27 url
=url
, page_set
=page_set
, name
=name
,
28 credentials_path
='data/credentials.json')
29 self
.user_agent_type
= 'desktop'
30 self
.credentials
= credentials
32 def RunPageInteractions(self
, action_runner
):
33 _IssueMarkerAndScroll(action_runner
)
36 class GmailSmoothPage(top_pages
.GmailPage
):
38 """ Why: productivity, top google properties """
40 def RunPageInteractions(self
, action_runner
):
41 action_runner
.ExecuteJavaScript('''
42 gmonkey.load('2.0', function(api) {
43 window.__scrollableElementForTelemetry = api.getScrollableElement();
45 action_runner
.WaitForJavaScriptCondition(
46 'window.__scrollableElementForTelemetry != null')
47 with action_runner
.CreateGestureInteraction('ScrollAction'):
48 action_runner
.ScrollElement(
49 element_function
='window.__scrollableElementForTelemetry')
52 class GoogleCalendarSmoothPage(top_pages
.GoogleCalendarPage
):
54 """ Why: productivity, top google properties """
56 def RunPageInteractions(self
, action_runner
):
57 with action_runner
.CreateGestureInteraction('ScrollAction'):
58 action_runner
.ScrollElement(selector
='#scrolltimedeventswk')
61 class GoogleDocSmoothPage(top_pages
.GoogleDocPage
):
63 """ Why: productivity, top google properties; Sample doc in the link """
65 def RunPageInteractions(self
, action_runner
):
66 with action_runner
.CreateGestureInteraction('ScrollAction'):
67 action_runner
.ScrollElement(selector
='.kix-appview-editor')
70 class ESPNSmoothPage(top_pages
.ESPNPage
):
72 """ Why: #1 sports """
74 def RunPageInteractions(self
, action_runner
):
75 with action_runner
.CreateGestureInteraction('ScrollAction'):
76 action_runner
.ScrollPage(left_start_ratio
=0.1)
79 class Top25SmoothPageSet(page_set_module
.PageSet
):
81 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """
84 super(Top25SmoothPageSet
, self
).__init
__(
85 user_agent_type
='desktop',
86 archive_data_file
='data/top_25_smooth.json',
87 bucket
=page_set_module
.PARTNER_BUCKET
)
89 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
90 top_pages
.GoogleWebSearchPage
)(self
))
91 self
.AddUserStory(GmailSmoothPage(self
))
92 self
.AddUserStory(GoogleCalendarSmoothPage(self
))
93 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
94 top_pages
.GoogleImageSearchPage
)(self
))
95 self
.AddUserStory(GoogleDocSmoothPage(self
))
96 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
97 top_pages
.GooglePlusPage
)(self
))
98 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
99 top_pages
.YoutubePage
)(self
))
100 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
101 top_pages
.BlogspotPage
)(self
))
102 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
103 top_pages
.WordpressPage
)(self
))
104 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
105 top_pages
.FacebookPage
)(self
))
106 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
107 top_pages
.LinkedinPage
)(self
))
108 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
109 top_pages
.WikipediaPage
)(self
))
110 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
111 top_pages
.TwitterPage
)(self
))
112 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
113 top_pages
.PinterestPage
)(self
))
114 self
.AddUserStory(ESPNSmoothPage(self
))
115 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
116 top_pages
.WeatherPage
)(self
))
117 self
.AddUserStory(_CreatePageClassWithSmoothInteractions(
118 top_pages
.YahooGamesPage
)(self
))
121 # Why: #1 news worldwide (Alexa global)
122 'http://news.yahoo.com',
123 # Why: #2 news worldwide
124 'http://www.cnn.com',
125 # Why: #1 world commerce website by visits; #3 commerce in the US by
127 'http://www.amazon.com',
128 # Why: #1 commerce website by time spent by users in US
129 'http://www.ebay.com',
130 # Why: #1 Alexa recreation
131 'http://booking.com',
132 # Why: #1 Alexa reference
133 'http://answers.yahoo.com',
134 # Why: #1 Alexa sports
135 'http://sports.yahoo.com/',
137 'http://techcrunch.com'
140 for url
in other_urls
:
141 self
.AddUserStory(TopSmoothPage(url
, self
))