OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from page_sets.system_health import platforms | 5 from page_sets.system_health import platforms |
6 from page_sets.system_health import system_health_story | 6 from page_sets.system_health import system_health_story |
7 | 7 |
8 from page_sets.login_helpers import google_login | 8 from page_sets.login_helpers import google_login |
9 from page_sets.login_helpers import pandora_login | 9 from page_sets.login_helpers import pandora_login |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 PLAY_SELECTOR = None | 107 PLAY_SELECTOR = None |
108 STOP_SELECTOR = '.pauseButton' | 108 STOP_SELECTOR = '.pauseButton' |
109 TIME_SELECTOR = '.elapsedTime' | 109 TIME_SELECTOR = '.elapsedTime' |
110 SEARCH_SELECTOR = '.searchInput' | 110 SEARCH_SELECTOR = '.searchInput' |
111 | 111 |
112 def _Login(self, action_runner): | 112 def _Login(self, action_runner): |
113 pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path) | 113 pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path) |
114 | 114 |
115 def _NavigateToMedia(self, action_runner): | 115 def _NavigateToMedia(self, action_runner): |
116 pass # Audio autoplays on Pandora, no need to search. | 116 pass # Audio autoplays on Pandora, no need to search. |
117 | |
118 | |
119 class YoutubeMobileStory(_MediaStory): | |
120 NAME = 'play:media:youtube' | |
121 URL = 'https://m.youtube.in/watch?v=OnhXkCPMeMc' | |
122 | |
123 PLAYER_FUNCTION = 'document.getElementById("player")' | |
124 STOP_FUNCTION = 'document.getElementsByTagName("video")[0].pause()' | |
125 TIME_FUNCTION = 'document.getElementsByTagName("video")[0].currentTime' | |
126 | |
127 def RunPageInteractions(self, action_runner): | |
128 platform = action_runner.tab.browser.platform | |
129 package = action_runner.tab.browser.GetBrowserInfo().package_name | |
130 action_runner.WaitForElement(element_function=self.PLAYER_FUNCTION) | |
131 | |
132 # Simulate user click in system ui since youtube play can be initialied only | |
133 # by user gesture. | |
134 renderer_view = package+':id/compositor_view_holder' | |
135 platform.system_ui.WaitForUiNode(resource_id=renderer_view) | |
136 content_view = platform.system_ui.GetUiNode(resource_id=renderer_view) | |
137 # Click on the top half of the renderer view to start video. | |
138 shifted_center = 0.5 * ( | |
139 content_view.bounds.center + content_view.bounds.top_left) | |
140 content_view.Tap(point=shifted_center) | |
141 | |
142 self._WaitForPlayTime(action_runner) | |
143 action_runner.EvaluateJavaScript(self.STOP_FUNCTION) | |
144 | |
145 def _GetTimeInSeconds(self, action_runner): | |
146 return int(action_runner.EvaluateJavaScript(self.TIME_FUNCTION)) | |
147 | |
148 def _NavigateToMedia(self, action_runner): | |
149 pass # Audio autoplays on Pandora, no need to search. | |
perezju
2017/04/04 09:23:38
Pandora?
ssid
2017/04/04 20:59:49
Done.
| |
150 | |
151 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
OLD | NEW |