| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 os | 6 import os |
| 7 import subprocess | 7 import subprocess |
| 8 | 8 |
| 9 import pyauto_functional | 9 import pyauto_functional |
| 10 import pyauto | 10 import pyauto |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 'peerconnection_server binary next to the chrome binary.') | 49 'peerconnection_server binary next to the chrome binary.') |
| 50 | 50 |
| 51 self._server_process = subprocess.Popen(binary_path) | 51 self._server_process = subprocess.Popen(binary_path) |
| 52 | 52 |
| 53 def tearDown(self): | 53 def tearDown(self): |
| 54 self._server_process.kill() | 54 self._server_process.kill() |
| 55 | 55 |
| 56 pyauto.PyUITest.tearDown(self) | 56 pyauto.PyUITest.tearDown(self) |
| 57 self.assertEquals('', self.CheckErrorsAndCrashes()) | 57 self.assertEquals('', self.CheckErrorsAndCrashes()) |
| 58 | 58 |
| 59 def _SimpleWebRtcCall(self, test_page): | 59 def _SimpleWebrtcCall(self, test_page): |
| 60 """Tests we can call and hang up with WebRTC. | 60 """Tests we can call and hang up with WebRTC. |
| 61 | 61 |
| 62 This test exercises pretty much the whole happy-case for the WebRTC | 62 This test exercises pretty much the whole happy-case for the WebRTC |
| 63 JavaScript API. Currently, it exercises a normal call setup using the API | 63 JavaScript API. Currently, it exercises a normal call setup using the API |
| 64 defined at http://dev.w3.org/2011/webrtc/editor/webrtc.html. The API is | 64 defined at http://dev.w3.org/2011/webrtc/editor/webrtc.html. The API is |
| 65 still evolving. | 65 still evolving. |
| 66 | 66 |
| 67 The test will load the supplied HTML file, which in turn will load different | 67 The test will load the supplied HTML file, which in turn will load different |
| 68 javascript files depending on which version of the signaling protocol | 68 javascript files depending on which version of the signaling protocol |
| 69 we are running. | 69 we are running. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 88 self._Connect('user_2', tab_index=1) | 88 self._Connect('user_2', tab_index=1) |
| 89 | 89 |
| 90 self._EstablishCall(from_tab_with_index=0) | 90 self._EstablishCall(from_tab_with_index=0) |
| 91 | 91 |
| 92 self._StartDetectingVideo(tab_index=0, video_element='remote_view') | 92 self._StartDetectingVideo(tab_index=0, video_element='remote_view') |
| 93 | 93 |
| 94 self._WaitForVideoToPlay() | 94 self._WaitForVideoToPlay() |
| 95 | 95 |
| 96 # The hang-up will automatically propagate to the second tab. | 96 # The hang-up will automatically propagate to the second tab. |
| 97 self._HangUp(from_tab_with_index=0) | 97 self._HangUp(from_tab_with_index=0) |
| 98 self._VerifyHungUp(tab_index=1) | 98 self._WaitUntilHangUpVerified(tab_index=1) |
| 99 | 99 |
| 100 self._Disconnect(tab_index=0) | 100 self._Disconnect(tab_index=0) |
| 101 self._Disconnect(tab_index=1) | 101 self._Disconnect(tab_index=1) |
| 102 | 102 |
| 103 # Ensure we didn't miss any errors. | 103 # Ensure we didn't miss any errors. |
| 104 self.AssertNoFailures(tab_index=0) | 104 self.AssertNoFailures(tab_index=0) |
| 105 self.AssertNoFailures(tab_index=1) | 105 self.AssertNoFailures(tab_index=1) |
| 106 | 106 |
| 107 def testSimpleWebRtcJsepCall(self): | 107 def testSimpleWebrtcJsepCall(self): |
| 108 self._SimpleWebRtcCall('webrtc_jsep_test.html') | 108 self._SimpleWebrtcCall('webrtc_jsep_test.html') |
| 109 | 109 |
| 110 def testLocalPreview(self): | 110 def testLocalPreview(self): |
| 111 """Brings up a local preview and ensures video is playing. | 111 """Brings up a local preview and ensures video is playing. |
| 112 | 112 |
| 113 This test will launch a window with a single tab and run a getUserMedia call | 113 This test will launch a window with a single tab and run a getUserMedia call |
| 114 which will give us access to the webcam and microphone. Then the javascript | 114 which will give us access to the webcam and microphone. Then the javascript |
| 115 code will hook up the webcam data to the local_view video tag. We will | 115 code will hook up the webcam data to the local_view video tag. We will |
| 116 detect video in that tag using the video detector, and if we see video | 116 detect video in that tag using the video detector, and if we see video |
| 117 moving the test passes. | 117 moving the test passes. |
| 118 """ | 118 """ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 'call()', tab_index=from_tab_with_index)) | 152 'call()', tab_index=from_tab_with_index)) |
| 153 self.AssertNoFailures(from_tab_with_index) | 153 self.AssertNoFailures(from_tab_with_index) |
| 154 | 154 |
| 155 # Double-check the call reached the other side. | 155 # Double-check the call reached the other side. |
| 156 self.assertEquals('yes', self.ExecuteJavascript( | 156 self.assertEquals('yes', self.ExecuteJavascript( |
| 157 'is_call_active()', tab_index=from_tab_with_index)) | 157 'is_call_active()', tab_index=from_tab_with_index)) |
| 158 | 158 |
| 159 def _HangUp(self, from_tab_with_index): | 159 def _HangUp(self, from_tab_with_index): |
| 160 self.assertEquals('ok-call-hung-up', self.ExecuteJavascript( | 160 self.assertEquals('ok-call-hung-up', self.ExecuteJavascript( |
| 161 'hangUp()', tab_index=from_tab_with_index)) | 161 'hangUp()', tab_index=from_tab_with_index)) |
| 162 self._VerifyHungUp(from_tab_with_index) | 162 self._WaitUntilHangUpVerified(tab_index=from_tab_with_index) |
| 163 self.AssertNoFailures(from_tab_with_index) | 163 self.AssertNoFailures(tab_index=from_tab_with_index) |
| 164 | 164 |
| 165 def _VerifyHungUp(self, tab_index): | 165 def _WaitUntilHangUpVerified(self, tab_index): |
| 166 self.assertEquals('no', self.ExecuteJavascript( | 166 hung_up = self.WaitUntil( |
| 167 'is_call_active()', tab_index=tab_index)) | 167 function=lambda: self.ExecuteJavascript('is_call_active()', |
| 168 tab_index=tab_index), |
| 169 expect_retval='no') |
| 170 self.assertTrue(hung_up, |
| 171 msg='Timed out while waiting for hang-up to be confirmed.') |
| 168 | 172 |
| 169 def _Disconnect(self, tab_index): | 173 def _Disconnect(self, tab_index): |
| 170 self.assertEquals('ok-disconnected', self.ExecuteJavascript( | 174 self.assertEquals('ok-disconnected', self.ExecuteJavascript( |
| 171 'disconnect()', tab_index=tab_index)) | 175 'disconnect()', tab_index=tab_index)) |
| 172 | 176 |
| 173 def _StartDetectingVideo(self, tab_index, video_element): | 177 def _StartDetectingVideo(self, tab_index, video_element): |
| 174 self.assertEquals('ok-started', self.ExecuteJavascript( | 178 self.assertEquals('ok-started', self.ExecuteJavascript( |
| 175 'startDetection("%s", "frame_buffer", 320, 240)' % video_element, | 179 'startDetection("%s", "frame_buffer", 320, 240)' % video_element, |
| 176 tab_index=tab_index)); | 180 tab_index=tab_index)); |
| 177 | 181 |
| 178 def _WaitForVideoToPlay(self): | 182 def _WaitForVideoToPlay(self): |
| 179 video_playing = self.WaitUntil( | 183 video_playing = self.WaitUntil( |
| 180 function=lambda: self.ExecuteJavascript('isVideoPlaying()'), | 184 function=lambda: self.ExecuteJavascript('isVideoPlaying()'), |
| 181 expect_retval='video-playing') | 185 expect_retval='video-playing') |
| 182 self.assertTrue(video_playing, | 186 self.assertTrue(video_playing, |
| 183 msg='Timed out while trying to detect video.') | 187 msg='Timed out while trying to detect video.') |
| 184 | 188 |
| 185 | 189 |
| 186 if __name__ == '__main__': | 190 if __name__ == '__main__': |
| 187 pyauto_functional.Main() | 191 pyauto_functional.Main() |
| OLD | NEW |