| 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 import time | |
| 9 import unittest | |
| 10 | 8 |
| 11 import pyauto_functional | 9 import pyauto_functional |
| 12 import pyauto | 10 import pyauto |
| 13 | 11 import webrtc_test_base |
| 14 | 12 |
| 15 class MissingRequiredBinaryException(Exception): | 13 class MissingRequiredBinaryException(Exception): |
| 16 pass | 14 pass |
| 17 | 15 |
| 18 | 16 |
| 19 class WebRTCCallTest(pyauto.PyUITest): | 17 class WebRTCCallTest(webrtc_test_base.WebrtcTestBase): |
| 20 """Test we can set up a WebRTC call and disconnect it. | 18 """Test we can set up a WebRTC call and disconnect it. |
| 21 | 19 |
| 22 Prerequisites: This test case must run on a machine with a webcam, either | 20 Prerequisites: This test case must run on a machine with a webcam, either |
| 23 fake or real, and with some kind of audio device. You must make the | 21 fake or real, and with some kind of audio device. You must make the |
| 24 peerconnection_server target before you run. | 22 peerconnection_server target before you run. |
| 25 | 23 |
| 26 The test case will launch a custom binary | 24 The test case will launch a custom binary |
| 27 (peerconnection_server) which will allow two WebRTC clients to find each | 25 (peerconnection_server) which will allow two WebRTC clients to find each |
| 28 other. For more details, see the source code which is available at the site | 26 other. For more details, see the source code which is available at the site |
| 29 http://code.google.com/p/libjingle/source/browse/ (make sure to browse to | 27 http://code.google.com/p/libjingle/source/browse/ (make sure to browse to |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 self._AssertNoFailures(from_tab_with_index) | 175 self._AssertNoFailures(from_tab_with_index) |
| 178 | 176 |
| 179 def _VerifyHungUp(self, tab_index): | 177 def _VerifyHungUp(self, tab_index): |
| 180 self.assertEquals('no', self.ExecuteJavascript( | 178 self.assertEquals('no', self.ExecuteJavascript( |
| 181 'is_call_active()', tab_index=tab_index)) | 179 'is_call_active()', tab_index=tab_index)) |
| 182 | 180 |
| 183 def _Disconnect(self, tab_index): | 181 def _Disconnect(self, tab_index): |
| 184 self.assertEquals('ok-disconnected', self.ExecuteJavascript( | 182 self.assertEquals('ok-disconnected', self.ExecuteJavascript( |
| 185 'disconnect()', tab_index=tab_index)) | 183 'disconnect()', tab_index=tab_index)) |
| 186 | 184 |
| 187 def _WaitForGetUserMediaResult(self, tab_index): | |
| 188 def HasResult(): | |
| 189 return self._GetUserMediaResult(tab_index) != 'not-called-yet' | |
| 190 self.assertTrue(self.WaitUntil(HasResult), | |
| 191 msg='Timed out while waiting for getUserMedia callback.') | |
| 192 | |
| 193 def _GetUserMediaResult(self, tab_index): | |
| 194 return self.ExecuteJavascript( | |
| 195 'obtainGetUserMediaResult()', tab_index=tab_index) | |
| 196 | |
| 197 def _StartDetectingVideo(self, tab_index, video_element): | 185 def _StartDetectingVideo(self, tab_index, video_element): |
| 198 self.assertEquals('ok-started', self.ExecuteJavascript( | 186 self.assertEquals('ok-started', self.ExecuteJavascript( |
| 199 'startDetection("%s", "frame_buffer", 320, 240)' % video_element, | 187 'startDetection("%s", "frame_buffer", 320, 240)' % video_element, |
| 200 tab_index=tab_index)); | 188 tab_index=tab_index)); |
| 201 | 189 |
| 202 def _WaitForVideoToPlay(self): | 190 def _WaitForVideoToPlay(self): |
| 203 video_playing = self.WaitUntil( | 191 video_playing = self.WaitUntil( |
| 204 function=lambda: self.ExecuteJavascript('isVideoPlaying()'), | 192 function=lambda: self.ExecuteJavascript('isVideoPlaying()'), |
| 205 expect_retval='video-playing') | 193 expect_retval='video-playing') |
| 206 self.assertTrue(video_playing, | 194 self.assertTrue(video_playing, |
| 207 msg='Timed out while trying to detect video.') | 195 msg='Timed out while trying to detect video.') |
| 208 | 196 |
| 209 def _AssertNoFailures(self, tab_index): | 197 def _AssertNoFailures(self, tab_index): |
| 210 self.assertEquals('ok-no-errors', self.ExecuteJavascript( | 198 self.assertEquals('ok-no-errors', self.ExecuteJavascript( |
| 211 'getAnyTestFailures()', tab_index=tab_index)) | 199 'getAnyTestFailures()', tab_index=tab_index)) |
| 212 | 200 |
| 213 | 201 |
| 214 if __name__ == '__main__': | 202 if __name__ == '__main__': |
| 215 pyauto_functional.Main() | 203 pyauto_functional.Main() |
| OLD | NEW |