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

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: Add Pandora 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
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.
8 from page_sets.login_helpers import google_login
9 from page_sets.login_helpers import pandora_login
10
11 class _MediaStory(system_health_story.SystemHealthStory):
12 """Abstract base class for media System Health user stories."""
13
14 ABSTRACT_STORY = True
15 SEARCH_IDENTIFIER = NotImplemented
16 PLAY_IDENTIFIER = NotImplemented
17 STOP_IDENTIFIER = NotImplemented
18 SEARCH_QUERY = NotImplemented
19 PLAY_DURATION = 10
20
21
22 def RunPageInteractions(self, action_runner):
23 self._SearchMedia(action_runner, self.SEARCH_IDENTIFIER,
24 self.SEARCH_QUERY)
25 # Start media.
26 self._WaitForAndClickElement(action_runner, self.PLAY_IDENTIFIER)
27 action_runner.Wait(self.PLAY_DURATION)
28 # Stop media.
29 self._WaitForAndClickElement(action_runner, self.STOP_IDENTIFIER)
30
31 def _SearchMedia(self, action_runner, element_function, query):
32 raise NotImplementedError
33
34 def _WaitForAndClickElement(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):
40 ABSTRACT_STORY = True
41 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
42
43 def _SearchMedia(self, action_runner, element_function, query):
44 raise NotImplementedError
45
46
47 ################################################################################
48 # Audio stories
49 ################################################################################
50
51
52 class GooglePlayMusicDesktopStory(_MediaDesktopStory):
53 NAME = 'play:media:google_play_music'
54 URL = 'https://music.google.com'
55
56 SEARCH_IDENTIFIER = 'document.querySelector(".title.fade-out.tooltip")'
57 PLAY_IDENTIFIER = (
58 'document.getElementsByClassName("x-scope paper-fab-0")[0]')
59 STOP_IDENTIFIER = (
60 'document.getElementsByClassName("style-scope sj-play-button")[0]')
61 NAVIGATE_IDENTIFIER = (
62 'document.getElementsByClassName("description tooltip fade-out")[0]')
63
64 def _Login(self, action_runner):
65 google_login.LoginGoogleAccount(action_runner, 'googletest',
66 self.credentials_path)
67
68 def _SearchMedia(self, action_runner, element_function, _):
69 # Clicks on Today's top hits. (SEARCH_IDENTIFIER)
70 self._WaitForAndClickElement(action_runner, element_function)
71 # Clicks on playlist. (NAVIGATE_IDENTIFIER)
72 self._WaitForAndClickElement(action_runner, self.NAVIGATE_IDENTIFIER)
73
74
75 class SoundCloudDesktopStory(_MediaDesktopStory):
76 NAME = 'play:media: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.
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 self._WaitForAndClickElement(action_runner, element_function)
88 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.
89 action_runner.EnterText(query)
90 action_runner.PressKey('Return')
91
92
93 class PandoraDesktopStory(_MediaDesktopStory):
94 NAME='play:media:pandora'
95 URL = 'https://pandora.com'
96
97 SEARCH_IDENTIFIER = 'document.getElementsByClassName("searchInput")[0]'
98 SEARCH_QUERY = None
99 PLAY_IDENTIFIER = None
100 STOP_IDENTIFIER = 'document.getElementsByClassName("pauseButton")[0]'
101
102 def _Login(self, action_runner):
103 pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path)
104
105 def _SearchMedia(self, action_runner, element_function, query):
106 pass # Audio autoplays on Pandora, no need to search.
107
108 def RunPageInteractions(self, action_runner):
109 self._SearchMedia(action_runner, self.SEARCH_IDENTIFIER,
110 self.SEARCH_QUERY)
111 action_runner.Wait(self.PLAY_DURATION)
112 self._WaitForAndClickElement(action_runner, self.STOP_IDENTIFIER)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698