Chromium Code Reviews| Index: tools/perf/page_sets/system_health/browsing_stories.py |
| diff --git a/tools/perf/page_sets/system_health/browsing_stories.py b/tools/perf/page_sets/system_health/browsing_stories.py |
| index 34efe2b882ab01ac10c399e59719639b80878f52..6c2422d93820cf39755de958a6102c01a1cc678f 100644 |
| --- a/tools/perf/page_sets/system_health/browsing_stories.py |
| +++ b/tools/perf/page_sets/system_health/browsing_stories.py |
| @@ -2,6 +2,7 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +from page_sets.login_helpers import facebook_login |
| from page_sets.system_health import platforms |
| from page_sets.system_health import system_health_story |
| @@ -16,7 +17,6 @@ class _BrowsingStory(system_health_story.SystemHealthStory): |
| IS_SINGLE_PAGE_APP = False |
| ITEM_SELECTOR = NotImplemented |
| - ITEMS_TO_VISIT = 4 |
| ABSTRACT_STORY = True |
| def _WaitForNavigation(self, action_runner): |
| @@ -38,6 +38,11 @@ class _BrowsingStory(system_health_story.SystemHealthStory): |
| self._WaitForNavigation(action_runner) |
| +############################################################################## |
| +# News browsing stories. |
| +############################################################################## |
| + |
| + |
| class _NewsBrowsingStory(_BrowsingStory): |
| """Abstract base class for news user stories. |
| @@ -52,6 +57,7 @@ class _NewsBrowsingStory(_BrowsingStory): |
| ITEM_READ_TIME_IN_SECONDS = 3 |
| ITEM_SCROLL_REPEAT = 2 |
| + ITEMS_TO_VISIT = 4 |
| MAIN_PAGE_SCROLL_REPEAT = 0 |
| ABSTRACT_STORY = True |
| @@ -74,11 +80,6 @@ class _NewsBrowsingStory(_BrowsingStory): |
| repeat_count=self.MAIN_PAGE_SCROLL_REPEAT) |
| -############################################################################## |
| -# News browsing stories. |
| -############################################################################## |
| - |
| - |
| class CnnStory(_NewsBrowsingStory): |
| """The second top website in http://www.alexa.com/topsites/category/News""" |
| NAME = 'browse:news:cnn' |
| @@ -212,3 +213,98 @@ class WashingtonPostMobileStory(_NewsBrowsingStory): |
| if has_button: |
| action_runner.ClickElement(selector=self._CLOSE_BUTTON_SELECTOR) |
| super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner) |
| + |
| + |
| +############################################################################## |
| +# Media browsing stories. |
| +############################################################################## |
| + |
| + |
| +class _MediaBrowsingStory(_BrowsingStory): |
| + """Abstract base class for media user stories |
| + |
| + A media story imitates browsing a website with photo or video content: |
| + 1. Load a page showing a media item |
| + 2. Click on the next link to go to the next media item |
| + 3. etc. |
| + """ |
| + |
| + ABSTRACT_STORY = True |
| + ITEM_VIEW_TIME_IN_SECONDS = 3 |
| + ITEMS_TO_VISIT = 15 |
| + ITEM_SELECTOR_INDEX = 0 |
| + |
| + def _DidLoadDocument(self, action_runner): |
| + for _ in xrange(self.ITEMS_TO_VISIT): |
| + self._NavigateToItem(action_runner, self.ITEM_SELECTOR_INDEX) |
| + self._ViewMediaItem(action_runner) |
| + |
| + def _ViewMediaItem(self, action_runner): |
| + action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| + action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS) |
| + |
| + |
| +class ImgurMobileStory(_MediaBrowsingStory): |
|
petrcermak
2016/08/04 13:32:42
Note that you could share common properties by def
Hannes Payer (out of office)
2016/08/05 10:21:05
Right on. I decided to keep the current structure
|
| + NAME = 'browse:media:imgur' |
| + URL = 'http://imgur.com/gallery/5UlBN' |
| + ITEM_SELECTOR = '.Navbar-customAction' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + IS_SINGLE_PAGE_APP = True |
| + |
| + |
| +class ImgurDesktopStory(_MediaBrowsingStory): |
| + NAME = 'browse:media:imgur' |
| + URL = 'http://imgur.com/gallery/5UlBN' |
| + ITEM_SELECTOR = '.navNext' |
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| + IS_SINGLE_PAGE_APP = True |
| + |
| + |
| +class YoutubeMobileStory(_MediaBrowsingStory): |
|
petrcermak
2016/08/04 13:32:42
nit: can you please change this to YouTubeMobileSt
Hannes Payer (out of office)
2016/08/05 10:21:05
Done.
|
| + NAME = 'browse:media:youtube' |
| + URL = 'https://m.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' |
| + ITEM_SELECTOR = '._mhgb > a' |
| + IS_SINGLE_PAGE_APP = True |
|
petrcermak
2016/08/04 13:32:42
nit: Can you please order the class fields consist
Hannes Payer (out of office)
2016/08/05 10:21:05
Done.
|
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + ITEM_SELECTOR_INDEX = 3 |
| + |
| + |
| +class YoutubeDesktopStory(_MediaBrowsingStory): |
|
petrcermak
2016/08/04 13:32:42
ditto (capital "T")
Hannes Payer (out of office)
2016/08/05 10:21:05
Done.
|
| + NAME = 'browse:media:youtube' |
| + URL = 'https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' |
| + ITEM_SELECTOR = '.yt-uix-simple-thumb-related' |
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| + IS_SINGLE_PAGE_APP = True |
| + ITEM_VIEW_TIME_IN_SECONDS = 5 |
|
petrcermak
2016/08/04 13:32:42
Could you please add a short comment why you overr
Hannes Payer (out of office)
2016/08/05 10:21:05
Done.
|
| + ITEMS_TO_VISIT = 8 |
| + ITEM_SELECTOR_INDEX = 3 |
| + |
| + |
| +class FacebookMobileStory(_MediaBrowsingStory): |
| + NAME = 'browse:media:facebookphotos' |
|
petrcermak
2016/08/04 13:32:42
nit: I think facebook_photos would be better (cons
Hannes Payer (out of office)
2016/08/05 10:21:05
Done.
|
| + URL = ( |
| + 'https://m.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/10153911739606676/?type=3&source=54&ref=page_internal') |
| + ITEM_SELECTOR = '._57-p > a' |
| + IS_SINGLE_PAGE_APP = True |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + ITEM_SELECTOR_INDEX = 1 |
| + |
| + def _Login(self, action_runner): |
| + action_runner.Navigate('https://m.facebook.com/NASA') |
|
petrcermak
2016/08/04 13:32:42
Why do you go to NASA and then back to Rihanna? If
Hannes Payer (out of office)
2016/08/05 10:21:05
Leftover, changed to rihanna.
|
| + action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| + |
|
petrcermak
2016/08/04 13:32:42
nit: too many blank lines (should be 2)
Hannes Payer (out of office)
2016/08/05 10:21:05
Done.
|
| + |
| + |
| +class FacebookDesktopStory(_MediaBrowsingStory): |
| + NAME = 'browse:media:facebookphotos' |
|
petrcermak
2016/08/04 13:32:42
ditto (facebook_photos)
Hannes Payer (out of office)
2016/08/05 10:21:05
Done.
|
| + URL = ( |
| + 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/10153911739606676/?type=3&theater') |
| + ITEM_SELECTOR = '.snowliftPager.next' |
| + IS_SINGLE_PAGE_APP = True |
| + # Recording currently does not work. The page gets stuck in the |
| + # theater viewer. |
| + SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS |
| + |
| + def _Login(self, action_runner): |
| + facebook_login.LoginWithDesktopSite(action_runner, 'facebook3', |
| + self.credentials_path) |