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
9 class ToughPinchZoomCasesPage(page_module
.Page
):
11 def __init__(self
, url
, page_set
, name
=''):
12 super(ToughPinchZoomCasesPage
, self
).__init
__(
13 url
=url
, page_set
=page_set
, name
=name
,
14 shared_page_state_class
=shared_page_state
.SharedDesktopPageState
,
15 credentials_path
= 'data/credentials.json')
16 self
.archive_data_file
= 'data/tough_pinch_zoom_cases.json'
18 def RunPinchGesture(self
, action_runner
, left_anchor_ratio
=0.5,
19 top_anchor_ratio
=0.5, scale_factor
=None,
20 speed_in_pixels_per_second
=800):
21 with action_runner
.CreateGestureInteraction('PinchAction',
23 action_runner
.PinchPage(
24 left_anchor_ratio
=left_anchor_ratio
,
25 top_anchor_ratio
=top_anchor_ratio
,
26 scale_factor
=scale_factor
,
27 speed_in_pixels_per_second
=speed_in_pixels_per_second
)
29 def RunPageInteractions(self
, action_runner
):
30 action_runner
.tab
.WaitForDocumentReadyStateToBeInteractiveOrBetter()
31 for _
in xrange(0, 3):
32 self
.RunPinchGesture(action_runner
, scale_factor
=7.0)
33 self
.RunPinchGesture(action_runner
, scale_factor
=1/2.0)
34 self
.RunPinchGesture(action_runner
, scale_factor
=1/2.0)
35 self
.RunPinchGesture(action_runner
, scale_factor
=1/2.0)
37 class GoogleSearchPage(ToughPinchZoomCasesPage
):
39 """ Why: top google property; a google tab is often open. """
41 def __init__(self
, page_set
):
42 super(GoogleSearchPage
, self
).__init
__(
43 url
='https://www.google.com/#hl=en&q=barack+obama',
46 def RunNavigateSteps(self
, action_runner
):
47 super(GoogleSearchPage
, self
).RunNavigateSteps(action_runner
)
48 action_runner
.WaitForElement(text
='Next')
51 class GmailPage(ToughPinchZoomCasesPage
):
53 """ Why: productivity, top google properties """
55 def __init__(self
, page_set
):
56 super(GmailPage
, self
).__init
__(
57 url
='https://mail.google.com/mail/',
60 self
.credentials
= 'google'
62 def RunNavigateSteps(self
, action_runner
):
63 super(GmailPage
, self
).RunNavigateSteps(action_runner
)
64 action_runner
.WaitForJavaScriptCondition(
65 'window.gmonkey !== undefined &&'
66 'document.getElementById("gb") !== null')
69 class GoogleCalendarPage(ToughPinchZoomCasesPage
):
71 """ Why: productivity, top google properties """
73 def __init__(self
, page_set
):
74 super(GoogleCalendarPage
, self
).__init
__(
75 url
='https://www.google.com/calendar/',
78 self
.credentials
= 'google'
80 def RunNavigateSteps(self
, action_runner
):
81 super(GoogleCalendarPage
, self
).RunNavigateSteps(action_runner
)
84 class GoogleImageSearchPage(ToughPinchZoomCasesPage
):
86 """ Why: tough image case; top google properties """
88 def __init__(self
, page_set
):
89 super(GoogleImageSearchPage
, self
).__init
__(
90 url
='https://www.google.com/search?q=cats&tbm=isch',
93 self
.credentials
= 'google'
96 class YoutubePage(ToughPinchZoomCasesPage
):
98 """ Why: #3 (Alexa global) """
100 def __init__(self
, page_set
):
101 super(YoutubePage
, self
).__init
__(
102 url
='http://www.youtube.com',
105 self
.credentials
= 'google'
107 def RunNavigateSteps(self
, action_runner
):
108 super(YoutubePage
, self
).RunNavigateSteps(action_runner
)
109 action_runner
.Wait(2)
111 class BlogSpotPage(ToughPinchZoomCasesPage
):
114 Why: #11 (Alexa global), google property; some blogger layouts have infinite
115 scroll but more interesting
118 def __init__(self
, page_set
):
119 super(BlogSpotPage
, self
).__init
__(
120 url
='http://googlewebmastercentral.blogspot.com/',
121 page_set
=page_set
, name
='Blogger')
123 def RunNavigateSteps(self
, action_runner
):
124 super(BlogSpotPage
, self
).RunNavigateSteps(action_runner
)
125 action_runner
.WaitForElement(text
='accessibility')
128 class FacebookPage(ToughPinchZoomCasesPage
):
130 """ Why: top social,Public profile """
132 def __init__(self
, page_set
):
133 super(FacebookPage
, self
).__init
__(
134 url
='http://www.facebook.com/barackobama',
135 page_set
=page_set
, name
='Facebook')
136 self
.credentials
= 'facebook'
138 def RunNavigateSteps(self
, action_runner
):
139 super(FacebookPage
, self
).RunNavigateSteps(action_runner
)
140 action_runner
.WaitForElement(text
='About')
143 class LinkedinPage(ToughPinchZoomCasesPage
):
145 """ Why: #12 (Alexa global),Public profile """
147 def __init__(self
, page_set
):
148 super(LinkedinPage
, self
).__init
__(
149 url
='http://www.linkedin.com/in/linustorvalds',
150 page_set
=page_set
, name
='LinkedIn')
153 class WikipediaPage(ToughPinchZoomCasesPage
):
155 """ Why: #6 (Alexa) most visited worldwide,Picked an interesting page """
157 def __init__(self
, page_set
):
158 super(WikipediaPage
, self
).__init
__(
159 url
='http://en.wikipedia.org/wiki/Wikipedia',
160 page_set
=page_set
, name
='Wikipedia (1 tab)')
163 class TwitterPage(ToughPinchZoomCasesPage
):
165 """ Why: #8 (Alexa global),Picked an interesting page """
167 def __init__(self
, page_set
):
168 super(TwitterPage
, self
).__init
__(
169 url
='https://twitter.com/katyperry',
170 page_set
=page_set
, name
='Twitter')
172 def RunNavigateSteps(self
, action_runner
):
173 super(TwitterPage
, self
).RunNavigateSteps(action_runner
)
174 action_runner
.Wait(2)
176 class ESPNPage(ToughPinchZoomCasesPage
):
178 """ Why: #1 sports """
180 def __init__(self
, page_set
):
181 super(ESPNPage
, self
).__init
__(
182 url
='http://espn.go.com/nba',
183 page_set
=page_set
, name
='ESPN')
186 class WeatherDotComPage(ToughPinchZoomCasesPage
):
188 """ Why: #7 (Alexa news); #27 total time spent,Picked interesting page """
190 def __init__(self
, page_set
):
191 super(WeatherDotComPage
, self
).__init
__(
192 # pylint: disable=C0301
193 url
='http://www.weather.com/weather/right-now/Mountain+View+CA+94043',
194 page_set
=page_set
, name
='Weather.com')
197 class YahooGamePage(ToughPinchZoomCasesPage
):
199 """ Why: #1 games according to Alexa (with actual games in it) """
201 def __init__(self
, page_set
):
202 super(YahooGamePage
, self
).__init
__(
203 url
='http://games.yahoo.com',
206 def RunNavigateSteps(self
, action_runner
):
207 super(YahooGamePage
, self
).RunNavigateSteps(action_runner
)
208 action_runner
.Wait(2)
211 class ToughPinchZoomCasesPageSet(story
.StorySet
):
213 """ Set of pages that are tricky to pinch-zoom """
216 super(ToughPinchZoomCasesPageSet
, self
).__init
__(
217 archive_data_file
='data/tough_pinch_zoom_cases.json',
218 cloud_storage_bucket
=story
.PARTNER_BUCKET
)
220 self
.AddStory(GoogleSearchPage(self
))
221 self
.AddStory(GmailPage(self
))
222 self
.AddStory(GoogleCalendarPage(self
))
223 self
.AddStory(GoogleImageSearchPage(self
))
224 self
.AddStory(YoutubePage(self
))
225 self
.AddStory(BlogSpotPage(self
))
226 self
.AddStory(FacebookPage(self
))
227 self
.AddStory(LinkedinPage(self
))
228 self
.AddStory(WikipediaPage(self
))
229 self
.AddStory(TwitterPage(self
))
230 self
.AddStory(ESPNPage(self
))
232 # Why: #1 news worldwide (Alexa global)
233 self
.AddStory(ToughPinchZoomCasesPage('http://news.yahoo.com', self
))
235 # Why: #2 news worldwide
236 self
.AddStory(ToughPinchZoomCasesPage('http://www.cnn.com', self
))
238 self
.AddStory(WeatherDotComPage(self
))
240 # Why: #1 world commerce website by visits; #3 commerce in the US by time
242 self
.AddStory(ToughPinchZoomCasesPage('http://www.amazon.com', self
))
244 # Why: #1 commerce website by time spent by users in US
245 self
.AddStory(ToughPinchZoomCasesPage('http://www.ebay.com', self
))
247 self
.AddStory(YahooGamePage(self
))
249 # Why: #1 Alexa recreation
250 self
.AddStory(ToughPinchZoomCasesPage('http://booking.com', self
))
252 # Why: #1 Alexa sports
253 self
.AddStory(ToughPinchZoomCasesPage('http://sports.yahoo.com/', self
))