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..59e3a171fbac6786367f2681a3a5ad6716a7681f 100644 |
--- a/tools/perf/page_sets/system_health/media_stories.py |
+++ b/tools/perf/page_sets/system_health/media_stories.py |
@@ -3,6 +3,7 @@ |
# 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.login_helpers import google_login |
@@ -12,7 +13,7 @@ from telemetry import benchmark |
from telemetry import decorators |
-class _MediaStory(system_health_story.SystemHealthStory): |
+class _PlayMediaStory(system_health_story.SystemHealthStory): |
"""Abstract base class for media System Health user stories.""" |
ABSTRACT_STORY = True |
@@ -52,12 +53,12 @@ class _MediaStory(system_health_story.SystemHealthStory): |
################################################################################ |
-# Audio stories. |
+# Audio and video stories. |
################################################################################ |
@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 +83,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 +101,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 +115,41 @@ class PandoraDesktopStory(_MediaStory): |
def _NavigateToMedia(self, action_runner): |
pass # Audio autoplays on Pandora, no need to search. |
+ |
+ |
+class YoutubeMobileStory(_PlayMediaStory): |
+ NAME = 'browse: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) |
+ |
perezju
2017/04/11 09:43:35
nit: remove one blank line
ssid
2017/04/11 21:52:55
Done.
|
+ |
+ 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. |
+ |
+ |