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
8 class ToughPinchZoomCasesPage(page_module
.Page
):
10 def __init__(self
, url
, page_set
, name
=''):
11 super(ToughPinchZoomCasesPage
, self
).__init
__(
12 url
=url
, page_set
=page_set
, name
=name
,
13 credentials_path
= 'data/credentials.json')
14 self
.user_agent_type
= 'desktop'
15 self
.archive_data_file
= 'data/tough_pinch_zoom_cases.json'
17 def RunSmoothness(self
, action_runner
):
18 interaction
= action_runner
.BeginGestureInteraction(
19 'PinchAction', is_smooth
=True)
20 action_runner
.PinchPage()
24 class GoogleSearchPage(ToughPinchZoomCasesPage
):
26 """ Why: top google property; a google tab is often open. """
28 def __init__(self
, page_set
):
29 super(GoogleSearchPage
, self
).__init
__(
30 url
='https://www.google.com/#hl=en&q=barack+obama',
33 def RunNavigateSteps(self
, action_runner
):
34 action_runner
.NavigateToPage(self
)
35 action_runner
.WaitForElement(text
='Next')
38 class GmailPage(ToughPinchZoomCasesPage
):
40 """ Why: productivity, top google properties """
42 def __init__(self
, page_set
):
43 super(GmailPage
, self
).__init
__(
44 url
='https://mail.google.com/mail/',
47 self
.credentials
= 'google'
49 def RunNavigateSteps(self
, action_runner
):
50 action_runner
.NavigateToPage(self
)
51 action_runner
.WaitForJavaScriptCondition(
52 'window.gmonkey !== undefined &&'
53 'document.getElementById("gb") !== null')
56 class GoogleCalendarPage(ToughPinchZoomCasesPage
):
58 """ Why: productivity, top google properties """
60 def __init__(self
, page_set
):
61 super(GoogleCalendarPage
, self
).__init
__(
62 url
='https://www.google.com/calendar/',
65 self
.credentials
= 'google'
67 def RunNavigateSteps(self
, action_runner
):
68 action_runner
.NavigateToPage(self
)
71 def RunSmoothness(self
, action_runner
):
72 interaction
= action_runner
.BeginGestureInteraction(
73 'PinchAction', is_smooth
=True)
74 action_runner
.PinchPage(left_anchor_ratio
=0.1, top_anchor_ratio
=0.3)
78 class GoogleImageSearchPage(ToughPinchZoomCasesPage
):
80 """ Why: tough image case; top google properties """
82 def __init__(self
, page_set
):
83 super(GoogleImageSearchPage
, self
).__init
__(
84 url
='https://www.google.com/search?q=cats&tbm=isch',
87 self
.credentials
= 'google'
90 class GooglePlusPage(ToughPinchZoomCasesPage
):
92 """ Why: social; top google property; Public profile; infinite scrolls """
94 def __init__(self
, page_set
):
95 super(GooglePlusPage
, self
).__init
__(
96 url
='https://plus.google.com/+BarackObama/posts',
99 self
.credentials
= 'google'
101 def RunNavigateSteps(self
, action_runner
):
102 action_runner
.NavigateToPage(self
)
103 action_runner
.WaitForElement(text
='Home')
105 def RunSmoothness(self
, action_runner
):
106 interaction
= action_runner
.BeginGestureInteraction(
107 'PinchAction', is_smooth
=True)
108 action_runner
.PinchElement(selector
='[id="110031535020051778989-tab-bar"]')
112 class YoutubePage(ToughPinchZoomCasesPage
):
114 """ Why: #3 (Alexa global) """
116 def __init__(self
, page_set
):
117 super(YoutubePage
, self
).__init
__(
118 url
='http://www.youtube.com',
121 self
.credentials
= 'google'
123 def RunNavigateSteps(self
, action_runner
):
124 action_runner
.NavigateToPage(self
)
125 action_runner
.Wait(2)
127 class BlogSpotPage(ToughPinchZoomCasesPage
):
130 Why: #11 (Alexa global), google property; some blogger layouts have infinite
131 scroll but more interesting
134 def __init__(self
, page_set
):
135 super(BlogSpotPage
, self
).__init
__(
136 url
='http://googlewebmastercentral.blogspot.com/',
137 page_set
=page_set
, name
='Blogger')
139 def RunNavigateSteps(self
, action_runner
):
140 action_runner
.NavigateToPage(self
)
141 action_runner
.WaitForElement(text
='accessibility')
144 class FacebookPage(ToughPinchZoomCasesPage
):
146 """ Why: top social,Public profile """
148 def __init__(self
, page_set
):
149 super(FacebookPage
, self
).__init
__(
150 url
='http://www.facebook.com/barackobama',
151 page_set
=page_set
, name
='Facebook')
152 self
.credentials
= 'facebook'
154 def RunNavigateSteps(self
, action_runner
):
155 action_runner
.NavigateToPage(self
)
156 action_runner
.WaitForElement(text
='About')
159 class LinkedinPage(ToughPinchZoomCasesPage
):
161 """ Why: #12 (Alexa global),Public profile """
163 def __init__(self
, page_set
):
164 super(LinkedinPage
, self
).__init
__(
165 url
='http://www.linkedin.com/in/linustorvalds',
166 page_set
=page_set
, name
='LinkedIn')
169 class WikipediaPage(ToughPinchZoomCasesPage
):
171 """ Why: #6 (Alexa) most visited worldwide,Picked an interesting page """
173 def __init__(self
, page_set
):
174 super(WikipediaPage
, self
).__init
__(
175 url
='http://en.wikipedia.org/wiki/Wikipedia',
176 page_set
=page_set
, name
='Wikipedia (1 tab)')
179 class TwitterPage(ToughPinchZoomCasesPage
):
181 """ Why: #8 (Alexa global),Picked an interesting page """
183 def __init__(self
, page_set
):
184 super(TwitterPage
, self
).__init
__(
185 url
='https://twitter.com/katyperry',
186 page_set
=page_set
, name
='Twitter')
188 def RunNavigateSteps(self
, action_runner
):
189 action_runner
.NavigateToPage(self
)
190 action_runner
.Wait(2)
192 class ESPNPage(ToughPinchZoomCasesPage
):
194 """ Why: #1 sports """
196 def __init__(self
, page_set
):
197 super(ESPNPage
, self
).__init
__(
198 url
='http://espn.go.com/nba',
199 page_set
=page_set
, name
='ESPN')
202 class WeatherDotComPage(ToughPinchZoomCasesPage
):
204 """ Why: #7 (Alexa news); #27 total time spent,Picked interesting page """
206 def __init__(self
, page_set
):
207 super(WeatherDotComPage
, self
).__init
__(
208 # pylint: disable=C0301
209 url
='http://www.weather.com/weather/right-now/Mountain+View+CA+94043',
210 page_set
=page_set
, name
='Weather.com')
213 class YahooGamePage(ToughPinchZoomCasesPage
):
215 """ Why: #1 games according to Alexa (with actual games in it) """
217 def __init__(self
, page_set
):
218 super(YahooGamePage
, self
).__init
__(
219 url
='http://games.yahoo.com',
222 def RunNavigateSteps(self
, action_runner
):
223 action_runner
.NavigateToPage(self
)
224 action_runner
.Wait(2)
227 class YahooAnswersPage(ToughPinchZoomCasesPage
):
229 """ Why: #1 Alexa reference """
231 def __init__(self
, page_set
):
232 super(YahooAnswersPage
, self
).__init
__(
233 url
='http://answers.yahoo.com',
236 def RunSmoothness(self
, action_runner
):
237 interaction
= action_runner
.BeginGestureInteraction(
238 'PinchAction', is_smooth
=True)
239 action_runner
.PinchElement(selector
='#ya-content-apps')
243 class ToughPinchZoomCasesPageSet(page_set_module
.PageSet
):
245 """ Set of pages that are tricky to pinch-zoom """
248 super(ToughPinchZoomCasesPageSet
, self
).__init
__(
249 user_agent_type
='desktop',
250 archive_data_file
='data/tough_pinch_zoom_cases.json',
251 bucket
=page_set_module
.PARTNER_BUCKET
)
253 self
.AddPage(GoogleSearchPage(self
))
254 self
.AddPage(GmailPage(self
))
255 self
.AddPage(GoogleCalendarPage(self
))
256 self
.AddPage(GoogleImageSearchPage(self
))
257 self
.AddPage(GooglePlusPage(self
))
258 self
.AddPage(YoutubePage(self
))
259 self
.AddPage(BlogSpotPage(self
))
260 self
.AddPage(FacebookPage(self
))
261 self
.AddPage(LinkedinPage(self
))
262 self
.AddPage(WikipediaPage(self
))
263 self
.AddPage(TwitterPage(self
))
264 self
.AddPage(ESPNPage(self
))
266 # Why: #1 news worldwide (Alexa global)
267 self
.AddPage(ToughPinchZoomCasesPage('http://news.yahoo.com', self
))
269 # Why: #2 news worldwide
270 self
.AddPage(ToughPinchZoomCasesPage('http://www.cnn.com', self
))
272 self
.AddPage(WeatherDotComPage(self
))
274 # Why: #1 world commerce website by visits; #3 commerce in the US by time
276 self
.AddPage(ToughPinchZoomCasesPage('http://www.amazon.com', self
))
278 # Why: #1 commerce website by time spent by users in US
279 self
.AddPage(ToughPinchZoomCasesPage('http://www.ebay.com', self
))
281 self
.AddPage(YahooGamePage(self
))
283 # Why: #1 Alexa recreation
284 self
.AddPage(ToughPinchZoomCasesPage('http://booking.com', self
))
286 self
.AddPage(YahooAnswersPage(self
))
288 # Why: #1 Alexa sports
289 self
.AddPage(ToughPinchZoomCasesPage('http://sports.yahoo.com/', self
))