Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: tools/perf/page_sets/system_health/browsing_stories.py

Issue 2168743004: [system health] Add media browsing stories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from page_sets.login_helpers import facebook_login
5 from page_sets.system_health import platforms 6 from page_sets.system_health import platforms
6 from page_sets.system_health import system_health_story 7 from page_sets.system_health import system_health_story
7 8
8 9
9 class _BrowsingStory(system_health_story.SystemHealthStory): 10 class _BrowsingStory(system_health_story.SystemHealthStory):
10 """Abstract base class for browsing stories. 11 """Abstract base class for browsing stories.
11 12
12 A browsing story visits items on the main page. Subclasses provide 13 A browsing story visits items on the main page. Subclasses provide
13 CSS selector to identify the items and implement interaction using 14 CSS selector to identify the items and implement interaction using
14 the helper methods of this class. 15 the helper methods of this class.
(...skipping 16 matching lines...) Expand all
31 def _ClickLink(self, action_runner, element_function): 32 def _ClickLink(self, action_runner, element_function):
32 action_runner.WaitForElement(element_function=element_function) 33 action_runner.WaitForElement(element_function=element_function)
33 action_runner.ClickElement(element_function=element_function) 34 action_runner.ClickElement(element_function=element_function)
34 self._WaitForNavigation(action_runner) 35 self._WaitForNavigation(action_runner)
35 36
36 def _NavigateBack(self, action_runner): 37 def _NavigateBack(self, action_runner):
37 action_runner.ExecuteJavaScript('window.history.back()') 38 action_runner.ExecuteJavaScript('window.history.back()')
38 self._WaitForNavigation(action_runner) 39 self._WaitForNavigation(action_runner)
39 40
40 41
42 ##############################################################################
43 # News browsing stories.
44 ##############################################################################
45
46
41 class _NewsBrowsingStory(_BrowsingStory): 47 class _NewsBrowsingStory(_BrowsingStory):
42 """Abstract base class for news user stories. 48 """Abstract base class for news user stories.
43 49
44 A news story imitates browsing a news website: 50 A news story imitates browsing a news website:
45 1. Load the main page. 51 1. Load the main page.
46 2. Open and scroll the first news item. 52 2. Open and scroll the first news item.
47 3. Go back to the main page and scroll it. 53 3. Go back to the main page and scroll it.
48 4. Open and scroll the second news item. 54 4. Open and scroll the second news item.
49 5. Go back to the main page and scroll it. 55 5. Go back to the main page and scroll it.
50 6. etc. 56 6. etc.
(...skipping 16 matching lines...) Expand all
67 action_runner.Wait(self.ITEM_READ_TIME_IN_SECONDS) 73 action_runner.Wait(self.ITEM_READ_TIME_IN_SECONDS)
68 action_runner.RepeatableBrowserDrivenScroll( 74 action_runner.RepeatableBrowserDrivenScroll(
69 repeat_count=self.ITEM_SCROLL_REPEAT) 75 repeat_count=self.ITEM_SCROLL_REPEAT)
70 76
71 def _ScrollMainPage(self, action_runner): 77 def _ScrollMainPage(self, action_runner):
72 action_runner.tab.WaitForDocumentReadyStateToBeComplete() 78 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
73 action_runner.RepeatableBrowserDrivenScroll( 79 action_runner.RepeatableBrowserDrivenScroll(
74 repeat_count=self.MAIN_PAGE_SCROLL_REPEAT) 80 repeat_count=self.MAIN_PAGE_SCROLL_REPEAT)
75 81
76 82
77 ##############################################################################
78 # News browsing stories.
79 ##############################################################################
80
81
82 class CnnStory(_NewsBrowsingStory): 83 class CnnStory(_NewsBrowsingStory):
83 """The second top website in http://www.alexa.com/topsites/category/News""" 84 """The second top website in http://www.alexa.com/topsites/category/News"""
84 NAME = 'browse:news:cnn' 85 NAME = 'browse:news:cnn'
85 URL = 'http://edition.cnn.com/' 86 URL = 'http://edition.cnn.com/'
86 ITEM_SELECTOR = '.cd__content > h3 > a' 87 ITEM_SELECTOR = '.cd__content > h3 > a'
87 ITEMS_TO_VISIT = 2 88 ITEMS_TO_VISIT = 2
88 # TODO(ulan): Enable this story on mobile once it uses less memory and 89 # TODO(ulan): Enable this story on mobile once it uses less memory and
89 # does not crash with OOM. 90 # does not crash with OOM.
90 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY 91 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
91 92
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 def _DidLoadDocument(self, action_runner): 206 def _DidLoadDocument(self, action_runner):
206 # Close the popup window. On Nexus 9 (and probably other tables) the popup 207 # Close the popup window. On Nexus 9 (and probably other tables) the popup
207 # window does not have a "Close" button, instead it has only a "Send link 208 # window does not have a "Close" button, instead it has only a "Send link
208 # to phone" button. So on tablets we run with the popup window open. The 209 # to phone" button. So on tablets we run with the popup window open. The
209 # popup is transparent, so this is mostly an aesthetical issue. 210 # popup is transparent, so this is mostly an aesthetical issue.
210 has_button = action_runner.EvaluateJavaScript( 211 has_button = action_runner.EvaluateJavaScript(
211 '!!document.querySelector("%s")' % self._CLOSE_BUTTON_SELECTOR) 212 '!!document.querySelector("%s")' % self._CLOSE_BUTTON_SELECTOR)
212 if has_button: 213 if has_button:
213 action_runner.ClickElement(selector=self._CLOSE_BUTTON_SELECTOR) 214 action_runner.ClickElement(selector=self._CLOSE_BUTTON_SELECTOR)
214 super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner) 215 super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner)
216
217
218 ##############################################################################
219 # Media browsing stories.
220 ##############################################################################
221
222
223 class _MediaBrowsingStory(_BrowsingStory):
224 """ Abstract base class for media user stories
225
226 A media story imitates browsing a website with photo or video content:
227 1. Load a page showing a media item
228 2. Click on the next link to go to the next media item
229 3. etc.
230 """
231
232 ABSTRACT_STORY = True
233 ITEM_VIEW_TIME_IN_SECONDS = 1
234 ITEMS_TO_VISIT = 30
235 ITEM_SELECTOR_INDEX = 0
236
237 def _DidLoadDocument(self, action_runner):
238 for _ in xrange(self.ITEMS_TO_VISIT):
239 self._NavigateToItem(action_runner, self.ITEM_SELECTOR_INDEX)
240 self._ViewMediaItem(action_runner)
241
242 def _ViewMediaItem(self, action_runner):
243 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
244 action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS)
245
246
247 class ImgurMobileStory(_MediaBrowsingStory):
248 NAME = 'browse:media:imgur'
249 URL = 'http://imgur.com/gallery/5UlBN'
250 ITEM_SELECTOR = '.Navbar-customAction'
251 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
252 IS_SINGLE_PAGE_APP = True
253
254
255 class ImgurDesktopStory(_MediaBrowsingStory):
256 NAME = 'browse:media:imgur'
257 URL = 'http://imgur.com/gallery/5UlBN'
258 ITEM_SELECTOR = '.navNext'
259 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
260 IS_SINGLE_PAGE_APP = True
261
262
263 class YoutubeMobileStory(_MediaBrowsingStory):
264 NAME = 'browse:media:youtube'
265 URL = 'https://m.youtube.com/watch?v=njCDZWTI-xg'
266 ITEM_SELECTOR = '._mpfb > a'
267 IS_SINGLE_PAGE_APP = True
268 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
269 ITEM_VIEW_TIME_IN_SECONDS = 2
270 ITEMS_TO_VISIT = 15
271 ITEM_SELECTOR_INDEX = 3
272
273
274 class YoutubeDesktopStory(_MediaBrowsingStory):
275 NAME = 'browse:media:youtube'
276 URL = 'https://www.youtube.com/watch?v=Ic07xTJoP34'
277 ITEM_SELECTOR = '.yt-uix-simple-thumb-related'
278 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
279 IS_SINGLE_PAGE_APP = True
280 ITEM_VIEW_TIME_IN_SECONDS = 2
281 ITEMS_TO_VISIT = 15
282
283
284 class FacebookMobileStory(_MediaBrowsingStory):
285 NAME = 'browse:media:facebookphotos'
286 URL = ('https://facebook.com/photo.php?fbid=10154398154450513&'
nednguyen 2016/07/26 18:33:43 nits: you can do URL = ( 'https://facebook.com/
Hannes Payer (out of office) 2016/07/27 09:04:33 Done.
287 'id=255110695512&set=a.406278500512.172778.255110695512&'
288 'source=54&refid=13')
289 ITEM_SELECTOR = '._57-p > a'
290 IS_SINGLE_PAGE_APP = True
291 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
292 ITEM_VIEW_TIME_IN_SECONDS = 2
293 ITEMS_TO_VISIT = 20
294 ITEM_SELECTOR_INDEX = 1
295
296
297 class FacebookDesktopStory(_MediaBrowsingStory):
298 NAME = 'browse:media:facebookphotos'
299 URL = ('https://www.facebook.com/NASA/photos/a.67899501771.69169.54971236771/'
300 '10154267233981772/?type=3&theater')
nednguyen 2016/07/26 18:33:43 Same here
Hannes Payer (out of office) 2016/07/27 09:04:33 Done.
301 ITEM_SELECTOR = '.snowliftPager.next'
302 IS_SINGLE_PAGE_APP = True
303 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
304 ITEM_VIEW_TIME_IN_SECONDS = 2
305 ITEMS_TO_VISIT = 20
306
307 def _Login(self, action_runner):
308 facebook_login.LoginWithDesktopSite(action_runner, 'facebook3',
309 self.credentials_path)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698