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

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

Issue 11428073: Wrote audio- and video-only WebRTC call tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 8
9 import pyauto 9 import pyauto
10 10
11 11
12 class MissingRequiredBinaryException(Exception): 12 class MissingRequiredBinaryException(Exception):
13 pass 13 pass
14 14
15 15
16 class WebrtcTestBase(pyauto.PyUITest): 16 class WebrtcTestBase(pyauto.PyUITest):
17 """This base class provides helpers for WebRTC calls.""" 17 """This base class provides helpers for WebRTC calls."""
18 18
19 def ExtraChromeFlags(self): 19 def ExtraChromeFlags(self):
20 """Adds flags to the Chrome command line.""" 20 """Adds flags to the Chrome command line."""
21 extra_flags = ['--enable-media-stream', '--enable-peer-connection'] 21 extra_flags = ['--enable-media-stream', '--enable-peer-connection']
22 return pyauto.PyUITest.ExtraChromeFlags(self) + extra_flags 22 return pyauto.PyUITest.ExtraChromeFlags(self) + extra_flags
23 23
24 def GetUserMedia(self, tab_index, action='allow'): 24 def GetUserMedia(self, tab_index, action='allow',
25 request_video=True, request_audio=True):
25 """Acquires webcam or mic for one tab and returns the result. 26 """Acquires webcam or mic for one tab and returns the result.
26 27
27 Args: 28 Args:
28 tab_index: The tab to request user media on. 29 tab_index: The tab to request user media on.
29 action: The action to take on the info bar. Can be 'allow', 'deny' or 30 action: The action to take on the info bar. Can be 'allow', 'deny' or
30 'dismiss'. 31 'dismiss'.
32 request_video: Whether to request video.
33 request_audio: Whether to request audio.
31 34
32 Returns: 35 Returns:
33 A string as specified by the getUserMedia javascript function. 36 A string as specified by the getUserMedia javascript function.
34 """ 37 """
38 constraints = '{ video: %s, audio: %s }' % (str(request_video).lower(),
39 str(request_audio).lower())
35 self.assertEquals('ok-requested', self.ExecuteJavascript( 40 self.assertEquals('ok-requested', self.ExecuteJavascript(
36 'getUserMedia("{ audio: true, video: true, }")', tab_index=tab_index)) 41 'getUserMedia("%s")' % constraints, tab_index=tab_index))
37 42
38 self.WaitForInfobarCount(1, tab_index=tab_index) 43 self.WaitForInfobarCount(1, tab_index=tab_index)
39 self.PerformActionOnInfobar(action, infobar_index=0, tab_index=tab_index) 44 self.PerformActionOnInfobar(action, infobar_index=0, tab_index=tab_index)
40 self.WaitForGetUserMediaResult(tab_index=0) 45 self.WaitForGetUserMediaResult(tab_index=0)
41 46
42 result = self.GetUserMediaResult(tab_index=0) 47 result = self.GetUserMediaResult(tab_index=0)
43 self.AssertNoFailures(tab_index) 48 self.AssertNoFailures(tab_index)
44 return result 49 return result
45 50
46 def WaitForGetUserMediaResult(self, tab_index): 51 def WaitForGetUserMediaResult(self, tab_index):
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 'Could not locate peerconnection_server. Have you built the ' 170 'Could not locate peerconnection_server. Have you built the '
166 'peerconnection_server target? We expect to have a ' 171 'peerconnection_server target? We expect to have a '
167 'peerconnection_server binary next to the chrome binary.') 172 'peerconnection_server binary next to the chrome binary.')
168 173
169 self._server_process = subprocess.Popen(binary_path) 174 self._server_process = subprocess.Popen(binary_path)
170 175
171 def StopPeerConnectionServer(self): 176 def StopPeerConnectionServer(self):
172 """Stops the peerconnection_server.""" 177 """Stops the peerconnection_server."""
173 assert self._server_process 178 assert self._server_process
174 self._server_process.kill() 179 self._server_process.kill()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698