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

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: charlie and neds reviews 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 from page_sets.login_helpers import pandora_login
10
11
12 class _MediaStory(system_health_story.SystemHealthStory):
13 """Abstract base class for media System Health user stories."""
14
15 ABSTRACT_STORY = True
16 SEARCH_IDENTIFIER = NotImplemented
17 PLAY_IDENTIFIER = NotImplemented
charliea (OOO until 10-5) 2016/09/14 23:55:03 I think "element" might be more accurate than "ide
rnephew (Reviews Here) 2016/09/20 21:09:54 Done.
18 STOP_IDENTIFIER = NotImplemented
19 SEARCH_QUERY = NotImplemented
petrcermak 2016/09/14 16:42:57 I don't think there's any value in having this abs
charliea (OOO until 10-5) 2016/09/14 23:55:03 +1
rnephew (Reviews Here) 2016/09/20 21:09:55 Done.
20 PLAY_DURATION = 10
nednguyen 2016/09/14 16:57:41 Can we change this to 20s?
rnephew (Reviews Here) 2016/09/20 21:09:54 Done.
21
22
23 def RunPageInteractions(self, action_runner):
24 self._SearchMedia(action_runner, self.SEARCH_IDENTIFIER,
25 self.SEARCH_QUERY)
26 # Start media.
27 self._WaitForAndClickElement(action_runner, self.PLAY_IDENTIFIER)
28 action_runner.Wait(self.PLAY_DURATION)
29 # Stop media.
30 self._WaitForAndClickElement(action_runner, self.STOP_IDENTIFIER)
31
32 def _SearchMedia(self, action_runner, element_function, query):
petrcermak 2016/09/14 16:42:57 What does "element_function" refer to? The input b
charliea (OOO until 10-5) 2016/09/14 23:55:03 I think _NavigateToMedia might be a more accurate
rnephew (Reviews Here) 2016/09/20 21:09:55 Done.
rnephew (Reviews Here) 2016/09/20 21:09:55 Done.
33 raise NotImplementedError
34
35 def _WaitForAndClickElement(self, action_runner, element_function):
36 action_runner.WaitForElement(element_function=element_function)
37 action_runner.ClickElement(element_function=element_function)
38
39
40 class _MediaDesktopStory(_MediaStory):
41 ABSTRACT_STORY = True
42 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
43
44 def _SearchMedia(self, action_runner, element_function, query):
petrcermak 2016/09/14 16:42:57 no need to re-define the method
rnephew (Reviews Here) 2016/09/20 21:09:54 Pylint disagrees. It complains that an abstract me
45 raise NotImplementedError
46
47
48 ################################################################################
49 # Audio stories
petrcermak 2016/09/14 16:42:57 nit: missing period (for consistency with other *_
rnephew (Reviews Here) 2016/09/20 21:09:54 Done.
50 ################################################################################
51
52
53 class GooglePlayMusicDesktopStory(_MediaDesktopStory):
54 NAME = 'play:media:google_play_music'
55 URL = 'https://music.google.com'
56
57 SEARCH_IDENTIFIER = 'document.querySelector(".title.fade-out.tooltip")'
58 PLAY_IDENTIFIER = (
59 'document.getElementsByClassName("x-scope paper-fab-0")[0]')
60 STOP_IDENTIFIER = (
61 'document.getElementsByClassName("style-scope sj-play-button")[0]')
62 NAVIGATE_IDENTIFIER = (
63 'document.getElementsByClassName("description tooltip fade-out")[0]')
64
65 def _Login(self, action_runner):
66 google_login.LoginGoogleAccount(action_runner, 'googletest',
67 self.credentials_path)
68
69 def _SearchMedia(self, action_runner, element_function, _):
70 # Clicks on Today's top hits. (SEARCH_IDENTIFIER)
petrcermak 2016/09/14 16:42:57 This is a proof that passing SEARCH_IDENTIFIER thr
rnephew (Reviews Here) 2016/09/20 21:09:54 Done.
71 self._WaitForAndClickElement(action_runner, element_function)
72 # Clicks on playlist. (NAVIGATE_IDENTIFIER)
petrcermak 2016/09/14 16:42:57 nit: no need for "(NAVIGATE_IDENTIFIER)" here. The
rnephew (Reviews Here) 2016/09/20 21:09:54 Done.
73 self._WaitForAndClickElement(action_runner, self.NAVIGATE_IDENTIFIER)
nednguyen 2016/09/14 17:02:03 The timing of google play is in "<span id="time-co
rnephew (Reviews Here) 2016/09/20 21:09:55 Done.
74
75
76 class SoundCloudDesktopStory(_MediaDesktopStory):
77 NAME = 'play:media:soundcloud'
78 URL = 'https://soundcloud.com'
79
80 SEARCH_IDENTIFIER = 'document.getElementsByClassName("headerSearch")[0]'
81 SEARCH_QUERY = 'SSmooth Jazz' # First S for some reason gets ommited.
82 PLAY_IDENTIFIER = ('document.getElementsByClassName("sc-button-play'
83 ' playButton sc-button sc-button-xlarge")[0]')
84 STOP_IDENTIFIER = ('document.getElementsByClassName("playControl '
85 'playControls__icon sc-ir playing")[0]')
86
87 def _SearchMedia(self, action_runner, element_function, query):
88 self._WaitForAndClickElement(action_runner, element_function)
89 action_runner.Wait(1) # Add 1 second wait to make the browsing realistic.
90 action_runner.EnterText(query)
91 action_runner.PressKey('Return')
92
93
94 class PandoraDesktopStory(_MediaDesktopStory):
petrcermak 2016/09/14 16:42:57 Note that at this point, this class could just sub
rnephew (Reviews Here) 2016/09/20 21:09:55 Done.
95 NAME='play:media:pandora'
96 URL = 'https://pandora.com'
97
98 SEARCH_IDENTIFIER = 'document.getElementsByClassName("searchInput")[0]'
99 SEARCH_QUERY = None
100 PLAY_IDENTIFIER = None
101 STOP_IDENTIFIER = 'document.getElementsByClassName("pauseButton")[0]'
102
103 def _Login(self, action_runner):
104 pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path)
105
106 def _SearchMedia(self, action_runner, element_function, query):
107 pass # Audio autoplays on Pandora, no need to search.
108
109 def RunPageInteractions(self, action_runner):
110 self._SearchMedia(action_runner, self.SEARCH_IDENTIFIER,
petrcermak 2016/09/14 16:42:57 Why do you do this? You're just calling an empty f
rnephew (Reviews Here) 2016/09/20 21:09:55 Acknowledged.
111 self.SEARCH_QUERY)
112 action_runner.Wait(self.PLAY_DURATION)
nednguyen 2016/09/14 17:02:03 The elapse time of the player is reflected through
rnephew (Reviews Here) 2016/09/20 21:09:54 Done, but one concern here is that, at least on GP
113 self._WaitForAndClickElement(action_runner, self.STOP_IDENTIFIER)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698