OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import re | 6 import re |
7 import time | 7 import time |
8 | 8 |
9 import pyauto_functional | 9 import pyauto_functional |
10 import pyauto | 10 import pyauto |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 ytplayer.pauseVideo(); | 114 ytplayer.pauseVideo(); |
115 window.domAutomationController.send(''); | 115 window.domAutomationController.send(''); |
116 """) | 116 """) |
117 | 117 |
118 def AssertPlayingState(self): | 118 def AssertPlayingState(self): |
119 """Assert player's playing state.""" | 119 """Assert player's playing state.""" |
120 self._pyauto.assertTrue(self._pyauto.WaitUntil(self._pyauto.GetPlayerState, | 120 self._pyauto.assertTrue(self._pyauto.WaitUntil(self._pyauto.GetPlayerState, |
121 expect_retval=self._pyauto.is_playing), | 121 expect_retval=self._pyauto.is_playing), |
122 msg='Player did not enter the playing state') | 122 msg='Player did not enter the playing state') |
123 | 123 |
124 def PlayVideoAndAssert(self): | 124 def PlayVideoAndAssert(self, youtube_video='zuzaxlddWbk'): |
125 """Start video and assert the playing state.""" | 125 """Start video and assert the playing state. |
| 126 |
| 127 By default test uses http://www.youtube.com/watch?v=zuzaxlddWbki. |
| 128 |
| 129 Args: |
| 130 youtube_video: The string ID of the youtube video to play. |
| 131 """ |
126 self._pyauto.assertTrue(self._pyauto.IsFlashPluginEnabled(), | 132 self._pyauto.assertTrue(self._pyauto.IsFlashPluginEnabled(), |
127 msg='From here Flash plugin is disabled or not available') | 133 msg='From here Flash plugin is disabled or not available') |
128 url = self._pyauto.GetHttpURLForDataPath('media', 'youtube.html') | 134 url = self._pyauto.GetHttpURLForDataPath( |
| 135 'media', 'youtube.html?video=' + youtube_video) |
129 self._pyauto.NavigateToURL(url) | 136 self._pyauto.NavigateToURL(url) |
130 self._pyauto.assertTrue(self._pyauto.WaitUntilPlayerReady(), | 137 self._pyauto.assertTrue(self._pyauto.WaitUntilPlayerReady(), |
131 msg='Failed to load YouTube player') | 138 msg='Failed to load YouTube player') |
132 self._pyauto.PlayVideo() | 139 self._pyauto.PlayVideo() |
133 self._pyauto.AssertPlayingState() | 140 self._pyauto.AssertPlayingState() |
134 | 141 |
135 | 142 |
136 class YoutubeTest(pyauto.PyUITest, YoutubeTestHelper): | 143 class YoutubeTest(pyauto.PyUITest, YoutubeTestHelper): |
137 """Test case for Youtube videos.""" | 144 """Test case for Youtube videos.""" |
138 | 145 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 break | 205 break |
199 loaded_bytes = self.GetVideoLoadedBytes() | 206 loaded_bytes = self.GetVideoLoadedBytes() |
200 self.assertTrue(prev_loaded_bytes <= loaded_bytes) | 207 self.assertTrue(prev_loaded_bytes <= loaded_bytes) |
201 prev_loaded_bytes = loaded_bytes | 208 prev_loaded_bytes = loaded_bytes |
202 # Give some time to load a video | 209 # Give some time to load a video |
203 time.sleep(1) | 210 time.sleep(1) |
204 | 211 |
205 | 212 |
206 if __name__ == '__main__': | 213 if __name__ == '__main__': |
207 pyauto_functional.Main() | 214 pyauto_functional.Main() |
OLD | NEW |