Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / tools / perf / page_sets / tough_pinch_zoom_cases.py
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
8
9
10 class ToughPinchZoomCasesPage(page_module.Page):
11
12   def __init__(self, url, page_set, name=''):
13     super(ToughPinchZoomCasesPage, self).__init__(url=url, page_set=page_set,
14                                                   name=name)
15     self.credentials_path = 'data/credentials.json'
16     self.user_agent_type = 'desktop'
17     self.archive_data_file = 'data/tough_pinch_zoom_cases.json'
18
19   def RunSmoothness(self, action_runner):
20     action_runner.RunAction(PinchAction())
21
22
23 class GoogleSearchPage(ToughPinchZoomCasesPage):
24
25   """ Why: top google property; a google tab is often open. """
26
27   def __init__(self, page_set):
28     super(GoogleSearchPage, self).__init__(
29       url='https://www.google.com/#hl=en&q=barack+obama',
30       page_set=page_set)
31
32   def RunNavigateSteps(self, action_runner):
33     action_runner.RunAction(NavigateAction())
34     action_runner.RunAction(WaitAction(
35       {
36         'text': 'Next',
37         'condition': 'element'
38       }))
39
40
41 class GmailPage(ToughPinchZoomCasesPage):
42
43   """ Why: productivity, top google properties """
44
45   def __init__(self, page_set):
46     super(GmailPage, self).__init__(
47       url='https://mail.google.com/mail/',
48       page_set=page_set)
49
50     self.credentials = 'google'
51
52   def RunNavigateSteps(self, action_runner):
53     action_runner.RunAction(NavigateAction())
54     action_runner.RunAction(WaitAction(
55       {
56         'javascript' : (
57           'window.gmonkey !== undefined &&'
58           'document.getElementById("gb") !== null')
59       }))
60
61
62 class GoogleCalendarPage(ToughPinchZoomCasesPage):
63
64   """ Why: productivity, top google properties """
65
66   def __init__(self, page_set):
67     super(GoogleCalendarPage, self).__init__(
68       url='https://www.google.com/calendar/',
69       page_set=page_set)
70
71     self.credentials = 'google'
72
73   def RunNavigateSteps(self, action_runner):
74     action_runner.RunAction(NavigateAction())
75     action_runner.RunAction(WaitAction({'seconds':2}))
76
77   def RunSmoothness(self, action_runner):
78     action_runner.RunAction(PinchAction(
79       {
80         'left_anchor_percentage': 0.1,
81         'top_anchor_percentage': 0.1
82       }))
83
84
85 class GoogleImageSearchPage(ToughPinchZoomCasesPage):
86
87   """ Why: tough image case; top google properties """
88
89   def __init__(self, page_set):
90     super(GoogleImageSearchPage, self).__init__(
91       url='https://www.google.com/search?q=cats&tbm=isch',
92       page_set=page_set)
93
94     self.credentials = 'google'
95
96
97 class GooglePlusPage(ToughPinchZoomCasesPage):
98
99   """ Why: social; top google property; Public profile; infinite scrolls """
100
101   def __init__(self, page_set):
102     super(GooglePlusPage, self).__init__(
103       url='https://plus.google.com/+BarackObama/posts',
104       page_set=page_set)
105
106     self.credentials = 'google'
107
108   def RunNavigateSteps(self, action_runner):
109     action_runner.RunAction(NavigateAction())
110     action_runner.RunAction(WaitAction(
111       {
112         'text': 'Home',
113         'condition': 'element'
114       }))
115
116   def RunSmoothness(self, action_runner):
117     action_runner.RunAction(PinchAction(
118       {
119         'element_function': '''
120           function(callback) {
121             callback(document.getElementsByClassName("Ct")[0])
122           }'''
123       }))
124
125
126 class YoutubePage(ToughPinchZoomCasesPage):
127
128   """ Why: #3 (Alexa global) """
129
130   def __init__(self, page_set):
131     super(YoutubePage, self).__init__(
132       url='http://www.youtube.com',
133       page_set=page_set)
134
135     self.credentials = 'google'
136
137   def RunNavigateSteps(self, action_runner):
138     action_runner.RunAction(NavigateAction())
139     action_runner.RunAction(WaitAction({'seconds':2}))
140
141 class BlogSpotPage(ToughPinchZoomCasesPage):
142
143   """
144   Why: #11 (Alexa global), google property; some blogger layouts have infinite
145   scroll but more interesting
146   """
147
148   def __init__(self, page_set):
149     super(BlogSpotPage, self).__init__(
150       url='http://googlewebmastercentral.blogspot.com/',
151       page_set=page_set, name='Blogger')
152
153   def RunNavigateSteps(self, action_runner):
154     action_runner.RunAction(NavigateAction())
155     action_runner.RunAction(WaitAction(
156       {
157         'text': 'accessibility',
158         'condition': 'element'
159       }))
160
161
162 class FacebookPage(ToughPinchZoomCasesPage):
163
164   """ Why: top social,Public profile """
165
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'
171
172   def RunNavigateSteps(self, action_runner):
173     action_runner.RunAction(NavigateAction())
174     action_runner.RunAction(WaitAction(
175       {
176         'text': 'About',
177         'condition': 'element'
178       }))
179
180
181 class LinkedinPage(ToughPinchZoomCasesPage):
182
183   """ Why: #12 (Alexa global),Public profile """
184
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')
189
190
191 class WikipediaPage(ToughPinchZoomCasesPage):
192
193   """ Why: #6 (Alexa) most visited worldwide,Picked an interesting page """
194
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)')
199
200
201 class TwitterPage(ToughPinchZoomCasesPage):
202
203   """ Why: #8 (Alexa global),Picked an interesting page """
204
205   def __init__(self, page_set):
206     super(TwitterPage, self).__init__(
207       url='https://twitter.com/katyperry',
208       page_set=page_set, name='Twitter')
209
210   def RunNavigateSteps(self, action_runner):
211     action_runner.RunAction(NavigateAction())
212     action_runner.RunAction(WaitAction({'seconds':2}))
213
214 class ESPNPage(ToughPinchZoomCasesPage):
215
216   """ Why: #1 sports """
217
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')
222
223
224 class WeatherDotComPage(ToughPinchZoomCasesPage):
225
226   """ Why: #7 (Alexa news); #27 total time spent,Picked interesting page """
227
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')
233
234
235 class YahooGamePage(ToughPinchZoomCasesPage):
236
237   """ Why: #1 games according to Alexa (with actual games in it) """
238
239   def __init__(self, page_set):
240     super(YahooGamePage, self).__init__(
241       url='http://games.yahoo.com',
242       page_set=page_set)
243
244   def RunNavigateSteps(self, action_runner):
245     action_runner.RunAction(NavigateAction())
246     action_runner.RunAction(WaitAction({'seconds':2}))
247
248 class ToughPinchZoomCasesPageSet(page_set_module.PageSet):
249
250   """ Set of pages that are tricky to pinch-zoom """
251
252   def __init__(self):
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')
257
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))
270
271     # Why: #1 news worldwide (Alexa global)
272     self.AddPage(ToughPinchZoomCasesPage('http://news.yahoo.com', self))
273
274     # Why: #2 news worldwide
275     self.AddPage(ToughPinchZoomCasesPage('http://www.cnn.com', self))
276
277     self.AddPage(WeatherDotComPage(self))
278
279     # Why: #1 world commerce website by visits; #3 commerce in the US by time
280     # spent
281     self.AddPage(ToughPinchZoomCasesPage('http://www.amazon.com', self))
282
283     # Why: #1 commerce website by time spent by users in US
284     self.AddPage(ToughPinchZoomCasesPage('http://www.ebay.com', self))
285
286     self.AddPage(YahooGamePage(self))
287
288     # Why: #1 Alexa recreation
289     self.AddPage(ToughPinchZoomCasesPage('http://booking.com', self))
290
291     # Why: #1 Alexa reference
292     self.AddPage(ToughPinchZoomCasesPage('http://answers.yahoo.com', self))
293
294     # Why: #1 Alexa sports
295     self.AddPage(ToughPinchZoomCasesPage('http://sports.yahoo.com/', self))