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
7 from page_sets
import key_mobile_sites_pages
8 from page_sets
import repaint_helpers
12 def _CreatePageClassWithRepaintInteractions(page_cls
, mode
, height
, width
):
13 class DerivedRepaintPage(page_cls
): # pylint: disable=W0232
15 def RunPageInteractions(self
, action_runner
):
16 repaint_helpers
.Repaint(
17 action_runner
, mode
=mode
, width
=width
, height
=height
)
19 return DerivedRepaintPage
22 class KeyMobileSitesRepaintPage(page_module
.Page
):
24 def __init__(self
, url
, page_set
, mode
, height
, width
, name
='', labels
=None):
25 super(KeyMobileSitesRepaintPage
, self
).__init
__(
26 url
=url
, page_set
=page_set
, name
=name
,
27 credentials_path
='data/credentials.json', labels
=labels
)
28 self
.user_agent_type
= 'mobile'
29 self
.archive_data_file
= 'data/key_mobile_sites_repaint.json'
34 def RunPageInteractions(self
, action_runner
):
35 repaint_helpers
.Repaint(
36 action_runner
, mode
=self
._mode
, width
=self
._width
, height
=self
._height
)
39 class KeyMobileSitesRepaintPageSet(page_set_module
.PageSet
):
41 """ Key mobile sites with repaint interactions. """
43 def __init__(self
, mode
='viewport', width
=None, height
=None):
44 super(KeyMobileSitesRepaintPageSet
, self
).__init
__(
45 user_agent_type
='mobile',
46 archive_data_file
='data/key_mobile_sites_repaint.json',
47 bucket
=page_set_module
.PARTNER_BUCKET
)
50 # Add pages with predefined classes that contain custom navigation logic.
51 predefined_page_classes
= [
52 key_mobile_sites_pages
.CapitolVolkswagenPage
,
53 key_mobile_sites_pages
.TheVergeArticlePage
,
54 key_mobile_sites_pages
.CnnArticlePage
,
55 key_mobile_sites_pages
.FacebookPage
,
56 key_mobile_sites_pages
.YoutubeMobilePage
,
57 key_mobile_sites_pages
.LinkedInPage
,
58 key_mobile_sites_pages
.YahooAnswersPage
,
59 key_mobile_sites_pages
.GmailPage
,
60 key_mobile_sites_pages
.GoogleNewsMobilePage
,
61 key_mobile_sites_pages
.GoogleNewsMobile2Page
,
62 key_mobile_sites_pages
.AmazonNicolasCagePage
,
63 # Page behaves non-deterministically, replaced with test version for now.
64 # key_mobile_sites_pages.GroupClonedPage,
66 # mean_input_event_latency cannot be tracked correctly for
67 # GroupClonedListImagesPage. See crbug.com/409086.
68 # key_mobile_sites_pages.GroupClonedListImagesPage,
70 for page_class
in predefined_page_classes
:
72 _CreatePageClassWithRepaintInteractions(
73 page_class
, mode
=mode
, height
=height
, width
=width
)(self
))
75 # Add pages with custom labels.
78 self
.AddUserStory(KeyMobileSitesRepaintPage(
79 url
='http://nytimes.com/', page_set
=self
, labels
=['fastpath'],
80 mode
=mode
, height
=height
, width
=width
))
82 # Why: Image-heavy site.
83 self
.AddUserStory(KeyMobileSitesRepaintPage(
84 url
='http://cuteoverload.com', page_set
=self
, labels
=['fastpath'],
85 mode
=mode
, height
=height
, width
=width
))
87 # Why: #11 (Alexa global), google property; some blogger layouts
88 # have infinite scroll but more interesting.
89 self
.AddUserStory(KeyMobileSitesRepaintPage(
90 url
='http://googlewebmastercentral.blogspot.com/',
91 page_set
=self
, name
='Blogger', mode
=mode
, height
=height
, width
=width
))
93 # Why: #18 (Alexa global), Picked an interesting post """
94 self
.AddUserStory(KeyMobileSitesRepaintPage(
95 # pylint: disable=line-too-long
96 url
='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
98 name
='Wordpress', mode
=mode
, height
=height
, width
=width
))
100 # Why: #6 (Alexa) most visited worldwide, picked an interesting page
101 self
.AddUserStory(KeyMobileSitesRepaintPage(
102 url
='http://en.wikipedia.org/wiki/Wikipedia',
104 name
='Wikipedia (1 tab)', mode
=mode
, height
=height
, width
=width
))
106 # Why: #8 (Alexa global), picked an interesting page
107 # Forbidden (Rate Limit Exceeded)
108 # self.AddUserStory(KeyMobileSitesRepaintPage(
109 # url='http://twitter.com/katyperry', page_set=self, name='Twitter'))
111 # Why: #37 (Alexa global) """
112 self
.AddUserStory(KeyMobileSitesRepaintPage(
113 url
='http://pinterest.com',
115 name
='Pinterest', mode
=mode
, height
=height
, width
=width
))
118 # Fails often; crbug.com/249722'
119 # self.AddUserStory(KeyMobileSitesRepaintPage(
120 # url='http://espn.go.com', page_set=self, name='ESPN'))
121 # Why: crbug.com/231413
122 # Doesn't scroll; crbug.com/249736
123 # self.AddUserStory(KeyMobileSitesRepaintPage(
124 # url='http://forecast.io', page_set=self))
125 # Why: crbug.com/169827
126 self
.AddUserStory(KeyMobileSitesRepaintPage(
127 url
='http://slashdot.org/', page_set
=self
, labels
=['fastpath'],
128 mode
=mode
, width
=width
, height
=height
))
130 # Why: #5 Alexa news """
132 self
.AddUserStory(KeyMobileSitesRepaintPage(
133 url
='http://www.reddit.com/r/programming/comments/1g96ve',
134 page_set
=self
, labels
=['fastpath'],
135 mode
=mode
, width
=width
, height
=height
))
137 # Why: Problematic use of fixed position elements """
138 self
.AddUserStory(KeyMobileSitesRepaintPage(
139 url
='http://www.boingboing.net', page_set
=self
, labels
=['fastpath'],
140 mode
=mode
, width
=width
, height
=height
))
142 # Add simple pages with no custom navigation logic or labels.
144 # Why: Social; top Google property; Public profile; infinite scrolls.
145 # pylint: disable=line-too-long
146 'https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
147 # Why: crbug.com/242544
148 ('http://www.androidpolice.com/2012/10/03/rumor-evidence-mounts-that-an-'
149 'lg-optimus-g-nexus-is-coming-along-with-a-nexus-phone-certification-'
151 # Why: crbug.com/149958
154 'http://theverge.com',
157 # Why: Top Google property; a Google tab is often open
158 'https://www.google.com/#hl=en&q=barack+obama',
159 # Why: #1 news worldwide (Alexa global)
160 'http://news.yahoo.com',
161 # Why: #2 news worldwide
162 'http://www.cnn.com',
163 # Why: #1 commerce website by time spent by users in US
164 'http://shop.mobileweb.ebay.com/searchresults?kw=viking+helmet',
165 # Why: #1 Alexa recreation
166 # pylint: disable=line-too-long
167 'http://www.booking.com/searchresults.html?src=searchresults&latitude=65.0500&longitude=25.4667',
168 # Why: #1 Alexa sports
169 'http://sports.yahoo.com/',
171 'http://techcrunch.com',
172 # Why: #6 Alexa sports
174 # Why: #14 Alexa California
175 'http://www.sfgate.com/',
176 # Why: Non-latin character set
177 'http://worldjournal.com/',
179 'http://www.wowwiki.com/World_of_Warcraft:_Mists_of_Pandaria',
180 # Why: #15 Alexa news
181 'http://online.wsj.com/home-page',
182 # Why: Image-heavy mobile site
183 'http://www.deviantart.com/',
184 # Why: Top search engine
185 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&'
186 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'),
187 # Why: Top search engine
188 'http://www.bing.com/search?q=sloths',
189 # Why: Good example of poor initial scrolling
190 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans'
193 for url
in urls_list
:
194 self
.AddUserStory(KeyMobileSitesRepaintPage(
195 url
, self
, mode
=mode
, height
=height
, width
=width
))