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 # pylint: disable=W0401,W0614
5 from telemetry.page.actions.all_page_actions import *
6 from telemetry.page import page as page_module
7 from telemetry.page import page_set as page_set_module
10 class ToughPinchZoomCasesPage(page_module.Page):
12 def __init__(self, url, page_set, name=''):
13 super(ToughPinchZoomCasesPage, self).__init__(url=url, page_set=page_set,
15 self.credentials_path = 'data/credentials.json'
16 self.user_agent_type = 'desktop'
17 self.archive_data_file = 'data/tough_pinch_zoom_cases.json'
19 def RunSmoothness(self, action_runner):
20 action_runner.RunAction(PinchAction())
23 class GoogleSearchPage(ToughPinchZoomCasesPage):
25 """ Why: top google property; a google tab is often open. """
27 def __init__(self, page_set):
28 super(GoogleSearchPage, self).__init__(
29 url='https://www.google.com/#hl=en&q=barack+obama',
32 def RunNavigateSteps(self, action_runner):
33 action_runner.RunAction(NavigateAction())
34 action_runner.RunAction(WaitAction(
37 'condition': 'element'
41 class GmailPage(ToughPinchZoomCasesPage):
43 """ Why: productivity, top google properties """
45 def __init__(self, page_set):
46 super(GmailPage, self).__init__(
47 url='https://mail.google.com/mail/',
50 self.credentials = 'google'
52 def RunNavigateSteps(self, action_runner):
53 action_runner.RunAction(NavigateAction())
54 action_runner.RunAction(WaitAction(
57 'window.gmonkey !== undefined &&'
58 'document.getElementById("gb") !== null')
62 class GoogleCalendarPage(ToughPinchZoomCasesPage):
64 """ Why: productivity, top google properties """
66 def __init__(self, page_set):
67 super(GoogleCalendarPage, self).__init__(
68 url='https://www.google.com/calendar/',
71 self.credentials = 'google'
73 def RunNavigateSteps(self, action_runner):
74 action_runner.RunAction(NavigateAction())
75 action_runner.RunAction(WaitAction({'seconds':2}))
77 def RunSmoothness(self, action_runner):
78 action_runner.RunAction(PinchAction(
80 'left_anchor_percentage': 0.1,
81 'top_anchor_percentage': 0.1
85 class GoogleImageSearchPage(ToughPinchZoomCasesPage):
87 """ Why: tough image case; top google properties """
89 def __init__(self, page_set):
90 super(GoogleImageSearchPage, self).__init__(
91 url='https://www.google.com/search?q=cats&tbm=isch',
94 self.credentials = 'google'
97 class GooglePlusPage(ToughPinchZoomCasesPage):
99 """ Why: social; top google property; Public profile; infinite scrolls """
101 def __init__(self, page_set):
102 super(GooglePlusPage, self).__init__(
103 url='https://plus.google.com/+BarackObama/posts',
106 self.credentials = 'google'
108 def RunNavigateSteps(self, action_runner):
109 action_runner.RunAction(NavigateAction())
110 action_runner.RunAction(WaitAction(
113 'condition': 'element'
116 def RunSmoothness(self, action_runner):
117 action_runner.RunAction(PinchAction(
119 'element_function': '''
121 callback(document.getElementsByClassName("Ct")[0])
126 class YoutubePage(ToughPinchZoomCasesPage):
128 """ Why: #3 (Alexa global) """
130 def __init__(self, page_set):
131 super(YoutubePage, self).__init__(
132 url='http://www.youtube.com',
135 self.credentials = 'google'
137 def RunNavigateSteps(self, action_runner):
138 action_runner.RunAction(NavigateAction())
139 action_runner.RunAction(WaitAction({'seconds':2}))
141 class BlogSpotPage(ToughPinchZoomCasesPage):
144 Why: #11 (Alexa global), google property; some blogger layouts have infinite
145 scroll but more interesting
148 def __init__(self, page_set):
149 super(BlogSpotPage, self).__init__(
150 url='http://googlewebmastercentral.blogspot.com/',
151 page_set=page_set, name='Blogger')
153 def RunNavigateSteps(self, action_runner):
154 action_runner.RunAction(NavigateAction())
155 action_runner.RunAction(WaitAction(
157 'text': 'accessibility',
158 'condition': 'element'
162 class FacebookPage(ToughPinchZoomCasesPage):
164 """ Why: top social,Public profile """
166 def __init__(self, page_set):
167 super(FacebookPage, self).__init__(
168 url='http://www.facebook.com/barackobama',
169 page_set=page_set, name='Facebook')
170 self.credentials = 'facebook'
172 def RunNavigateSteps(self, action_runner):
173 action_runner.RunAction(NavigateAction())
174 action_runner.RunAction(WaitAction(
177 'condition': 'element'
181 class LinkedinPage(ToughPinchZoomCasesPage):
183 """ Why: #12 (Alexa global),Public profile """
185 def __init__(self, page_set):
186 super(LinkedinPage, self).__init__(
187 url='http://www.linkedin.com/in/linustorvalds',
188 page_set=page_set, name='LinkedIn')
191 class WikipediaPage(ToughPinchZoomCasesPage):
193 """ Why: #6 (Alexa) most visited worldwide,Picked an interesting page """
195 def __init__(self, page_set):
196 super(WikipediaPage, self).__init__(
197 url='http://en.wikipedia.org/wiki/Wikipedia',
198 page_set=page_set, name='Wikipedia (1 tab)')
201 class TwitterPage(ToughPinchZoomCasesPage):
203 """ Why: #8 (Alexa global),Picked an interesting page """
205 def __init__(self, page_set):
206 super(TwitterPage, self).__init__(
207 url='https://twitter.com/katyperry',
208 page_set=page_set, name='Twitter')
210 def RunNavigateSteps(self, action_runner):
211 action_runner.RunAction(NavigateAction())
212 action_runner.RunAction(WaitAction({'seconds':2}))
214 class ESPNPage(ToughPinchZoomCasesPage):
216 """ Why: #1 sports """
218 def __init__(self, page_set):
219 super(ESPNPage, self).__init__(
220 url='http://espn.go.com/nba',
221 page_set=page_set, name='ESPN')
224 class WeatherDotComPage(ToughPinchZoomCasesPage):
226 """ Why: #7 (Alexa news); #27 total time spent,Picked interesting page """
228 def __init__(self, page_set):
229 super(WeatherDotComPage, self).__init__(
230 # pylint: disable=C0301
231 url='http://www.weather.com/weather/right-now/Mountain+View+CA+94043',
232 page_set=page_set, name='Weather.com')
235 class YahooGamePage(ToughPinchZoomCasesPage):
237 """ Why: #1 games according to Alexa (with actual games in it) """
239 def __init__(self, page_set):
240 super(YahooGamePage, self).__init__(
241 url='http://games.yahoo.com',
244 def RunNavigateSteps(self, action_runner):
245 action_runner.RunAction(NavigateAction())
246 action_runner.RunAction(WaitAction({'seconds':2}))
248 class ToughPinchZoomCasesPageSet(page_set_module.PageSet):
250 """ Set of pages that are tricky to pinch-zoom """
253 super(ToughPinchZoomCasesPageSet, self).__init__(
254 credentials_path='data/credentials.json',
255 user_agent_type='desktop',
256 archive_data_file='data/tough_pinch_zoom_cases.json')
258 self.AddPage(GoogleSearchPage(self))
259 self.AddPage(GmailPage(self))
260 self.AddPage(GoogleCalendarPage(self))
261 self.AddPage(GoogleImageSearchPage(self))
262 self.AddPage(GooglePlusPage(self))
263 self.AddPage(YoutubePage(self))
264 self.AddPage(BlogSpotPage(self))
265 self.AddPage(FacebookPage(self))
266 self.AddPage(LinkedinPage(self))
267 self.AddPage(WikipediaPage(self))
268 self.AddPage(TwitterPage(self))
269 self.AddPage(ESPNPage(self))
271 # Why: #1 news worldwide (Alexa global)
272 self.AddPage(ToughPinchZoomCasesPage('http://news.yahoo.com', self))
274 # Why: #2 news worldwide
275 self.AddPage(ToughPinchZoomCasesPage('http://www.cnn.com', self))
277 self.AddPage(WeatherDotComPage(self))
279 # Why: #1 world commerce website by visits; #3 commerce in the US by time
281 self.AddPage(ToughPinchZoomCasesPage('http://www.amazon.com', self))
283 # Why: #1 commerce website by time spent by users in US
284 self.AddPage(ToughPinchZoomCasesPage('http://www.ebay.com', self))
286 self.AddPage(YahooGamePage(self))
288 # Why: #1 Alexa recreation
289 self.AddPage(ToughPinchZoomCasesPage('http://booking.com', self))
291 # Why: #1 Alexa reference
292 self.AddPage(ToughPinchZoomCasesPage('http://answers.yahoo.com', self))
294 # Why: #1 Alexa sports
295 self.AddPage(ToughPinchZoomCasesPage('http://sports.yahoo.com/', self))