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..02f383121176eebce29041a80331f1b5d0fdf3b6 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): |
| + 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): |
| + NAME = 'browse:media:youtube' |
| + URL = 'https://m.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' |
|
petrcermak
2016/08/05 10:30:46
Could you please update the loading stories to use
petrcermak
2016/08/05 10:32:08
Please ignore this comment. I've just realized tha
Hannes Payer (out of office)
2016/08/05 11:13:07
Acknowledged.
|
| + ITEM_SELECTOR = '._mhgb > a' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + IS_SINGLE_PAGE_APP = True |
| + ITEM_SELECTOR_INDEX = 3 |
| + |
| + |
| +class YouTubeDesktopStory(_MediaBrowsingStory): |
| + 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 |
| + # A longer view time allows videos to load and play. |
| + ITEM_VIEW_TIME_IN_SECONDS = 5 |
| + ITEMS_TO_VISIT = 8 |
| + ITEM_SELECTOR_INDEX = 3 |
| + |
| + |
| +class FacebookMobileStory(_MediaBrowsingStory): |
| + NAME = 'browse:media:facebook_photos' |
|
petrcermak
2016/08/05 10:30:46
Could you please add facebook_photos loading stori
Hannes Payer (out of office)
2016/08/05 11:13:07
This is why I navigate to the regular page before.
|
| + URL = ( |
| + 'https://m.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/10153911739606676/?type=3&source=54&ref=page_internal') |
| + ITEM_SELECTOR = '._57-p > a' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + IS_SINGLE_PAGE_APP = True |
| + ITEM_SELECTOR_INDEX = 1 |
| + |
| + def _Login(self, action_runner): |
| + action_runner.Navigate('https://m.facebook.com/rihanna') |
|
petrcermak
2016/08/05 10:30:46
Why do you have this _Login hook at all? It just a
Hannes Payer (out of office)
2016/08/05 11:13:07
To make it comparable to the load story. With that
petrcermak
2016/08/08 13:52:16
That makes the mobile and desktop browsing stories
Hannes Payer (out of office)
2016/08/08 16:47:28
I unified the facebook login and reuse the story a
|
| + action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| + |
| + |
| +class FacebookDesktopStory(_MediaBrowsingStory): |
| + NAME = 'browse:media:facebook_photos' |
| + URL = ( |
| + 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/10153911739606676/?type=3&theater') |
| + ITEM_SELECTOR = '.snowliftPager.next' |
| + # Recording currently does not work. The page gets stuck in the |
| + # theater viewer. |
| + SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS |
| + IS_SINGLE_PAGE_APP = True |
| + |
| + def _Login(self, action_runner): |
| + facebook_login.LoginWithDesktopSite(action_runner, 'facebook3', |
| + self.credentials_path) |
|
petrcermak
2016/08/05 10:30:46
nit: this should be indented so that it's vertical
Hannes Payer (out of office)
2016/08/05 11:13:07
Done.
|