Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/perf/page_sets/system_health/media_stories.py

Issue 2334233002: [System Health] Create first System Health media user stories. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from page_sets.system_health import platforms
6 from page_sets.system_health import system_health_story
7
8 from page_sets.login_helpers import google_login
9
10
11 class _MediaStory(system_health_story.SystemHealthStory):
12 """Abstract base class for single-page System Health user stories."""
13 ABSTRACT_STORY = True
14 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.
15 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
16 PLAY_IDENTIFIER = NotImplemented
17 PLAY_DURATION = 10
18 STOP_IDENTIFIER = NotImplemented
19
20 def RunPageInteractions(self, action_runner):
21 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.
22 self.SEARCH_QUERY)
23 self._PlayMedia(action_runner, self.PLAY_IDENTIFIER)
24 action_runner.Wait(self.PLAY_DURATION)
25 self._StopMedia(action_runner, self.STOP_IDENTIFIER)
26
27 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.
28 pass
29
30 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.
31 action_runner.WaitForElement(element_function=element_function)
32 action_runner.ClickElement(element_function=element_function)
33
34 def _StopMedia(self, action_runner, element_function):
35 action_runner.WaitForElement(element_function=element_function)
36 action_runner.ClickElement(element_function=element_function)
37
38
39 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.
40 ABSTRACT_STORY = True
41 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
42
43
44 ################################################################################
45 # 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.
46 ################################################################################
47
48
49 class GooglePlayMusicDesktopStory(_MediaDesktopStory):
50 NAME = 'media:audio:google_play_music'
51 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.
52
53 SEARCH_IDENTIFIER = (
54 '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.
55 PLAY_IDENTIFIER = (
56 'document.getElementsByClassName("x-scope paper-fab-0")[0]')
57 STOP_IDENTIFIER = (
58 'document.getElementsByClassName("style-scope sj-play-button")[0]')
59
60 def _Login(self, action_runner):
61 google_login.LoginGoogleAccount(action_runner, 'googletest',
62 self.credentials_path)
63
64 def _SearchMedia(self, action_runner, element_function, _):
65 # Clicks on Today's top hits. (SEARCH_IDENTIFIER)
66 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.
67 action_runner.ClickElement(element_function=element_function)
68 # Clicks on playlist. (navigate_element)
69 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.
70 'fade-out")[0]')
71 action_runner.WaitForElement(element_function=navigate_element)
72 action_runner.ClickElement(element_function=navigate_element)
73
74
75 class SoundCloudDesktopStory(_MediaDesktopStory):
76 NAME = 'media:audio:soundcloud'
77 URL = 'https://soundcloud.com'
78
79 SEARCH_IDENTIFIER = 'document.getElementsByClassName("headerSearch")[0]'
80 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
81 PLAY_IDENTIFIER = ('document.getElementsByClassName("sc-button-play'
82 ' playButton sc-button sc-button-xlarge")[0]')
83 STOP_IDENTIFIER = ('document.getElementsByClassName("playControl '
84 'playControls__icon sc-ir playing")[0]')
85
86 def _SearchMedia(self, action_runner, element_function, query):
87 action_runner.WaitForElement(element_function=element_function)
88 action_runner.ClickElement(element_function=element_function)
89 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
90 action_runner.EnterText(query)
91 action_runner.PressKey('Return')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698