Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..762f9bf2ccdc43a74bfaa3c6bff9786aa73da037 |
| --- /dev/null |
| +++ b/tools/perf/page_sets/system_health/media_stories.py |
| @@ -0,0 +1,112 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +from page_sets.system_health import platforms |
| +from page_sets.system_health import system_health_story |
| + |
|
charliea (OOO until 10-5)
2016/09/13 19:38:40
nit: extra blank line?
rnephew (Reviews Here)
2016/09/13 20:17:17
Done.
|
| +from page_sets.login_helpers import google_login |
| +from page_sets.login_helpers import pandora_login |
| + |
| +class _MediaStory(system_health_story.SystemHealthStory): |
| + """Abstract base class for media System Health user stories.""" |
| + |
| + ABSTRACT_STORY = True |
| + SEARCH_IDENTIFIER = NotImplemented |
| + PLAY_IDENTIFIER = NotImplemented |
| + STOP_IDENTIFIER = NotImplemented |
| + SEARCH_QUERY = NotImplemented |
| + PLAY_DURATION = 10 |
| + |
| + |
| + def RunPageInteractions(self, action_runner): |
| + self._SearchMedia(action_runner, self.SEARCH_IDENTIFIER, |
| + self.SEARCH_QUERY) |
| + # Start media. |
| + self._WaitForAndClickElement(action_runner, self.PLAY_IDENTIFIER) |
| + action_runner.Wait(self.PLAY_DURATION) |
| + # Stop media. |
| + self._WaitForAndClickElement(action_runner, self.STOP_IDENTIFIER) |
| + |
| + def _SearchMedia(self, action_runner, element_function, query): |
| + raise NotImplementedError |
| + |
| + def _WaitForAndClickElement(self, action_runner, element_function): |
| + action_runner.WaitForElement(element_function=element_function) |
| + action_runner.ClickElement(element_function=element_function) |
| + |
| + |
| +class _MediaDesktopStory(_MediaStory): |
| + ABSTRACT_STORY = True |
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| + |
| + def _SearchMedia(self, action_runner, element_function, query): |
| + raise NotImplementedError |
| + |
| + |
| +################################################################################ |
| +# Audio stories |
| +################################################################################ |
| + |
| + |
| +class GooglePlayMusicDesktopStory(_MediaDesktopStory): |
| + NAME = 'play:media:google_play_music' |
| + URL = 'https://music.google.com' |
| + |
| + SEARCH_IDENTIFIER = 'document.querySelector(".title.fade-out.tooltip")' |
| + PLAY_IDENTIFIER = ( |
| + 'document.getElementsByClassName("x-scope paper-fab-0")[0]') |
| + STOP_IDENTIFIER = ( |
| + 'document.getElementsByClassName("style-scope sj-play-button")[0]') |
| + NAVIGATE_IDENTIFIER = ( |
| + 'document.getElementsByClassName("description tooltip fade-out")[0]') |
| + |
| + def _Login(self, action_runner): |
| + google_login.LoginGoogleAccount(action_runner, 'googletest', |
| + self.credentials_path) |
| + |
| + def _SearchMedia(self, action_runner, element_function, _): |
| + # Clicks on Today's top hits. (SEARCH_IDENTIFIER) |
| + self._WaitForAndClickElement(action_runner, element_function) |
| + # Clicks on playlist. (NAVIGATE_IDENTIFIER) |
| + self._WaitForAndClickElement(action_runner, self.NAVIGATE_IDENTIFIER) |
| + |
| + |
| +class SoundCloudDesktopStory(_MediaDesktopStory): |
| + NAME = 'play:media:soundcloud' |
| + URL = 'https://soundcloud.com' |
| + |
| + SEARCH_IDENTIFIER = 'document.getElementsByClassName("headerSearch")[0]' |
| + SEARCH_QUERY = 'SSmooth Jazz' # First S for some reason gets ommited. |
| + PLAY_IDENTIFIER = ('document.getElementsByClassName("sc-button-play' |
| + ' playButton sc-button sc-button-xlarge")[0]') |
| + STOP_IDENTIFIER = ('document.getElementsByClassName("playControl ' |
| + 'playControls__icon sc-ir playing")[0]') |
| + |
| + def _SearchMedia(self, action_runner, element_function, query): |
| + self._WaitForAndClickElement(action_runner, element_function) |
| + action_runner.Wait(1) # Without wait it enters text too soon. |
|
charliea (OOO until 10-5)
2016/09/13 19:38:40
what is "it" in this context?
nednguyen
2016/09/13 19:41:17
Yeah. Probably just document that "add 1 seconds w
rnephew (Reviews Here)
2016/09/13 20:17:17
Done.
|
| + action_runner.EnterText(query) |
| + action_runner.PressKey('Return') |
| + |
| + |
| +class PandoraDesktopStory(_MediaDesktopStory): |
| + NAME='play:media:pandora' |
| + URL = 'https://pandora.com' |
| + |
| + SEARCH_IDENTIFIER = 'document.getElementsByClassName("searchInput")[0]' |
| + SEARCH_QUERY = None |
| + PLAY_IDENTIFIER = None |
| + STOP_IDENTIFIER = 'document.getElementsByClassName("pauseButton")[0]' |
| + |
| + def _Login(self, action_runner): |
| + pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path) |
| + |
| + def _SearchMedia(self, action_runner, element_function, query): |
| + pass # Audio autoplays on Pandora, no need to search. |
| + |
| + def RunPageInteractions(self, action_runner): |
| + self._SearchMedia(action_runner, self.SEARCH_IDENTIFIER, |
| + self.SEARCH_QUERY) |
| + action_runner.Wait(self.PLAY_DURATION) |
| + self._WaitForAndClickElement(action_runner, self.STOP_IDENTIFIER) |