| Index: tools/perf/page_sets/system_health/media_stories.py
|
| diff --git a/tools/perf/page_sets/system_health/media_stories.py b/tools/perf/page_sets/system_health/media_stories.py
|
| index ad079e8d4b515282fcec217d1b9a326dc0bcc3a8..5e59710432052ebed84811f13d7f8f966493b572 100644
|
| --- a/tools/perf/page_sets/system_health/media_stories.py
|
| +++ b/tools/perf/page_sets/system_health/media_stories.py
|
| @@ -3,16 +3,24 @@
|
| # found in the LICENSE file.
|
|
|
| from page_sets.system_health import platforms
|
| +from page_sets.system_health import story_tags
|
| from page_sets.system_health import system_health_story
|
| +from page_sets.system_health import browsing_stories
|
|
|
| from page_sets.login_helpers import google_login
|
| from page_sets.login_helpers import pandora_login
|
| +from page_sets.login_helpers import pinterest_login
|
|
|
| from telemetry import benchmark
|
| from telemetry import decorators
|
|
|
|
|
| -class _MediaStory(system_health_story.SystemHealthStory):
|
| +################################################################################
|
| +# Audio and Video stories.
|
| +################################################################################
|
| +
|
| +
|
| +class _PlayMediaStory(system_health_story.SystemHealthStory):
|
| """Abstract base class for media System Health user stories."""
|
|
|
| ABSTRACT_STORY = True
|
| @@ -51,13 +59,9 @@ class _MediaStory(system_health_story.SystemHealthStory):
|
| return int(minutes * 60 + seconds)
|
|
|
|
|
| -################################################################################
|
| -# Audio stories.
|
| -################################################################################
|
| -
|
| -
|
| +# TODO(ssid): Rename the play stories to browse stories crbug.com/708300.
|
| @benchmark.Disabled('all') # crbug.com/649392
|
| -class GooglePlayMusicDesktopStory(_MediaStory):
|
| +class GooglePlayMusicDesktopStory(_PlayMediaStory):
|
| NAME = 'play:media:google_play_music'
|
| URL = 'https://music.google.com'
|
|
|
| @@ -82,7 +86,7 @@ class GooglePlayMusicDesktopStory(_MediaStory):
|
|
|
|
|
| @benchmark.Disabled('win') # crbug.com/649392
|
| -class SoundCloudDesktopStory(_MediaStory):
|
| +class SoundCloudDesktopStory(_PlayMediaStory):
|
| NAME = 'play:media:soundcloud'
|
| URL = 'https://soundcloud.com'
|
|
|
| @@ -100,7 +104,7 @@ class SoundCloudDesktopStory(_MediaStory):
|
|
|
|
|
| @decorators.Disabled('all') # crbug.com/649392
|
| -class PandoraDesktopStory(_MediaStory):
|
| +class PandoraDesktopStory(_PlayMediaStory):
|
| NAME = 'play:media:pandora'
|
| URL = 'https://pandora.com'
|
|
|
| @@ -114,3 +118,207 @@ class PandoraDesktopStory(_MediaStory):
|
|
|
| def _NavigateToMedia(self, action_runner):
|
| pass # Audio autoplays on Pandora, no need to search.
|
| +
|
| +
|
| +class YoutubeMobileStory(_PlayMediaStory):
|
| + NAME = 'play:media:youtube'
|
| + URL = 'https://m.youtube.in/watch?v=OnhXkCPMeMc'
|
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
|
| + TAGS = [story_tags.EMERGING_MARKET]
|
| +
|
| + PLAYER_FUNCTION = 'document.getElementById("player")'
|
| + STOP_FUNCTION = 'document.getElementsByTagName("video")[0].pause()'
|
| + TIME_FUNCTION = 'document.getElementsByTagName("video")[0].currentTime'
|
| +
|
| + def RunPageInteractions(self, action_runner):
|
| + app_ui = action_runner.tab.browser.app_ui
|
| + action_runner.WaitForElement(element_function=self.PLAYER_FUNCTION)
|
| +
|
| + # Simulate user click in system ui since youtube play can be initialied only
|
| + # by user gesture.
|
| + renderer_view_id = 'compositor_view_holder'
|
| + app_ui.WaitForUiNode(resource_id=renderer_view_id)
|
| + renderer_view = app_ui.GetUiNode(resource_id=renderer_view_id)
|
| + # Click on the top half of the renderer view to start video.
|
| + shifted_center = 0.5 * (
|
| + renderer_view.bounds.center + renderer_view.bounds.top_left)
|
| + renderer_view.Tap(point=shifted_center)
|
| +
|
| + self._WaitForPlayTime(action_runner)
|
| + action_runner.EvaluateJavaScript(self.STOP_FUNCTION)
|
| + self._Measure(action_runner)
|
| +
|
| +
|
| + def _GetTimeInSeconds(self, action_runner):
|
| + return int(action_runner.EvaluateJavaScript(self.TIME_FUNCTION))
|
| +
|
| + def _NavigateToMedia(self, action_runner):
|
| + pass # Users usually open youtube links directly, skip searching.
|
| +
|
| +
|
| +################################################################################
|
| +# Photos browsing stories.
|
| +################################################################################
|
| +
|
| +
|
| +class _PhotoBrowsingStory(browsing_stories.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
|
| + INCREMENT_INDEX_AFTER_EACH_ITEM = False
|
| +
|
| + def _DidLoadDocument(self, action_runner):
|
| + index = self.ITEM_SELECTOR_INDEX
|
| + for _ in xrange(self.ITEMS_TO_VISIT):
|
| + self._NavigateToItem(action_runner, index)
|
| + self._ViewMediaItem(action_runner, index)
|
| + if self.INCREMENT_INDEX_AFTER_EACH_ITEM:
|
| + index += 1
|
| +
|
| +
|
| + def _ViewMediaItem(self, action_runner, index):
|
| + del index # Unused.
|
| + action_runner.tab.WaitForDocumentReadyStateToBeComplete()
|
| + action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS)
|
| +
|
| +
|
| +class ImgurMobileStory(_PhotoBrowsingStory):
|
| + NAME = 'browse:media:imgur'
|
| + URL = 'http://imgur.com/gallery/5UlBN'
|
| + ITEM_SELECTOR = '.Navbar-customAction'
|
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
|
| + IS_SINGLE_PAGE_APP = True
|
| + TAGS = [story_tags.EMERGING_MARKET]
|
| +
|
| +
|
| +# crbug.com/704197 for win and mac
|
| +@decorators.Disabled('win', 'mac')
|
| +class ImgurDesktopStory(_PhotoBrowsingStory):
|
| + NAME = 'browse:media:imgur'
|
| + URL = 'http://imgur.com/gallery/5UlBN'
|
| + ITEM_SELECTOR = '.navNext'
|
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
|
| + IS_SINGLE_PAGE_APP = True
|
| +
|
| +
|
| +# TODO(ssid): Remove this story since we have play youtube story
|
| +# crbug.com/708300.
|
| +class YouTubeMobileStory(_PhotoBrowsingStory):
|
| + NAME = 'browse:media:youtube'
|
| + URL = 'https://m.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false'
|
| + ITEM_SELECTOR = '._mhgb > a'
|
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
|
| + IS_SINGLE_PAGE_APP = True
|
| + ITEM_SELECTOR_INDEX = 3
|
| + TAGS = [story_tags.JAVASCRIPT_HEAVY]
|
| +
|
| +
|
| +class YouTubeDesktopStory(_PhotoBrowsingStory):
|
| + 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
|
| + PLATFORM_SPECIFIC = True
|
| + TAGS = [story_tags.JAVASCRIPT_HEAVY]
|
| +
|
| +
|
| +class FacebookPhotosMobileStory(_PhotoBrowsingStory):
|
| + NAME = 'browse:media:facebook_photos'
|
| + URL = (
|
| + 'https://m.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/10153911739606676/?type=3&source=54&ref=page_internal')
|
| + ITEM_SELECTOR = '._57-r.touchable'
|
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
|
| + IS_SINGLE_PAGE_APP = True
|
| + ITEM_SELECTOR_INDEX = 0
|
| + TAGS = [story_tags.EMERGING_MARKET]
|
| +
|
| +
|
| +class FacebookPhotosDesktopStory(_PhotoBrowsingStory):
|
| + 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
|
| +
|
| +
|
| +class TumblrDesktopStory(_PhotoBrowsingStory):
|
| + NAME = 'browse:media:tumblr'
|
| + URL = 'https://tumblr.com/search/gifs'
|
| + ITEM_SELECTOR = '.photo'
|
| + IS_SINGLE_PAGE_APP = True
|
| + ITEMS_TO_VISIT = 8
|
| + INCREMENT_INDEX_AFTER_EACH_ITEM = True
|
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
|
| +
|
| + def _ViewMediaItem(self, action_runner, index):
|
| + super(TumblrDesktopStory, self)._ViewMediaItem(action_runner, index)
|
| + action_runner.MouseClick(selector='#tumblr_lightbox_center_image')
|
| + action_runner.Wait(1) # To make browsing more realistic.
|
| +
|
| +
|
| +class PinterestDesktopStory(_PhotoBrowsingStory):
|
| + NAME = 'browse:media:pinterest'
|
| + URL = 'https://pinterest.com'
|
| + ITEM_SELECTOR = '.pinImageDim'
|
| + IS_SINGLE_PAGE_APP = True
|
| + ITEMS_TO_VISIT = 8
|
| + INCREMENT_INDEX_AFTER_EACH_ITEM = True
|
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
|
| +
|
| + def _Login(self, action_runner):
|
| + pinterest_login.LoginDesktopAccount(action_runner, 'googletest',
|
| + self.credentials_path)
|
| +
|
| + def _ViewMediaItem(self, action_runner, index):
|
| + super(PinterestDesktopStory, self)._ViewMediaItem(action_runner, index)
|
| + # To imitate real user interaction, we do not want to pin every post.
|
| + # We will only pin every other post.
|
| + if index % 2 == 0:
|
| + # Pin the selection.
|
| + save_function = ('document.querySelector('
|
| + '".Button.Module.ShowModalButton.btn.hasIcon.hasText.'
|
| + 'isBrioFlat.medium.primary.primaryOnHover.repin.'
|
| + 'pinActionBarButton.isBrioFlat.rounded")')
|
| + action_runner.ClickElement(element_function=save_function)
|
| + action_runner.Wait(1) # Wait to make navigation realistic.
|
| + # Select which board to pin to.
|
| + inner_save_function = 'document.querySelector(".nameAndIcons")'
|
| + action_runner.WaitForElement(element_function=inner_save_function)
|
| + action_runner.ClickElement(element_function=inner_save_function)
|
| + action_runner.Wait(1) # Wait to make navigation realistic.
|
| +
|
| + # Close selection.
|
| + x_element_function = ('document.querySelector('
|
| + '".Button.borderless.close.visible")')
|
| + action_runner.ClickElement(element_function=x_element_function)
|
| + action_runner.Wait(1) # Wait to make navigation realistic.
|
| +
|
| +
|
| +# Instagram requires navigate back to view next photo So, use
|
| +# ArticleBrowsingStory.
|
| +class InstagramMobileStory(browsing_stories.ArticleBrowsingStory):
|
| + NAME = 'browse:media:instagram'
|
| + URL = 'https://www.instagram.com/badgalriri/'
|
| + ITEM_SELECTOR = '[class=\\"_8mlbc _vbtk2 _t5r8b\\"]'
|
| + ITEMS_TO_VISIT = 8
|
| + IS_SINGLE_PAGE_APP = True
|
| +
|
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
|
| + TAGS = [story_tags.EMERGING_MARKET]
|
|
|