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_file='youtube.html'): |
Nirnimesh
2011/12/01 00:03:14
why not pass the youtube video's URL as argument t
| |
125 """Start video and assert the playing state.""" | 125 """Start video and assert the playing state.""" |
126 self._pyauto.assertTrue(self._pyauto.IsFlashPluginEnabled(), | 126 self._pyauto.assertTrue(self._pyauto.IsFlashPluginEnabled(), |
127 msg='From here Flash plugin is disabled or not available') | 127 msg='From here Flash plugin is disabled or not available') |
128 url = self._pyauto.GetHttpURLForDataPath('media', 'youtube.html') | 128 url = self._pyauto.GetHttpURLForDataPath('media', youtube_file) |
129 self._pyauto.NavigateToURL(url) | 129 self._pyauto.NavigateToURL(url) |
130 self._pyauto.assertTrue(self._pyauto.WaitUntilPlayerReady(), | 130 self._pyauto.assertTrue(self._pyauto.WaitUntilPlayerReady(), |
131 msg='Failed to load YouTube player') | 131 msg='Failed to load YouTube player') |
132 self._pyauto.PlayVideo() | 132 self._pyauto.PlayVideo() |
133 self._pyauto.AssertPlayingState() | 133 self._pyauto.AssertPlayingState() |
134 | 134 |
135 | 135 |
136 class YoutubeTest(pyauto.PyUITest, YoutubeTestHelper): | 136 class YoutubeTest(pyauto.PyUITest, YoutubeTestHelper): |
137 """Test case for Youtube videos.""" | 137 """Test case for Youtube videos.""" |
138 | 138 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 break | 198 break |
199 loaded_bytes = self.GetVideoLoadedBytes() | 199 loaded_bytes = self.GetVideoLoadedBytes() |
200 self.assertTrue(prev_loaded_bytes <= loaded_bytes) | 200 self.assertTrue(prev_loaded_bytes <= loaded_bytes) |
201 prev_loaded_bytes = loaded_bytes | 201 prev_loaded_bytes = loaded_bytes |
202 # Give some time to load a video | 202 # Give some time to load a video |
203 time.sleep(1) | 203 time.sleep(1) |
204 | 204 |
205 | 205 |
206 if __name__ == '__main__': | 206 if __name__ == '__main__': |
207 pyauto_functional.Main() | 207 pyauto_functional.Main() |
OLD | NEW |