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..300dc67bac194f887d44703ba015d51e5ecc8f16 |
| --- /dev/null |
| +++ b/tools/perf/page_sets/system_health/media_stories.py |
| @@ -0,0 +1,91 @@ |
| +# 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 |
| + |
| +from page_sets.login_helpers import google_login |
| + |
| + |
| +class _MediaStory(system_health_story.SystemHealthStory): |
| + """Abstract base class for single-page System Health user stories.""" |
| + ABSTRACT_STORY = True |
| + SEARCH_IDENTIFIER = NotImplemented |
|
petrcermak
2016/09/13 16:49:03
nit: please group the IDENTIFIER fields together
rnephew (Reviews Here)
2016/09/13 18:52:41
Done.
|
| + SEARCH_QUERY = NotImplemented |
|
petrcermak
2016/09/13 16:49:03
This is actually used only by one subclass. I sugg
rnephew (Reviews Here)
2016/09/13 18:52:41
There will eventually be a MediaMobileStory as wel
|
| + PLAY_IDENTIFIER = NotImplemented |
| + PLAY_DURATION = 10 |
| + STOP_IDENTIFIER = NotImplemented |
| + |
| + def RunPageInteractions(self, action_runner): |
| + self._SearchMedia(action_runner, self.SEARCH_IDENTIFIER, |
|
petrcermak
2016/09/13 16:49:03
Can you please add a _SearchMedia method that thro
rnephew (Reviews Here)
2016/09/13 18:52:41
Done.
|
| + self.SEARCH_QUERY) |
| + self._PlayMedia(action_runner, self.PLAY_IDENTIFIER) |
| + action_runner.Wait(self.PLAY_DURATION) |
| + self._StopMedia(action_runner, self.STOP_IDENTIFIER) |
| + |
| + def _Login(self, action_runner): |
|
petrcermak
2016/09/13 16:49:03
no need for this method (it's empty by default)
rnephew (Reviews Here)
2016/09/13 18:52:40
Done.
|
| + pass |
| + |
| + def _PlayMedia(self, action_runner, element_function): |
|
petrcermak
2016/09/13 16:49:03
Both _PlayMedia and _StopMedia do exactly the same
rnephew (Reviews Here)
2016/09/13 18:52:40
Done.
|
| + action_runner.WaitForElement(element_function=element_function) |
| + action_runner.ClickElement(element_function=element_function) |
| + |
| + def _StopMedia(self, action_runner, element_function): |
| + action_runner.WaitForElement(element_function=element_function) |
| + action_runner.ClickElement(element_function=element_function) |
| + |
| + |
| +class _MediaDesktopStory(_MediaStory): |
|
petrcermak
2016/09/13 16:49:03
This seems to add an unnecessary level of indirect
rnephew (Reviews Here)
2016/09/13 18:52:40
This is setting up for when I add MediaMobileStory
petrcermak
2016/09/14 16:42:56
This is already the case in other SH stories files
rnephew (Reviews Here)
2016/09/20 22:19:30
Woops. Missed this one. Done.
|
| + ABSTRACT_STORY = True |
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| + |
| + |
| +################################################################################ |
| +# Audio Stories |
|
petrcermak
2016/09/13 16:49:03
nit: lowercase "s" in "stories" and add a period a
rnephew (Reviews Here)
2016/09/13 18:52:41
Done.
|
| +################################################################################ |
| + |
| + |
| +class GooglePlayMusicDesktopStory(_MediaDesktopStory): |
| + NAME = 'media:audio:google_play_music' |
| + URL = 'https:/music.google.com' |
|
petrcermak
2016/09/13 16:49:03
you're missing a slash in the url
rnephew (Reviews Here)
2016/09/13 18:52:41
Done.
|
| + |
| + SEARCH_IDENTIFIER = ( |
| + 'document.getElementsByClassName("title fade-out tooltip ")[0]') |
|
petrcermak
2016/09/13 16:49:03
remove unnecessary space from the end of the strin
petrcermak
2016/09/13 16:49:03
the following might be simpler: 'document.querySel
rnephew (Reviews Here)
2016/09/13 18:52:40
Done.
|
| + PLAY_IDENTIFIER = ( |
| + 'document.getElementsByClassName("x-scope paper-fab-0")[0]') |
| + STOP_IDENTIFIER = ( |
| + 'document.getElementsByClassName("style-scope sj-play-button")[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) |
| + action_runner.WaitForElement(element_function=element_function) |
|
petrcermak
2016/09/13 16:49:03
you can reuse the WaitForAndClickElement I suggest
rnephew (Reviews Here)
2016/09/13 18:52:41
Done.
|
| + action_runner.ClickElement(element_function=element_function) |
| + # Clicks on playlist. (navigate_element) |
| + navigate_element = ('document.getElementsByClassName("description tooltip ' |
|
petrcermak
2016/09/13 16:49:03
this can be a class constant
rnephew (Reviews Here)
2016/09/13 18:52:41
Done.
|
| + 'fade-out")[0]') |
| + action_runner.WaitForElement(element_function=navigate_element) |
| + action_runner.ClickElement(element_function=navigate_element) |
| + |
| + |
| +class SoundCloudDesktopStory(_MediaDesktopStory): |
| + NAME = 'media:audio:soundcloud' |
| + URL = 'https://soundcloud.com' |
| + |
| + SEARCH_IDENTIFIER = 'document.getElementsByClassName("headerSearch")[0]' |
| + SEARCH_QUERY = 'SSmooth Jazz' # First S for some reason gets ommited. |
|
petrcermak
2016/09/13 16:49:03
Even if we wait longer?
rnephew (Reviews Here)
2016/09/13 18:52:40
Yeah. I upped the wait time to 2 seconds and it st
|
| + 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): |
| + action_runner.WaitForElement(element_function=element_function) |
| + action_runner.ClickElement(element_function=element_function) |
| + action_runner.Wait(1) # Without wait it clicks too soon. |
|
petrcermak
2016/09/13 16:49:03
Don't you mean "starts entering text" rather than
rnephew (Reviews Here)
2016/09/13 18:52:41
Yes, clicking is not the right word there.
I'll w
|
| + action_runner.EnterText(query) |
| + action_runner.PressKey('Return') |