Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / tools / perf / page_sets / top_10.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 SimpleScrollPage(page_module.Page):
11   def __init__(self, url, page_set, credentials='', name=''):
12     super(SimpleScrollPage, self).__init__(url, page_set=page_set, name=name)
13     self.credentials = credentials
14
15   def RunSmoothness(self, action_runner):
16     action_runner.RunAction(ScrollAction())
17
18 class Google(SimpleScrollPage):
19   def __init__(self, page_set):
20     super(Google, self).__init__(
21       url='https://www.google.com/#hl=en&q=barack+obama', page_set=page_set)
22
23   def RunNavigateSteps(self, action_runner):
24     super(Google, self).RunNavigateSteps(action_runner)
25     action_runner.RunAction(WaitAction(
26       {'condition': 'element', 'text': 'Next'}))
27
28
29 class Gmail(SimpleScrollPage):
30   def __init__(self, page_set):
31     super(Gmail, self).__init__(
32       url='https://mail.google.com/mail/',
33       page_set=page_set,
34       credentials='google')
35
36   def RunNavigateSteps(self, action_runner):
37     super(Gmail, self).RunNavigateSteps(action_runner)
38     action_runner.RunAction(WaitAction(
39       {'javascript' : 'window.gmonkey !== undefined &&'
40        'document.getElementById("gb") !== null'}))
41
42
43 class GoogleCalendar(SimpleScrollPage):
44   def __init__(self, page_set):
45     super(GoogleCalendar, self).__init__(
46       url='https://www.google.com/calendar/',
47       page_set=page_set,
48       credentials='google')
49
50   def RunNavigateSteps(self, action_runner):
51     super(GoogleCalendar, self).RunNavigateSteps(action_runner)
52     action_runner.RunAction(JavascriptAction(
53       { 'expression' :
54        '(function() { var elem = document.createElement("meta");'
55       'elem.name="viewport";'
56       'elem.content="initial-scale=1";'
57       'document.body.appendChild(elem); })();'}))
58     action_runner.RunAction(WaitAction({'seconds' : 2}))
59     action_runner.RunAction(WaitAction({
60       'condition' : 'element', 'selector' : 'div[class~="navForward"]'}))
61
62
63 class Youtube(SimpleScrollPage):
64   def __init__(self, page_set):
65     super(Youtube, self).__init__(
66       url='http://www.youtube.com',
67       page_set=page_set,
68       credentials='google')
69
70   def RunNavigateSteps(self, action_runner):
71     super(Youtube, self).RunNavigateSteps(action_runner)
72     action_runner.RunAction(WaitAction({'seconds' : 2}))
73
74
75 class Facebook(SimpleScrollPage):
76   def __init__(self, page_set):
77     super(Facebook, self).__init__(
78       url='http://www.facebook.com/barackobama',
79       page_set=page_set,
80       credentials='facebook',
81       name='Facebook')
82
83   def RunNavigateSteps(self, action_runner):
84     super(Facebook, self).RunNavigateSteps(action_runner)
85     action_runner.RunAction(WaitAction(
86       {'condition': 'element', 'text': 'About'}))
87
88
89 class Top10PageSet(page_set_module.PageSet):
90   def __init__(self):
91     super(Top10PageSet, self).__init__(
92       description='10 Pages chosen from Alexa top sites',
93       archive_data_file='data/top_10.json',
94       credentials_path='data/credentials.json',
95       user_agent_type='desktop')
96
97     # top google property; a google tab is often open
98     self.AddPage(Google(self))
99
100     # productivity, top google properties
101     self.AddPage(Gmail(self))
102
103     # productivity, top google properties
104     self.AddPage(GoogleCalendar(self))
105
106     # #3 (Alexa global)
107     self.AddPage(Youtube(self))
108
109     # top social, Public profile
110     self.AddPage(Facebook(self))
111
112     # #6 (Alexa) most visited worldwide,Picked an interesting page
113     self.AddPage(SimpleScrollPage('http://en.wikipedia.org/wiki/Wikipedia',
114                                   self, name='Wikipedia'))
115
116     # #1 world commerce website by visits; #3 commerce in the US by time spent
117     self.AddPage(SimpleScrollPage('http://www.amazon.com', self))
118
119     # #4 Alexa
120     self.AddPage(SimpleScrollPage('http://www.yahoo.com/', self))
121
122     # #16 Alexa
123     self.AddPage(SimpleScrollPage('http://www.bing.com/', self))
124
125     # #20 Alexa
126     self.AddPage(SimpleScrollPage('http://www.ask.com/', self))