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

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: [System Health] Create first System Health media user stories. Created 4 years, 2 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
« no previous file with comments | « tools/perf/page_sets/login_helpers/pandora_login.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
17 PLAY_DURATION = 20
18 PLAY_SELECTOR = NotImplemented
19 STOP_SELECTOR = NotImplemented
20 TIME_SELECTOR = NotImplemented
21
22 def RunPageInteractions(self, action_runner):
23 self._NavigateToMedia(action_runner)
24 # Play Media.
25 if self.PLAY_SELECTOR:
26 self._WaitForAndClickElement(action_runner, self.PLAY_SELECTOR)
27 self._WaitForPlayTime(action_runner)
28 # Stop media.
29 self._WaitForAndClickElement(action_runner, self.STOP_SELECTOR)
30
31 def _NavigateToMedia(self, action_runner):
32 raise NotImplementedError
33
34 def _WaitForAndClickElement(self, action_runner, element_function,
35 is_selector=True):
petrcermak 2016/09/22 17:10:48 As far as I can tell, you never pass is_selector=F
rnephew (Reviews Here) 2016/09/22 17:28:50 Done.
36 if is_selector:
37 element_function = 'document.querySelector("%s")' % element_function
38 action_runner.WaitForElement(element_function=element_function)
39 action_runner.ClickElement(element_function=element_function)
40
41 def _WaitForPlayTime(self, action_runner):
42 action_runner.Wait(self.PLAY_DURATION)
43 while self._GetTimeInSeconds(action_runner) < self.PLAY_DURATION:
44 action_runner.Wait(
45 self.PLAY_DURATION - self._GetTimeInSeconds(action_runner))
46
47 def _GetTimeInSeconds(self, action_runner):
48 time_funct = (
petrcermak 2016/09/22 17:10:48 supernit: "function" is typically abbreviated to "
rnephew (Reviews Here) 2016/09/22 17:28:50 Done.
49 'document.querySelector("%s").textContent' % self.TIME_SELECTOR)
50 minutes, seconds = action_runner.EvaluateJavaScript(time_funct).split(':')
51 return int(minutes * 60 + seconds)
52
53
54 ################################################################################
55 # Audio stories.
56 ################################################################################
57
58
59 class GooglePlayMusicDesktopStory(_MediaStory):
60 NAME = 'play:media:google_play_music'
61 URL = 'https://music.google.com'
62
63 PLAY_SELECTOR = '.x-scope.paper-fab-0'
64 STOP_SELECTOR = '.style-scope.sj-play-button'
65 TIME_SELECTOR = '#time-container-current'
66 SEARCH_SELECTOR = '.title.fade-out.tooltip'
67 NAVIGATE_SELECTOR = '.description.tooltip.fade-out'
68
69 def _Login(self, action_runner):
70 google_login.LoginGoogleAccount(action_runner, 'googletest',
71 self.credentials_path)
72
73 def _NavigateToMedia(self, action_runner):
74 # Clicks on Today's top hits.
75 action_runner.Wait(1) # Add 1 second wait to make the browsing realistic.
petrcermak 2016/09/22 17:10:48 nit: there should be 2 spaces before "#" (see http
rnephew (Reviews Here) 2016/09/22 17:28:50 Done.
76 self._WaitForAndClickElement(action_runner, self.SEARCH_SELECTOR)
77 # Clicks on playlist.
78 action_runner.Wait(1) # Add 1 second wait to make the browsing realistic.
79 self._WaitForAndClickElement(action_runner, self.NAVIGATE_SELECTOR)
80
81
82 class SoundCloudDesktopStory(_MediaStory):
83 NAME = 'play:media:soundcloud'
84 URL = 'https://soundcloud.com'
85
86 PLAY_SELECTOR = '.sc-button-play.playButton.sc-button.sc-button-xlarge'
87 STOP_SELECTOR = '.playControl.playControls__icon.sc-ir.playing'
88 TIME_SELECTOR = '.playbackTimeline__timePassed>span[aria-hidden=true]'
89 SEARCH_SELECTOR = '.headerSearch'
90 SEARCH_QUERY = 'SSmooth Jazz' # First S for some reason gets ommited.
91
92 def _NavigateToMedia(self, action_runner):
93 self._WaitForAndClickElement(action_runner, self.SEARCH_SELECTOR)
94 action_runner.Wait(1) # Add 1 second wait to make the browsing realistic.
95 action_runner.EnterText(self.SEARCH_QUERY)
96 action_runner.PressKey('Return')
97
98
99 class PandoraDesktopStory(_MediaStory):
100 NAME = 'play:media:pandora'
101 URL = 'https://pandora.com'
102
103 PLAY_SELECTOR = None
104 STOP_SELECTOR = '.pauseButton'
105 TIME_SELECTOR = '.elapsedTime'
106 SEARCH_SELECTOR = '.searchInput'
107
108 def _Login(self, action_runner):
109 pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path)
110
111 def _NavigateToMedia(self, action_runner):
112 pass # Audio autoplays on Pandora, no need to search.
OLDNEW
« no previous file with comments | « tools/perf/page_sets/login_helpers/pandora_login.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698