Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: chrome/test/functional/webrtc_call.py

Issue 10832084: Fixed race condition in media_stream_infobar.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added docstrings Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 self.assertEquals('failed-with-error-1', 140 self.assertEquals('failed-with-error-1',
143 self._GetUserMedia(tab_index=0, action='dismiss')) 141 self._GetUserMedia(tab_index=0, action='dismiss'))
144 142
145 def _GetUserMedia(self, tab_index, action='allow'): 143 def _GetUserMedia(self, tab_index, action='allow'):
146 """Acquires webcam or mic for one tab and returns the result.""" 144 """Acquires webcam or mic for one tab and returns the result."""
147 self.assertEquals('ok-requested', self.ExecuteJavascript( 145 self.assertEquals('ok-requested', self.ExecuteJavascript(
148 'getUserMedia(true, true)', tab_index=tab_index)) 146 'getUserMedia(true, true)', tab_index=tab_index))
149 147
150 self.WaitForInfobarCount(1, tab_index=tab_index) 148 self.WaitForInfobarCount(1, tab_index=tab_index)
151 self.PerformActionOnInfobar(action, infobar_index=0, tab_index=tab_index) 149 self.PerformActionOnInfobar(action, infobar_index=0, tab_index=tab_index)
152 self._WaitForGetUserMediaResult(tab_index=0) 150 self.WaitForGetUserMediaResult(tab_index=0)
153 151
154 result = self._GetUserMediaResult(tab_index=0) 152 result = self.GetUserMediaResult(tab_index=0)
155 self._AssertNoFailures(tab_index) 153 self._AssertNoFailures(tab_index)
156 return result 154 return result
157 155
158 def _Connect(self, user_name, tab_index): 156 def _Connect(self, user_name, tab_index):
159 self.assertEquals('ok-connected', self.ExecuteJavascript( 157 self.assertEquals('ok-connected', self.ExecuteJavascript(
160 'connect("http://localhost:8888", "%s")' % user_name, 158 'connect("http://localhost:8888", "%s")' % user_name,
161 tab_index=tab_index)) 159 tab_index=tab_index))
162 self._AssertNoFailures(tab_index) 160 self._AssertNoFailures(tab_index)
163 161
164 def _EstablishCall(self, from_tab_with_index): 162 def _EstablishCall(self, from_tab_with_index):
(...skipping 12 matching lines...) Expand all
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()
OLDNEW
« no previous file with comments | « chrome/test/functional/media_stream_infobar.py ('k') | chrome/test/functional/webrtc_test_base.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698