Commit 8ab0b01d authored by phoglund@chromium.org's avatar phoglund@chromium.org

Wrote audio- and video-only WebRTC call tests.


BUG=


Review URL: https://chromiumcodereview.appspot.com/11428073

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170930 0039d316-1c4b-4281-b951-d872f2087c98
parent df9ec3cb
...@@ -2258,8 +2258,15 @@ void TestingAutomationProvider::PerformActionOnInfobar( ...@@ -2258,8 +2258,15 @@ void TestingAutomationProvider::PerformActionOnInfobar(
media_stream_infobar->GetVideoDevices(); media_stream_infobar->GetVideoDevices();
content::MediaStreamDevices audio_devices = content::MediaStreamDevices audio_devices =
media_stream_infobar->GetAudioDevices(); media_stream_infobar->GetAudioDevices();
if (video_devices.empty() || audio_devices.empty()) {
reply.SendError("No available audio/video devices to autoselect."); if (media_stream_infobar->HasVideo() && video_devices.empty()) {
reply.SendError("Requested video, but there are no video "
"devices on the system.");
return;
}
if (media_stream_infobar->HasAudio() && audio_devices.empty()) {
reply.SendError("Requested audio, but there are no audio "
"devices on the system.");
return; return;
} }
......
...@@ -50,7 +50,7 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase): ...@@ -50,7 +50,7 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase):
pyauto.PyUITest.tearDown(self) pyauto.PyUITest.tearDown(self)
self.assertEquals('', self.CheckErrorsAndCrashes()) self.assertEquals('', self.CheckErrorsAndCrashes())
def _SimpleWebrtcCall(self, duration_seconds=0): def _SimpleWebrtcCall(self, request_video, request_audio, duration_seconds=0):
"""Tests we can call and hang up with WebRTC. """Tests we can call and hang up with WebRTC.
This test exercises pretty much the whole happy-case for the WebRTC This test exercises pretty much the whole happy-case for the WebRTC
...@@ -73,10 +73,12 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase): ...@@ -73,10 +73,12 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase):
playing by using the video detector. playing by using the video detector.
Args: Args:
request_video: Whether to request video.
request_audio: Whether to request audio.
duration_seconds: The number of seconds to keep the call up before duration_seconds: The number of seconds to keep the call up before
shutting it down. shutting it down.
""" """
self._SetupCall() self._SetupCall(request_video=request_video, request_audio=request_audio)
if duration_seconds: if duration_seconds:
print 'Call up: sleeping %d seconds...' % duration_seconds print 'Call up: sleeping %d seconds...' % duration_seconds
...@@ -93,10 +95,18 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase): ...@@ -93,10 +95,18 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase):
self.AssertNoFailures(tab_index=0) self.AssertNoFailures(tab_index=0)
self.AssertNoFailures(tab_index=1) self.AssertNoFailures(tab_index=1)
def testSimpleWebrtcJsep01Call(self): def testWebrtcJsep01Call(self):
"""Uses a draft of the PeerConnection API, using JSEP01.""" """Uses a draft of the PeerConnection API, using JSEP01."""
self._LoadPageInTwoTabs('webrtc_jsep01_test.html') self._LoadPageInTwoTabs('webrtc_jsep01_test.html')
self._SimpleWebrtcCall() self._SimpleWebrtcCall(request_video=True, request_audio=True)
def testWebrtcVideoOnlyJsep01Call(self):
self._LoadPageInTwoTabs('webrtc_jsep01_test.html')
self._SimpleWebrtcCall(request_video=True, request_audio=False)
def testWebrtcAudioOnlyJsep01Call(self):
self._LoadPageInTwoTabs('webrtc_jsep01_test.html')
self._SimpleWebrtcCall(request_video=False, request_audio=True)
def testJsep01AndMeasureCpu20Seconds(self): def testJsep01AndMeasureCpu20Seconds(self):
if not _HAS_CORRECT_PSUTIL_VERSION: if not _HAS_CORRECT_PSUTIL_VERSION:
...@@ -111,7 +121,9 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase): ...@@ -111,7 +121,9 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase):
renderer_process = self._GetChromeRendererProcess(tab_index=0) renderer_process = self._GetChromeRendererProcess(tab_index=0)
renderer_process.get_cpu_percent() renderer_process.get_cpu_percent()
self._SimpleWebrtcCall(duration_seconds=20) self._SimpleWebrtcCall(request_video=True,
request_audio=True,
duration_seconds=20)
cpu_usage = renderer_process.get_cpu_percent(interval=0) cpu_usage = renderer_process.get_cpu_percent(interval=0)
mem_usage_bytes = renderer_process.get_memory_info()[0] mem_usage_bytes = renderer_process.get_memory_info()[0]
...@@ -165,7 +177,7 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase): ...@@ -165,7 +177,7 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase):
# TODO(perkj): Verify that audio is muted. # TODO(perkj): Verify that audio is muted.
self._LoadPageInTwoTabs('webrtc_jsep01_test.html') self._LoadPageInTwoTabs('webrtc_jsep01_test.html')
self._SetupCall() self._SetupCall(request_video=True, request_audio=True)
select_video_function = 'function(local) { return local.videoTracks[0]; }' select_video_function = 'function(local) { return local.videoTracks[0]; }'
self.assertEquals('ok-video-toggled-to-false', self.ExecuteJavascript( self.assertEquals('ok-video-toggled-to-false', self.ExecuteJavascript(
'toggleLocalStream(' + select_video_function + ', "video")', 'toggleLocalStream(' + select_video_function + ', "video")',
...@@ -193,23 +205,30 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase): ...@@ -193,23 +205,30 @@ class WebrtcCallTest(webrtc_test_base.WebrtcTestBase):
self.NavigateToURL(url) self.NavigateToURL(url)
self.AppendTab(pyauto.GURL(url)) self.AppendTab(pyauto.GURL(url))
def _SetupCall(self): def _SetupCall(self, request_video, request_audio):
"""Gets user media and establishes a call. """Gets user media and establishes a call.
Assumes that two tabs are already opened with a suitable test page. Assumes that two tabs are already opened with a suitable test page.
Args:
request_video: Whether to request video.
request_audio: Whether to request audio.
""" """
self.assertEquals('ok-got-stream', self.GetUserMedia(tab_index=0)) self.assertEquals('ok-got-stream', self.GetUserMedia(
self.assertEquals('ok-got-stream', self.GetUserMedia(tab_index=1)) tab_index=0, request_video=request_video, request_audio=request_audio))
self.assertEquals('ok-got-stream', self.GetUserMedia(
tab_index=1, request_video=request_video, request_audio=request_audio))
self.Connect('user_1', tab_index=0) self.Connect('user_1', tab_index=0)
self.Connect('user_2', tab_index=1) self.Connect('user_2', tab_index=1)
self.EstablishCall(from_tab_with_index=0, to_tab_with_index=1) self.EstablishCall(from_tab_with_index=0, to_tab_with_index=1)
self._StartDetectingVideo(tab_index=0, video_element='remote-view') if request_video:
self._StartDetectingVideo(tab_index=1, video_element='remote-view') self._StartDetectingVideo(tab_index=0, video_element='remote-view')
self._StartDetectingVideo(tab_index=1, video_element='remote-view')
self._WaitForVideo(tab_index=0, expect_playing=True) self._WaitForVideo(tab_index=0, expect_playing=True)
self._WaitForVideo(tab_index=1, expect_playing=True) self._WaitForVideo(tab_index=1, expect_playing=True)
def _StartDetectingVideo(self, tab_index, video_element): def _StartDetectingVideo(self, tab_index, video_element):
self.assertEquals('ok-started', self.ExecuteJavascript( self.assertEquals('ok-started', self.ExecuteJavascript(
......
...@@ -21,19 +21,24 @@ class WebrtcTestBase(pyauto.PyUITest): ...@@ -21,19 +21,24 @@ class WebrtcTestBase(pyauto.PyUITest):
extra_flags = ['--enable-media-stream', '--enable-peer-connection'] extra_flags = ['--enable-media-stream', '--enable-peer-connection']
return pyauto.PyUITest.ExtraChromeFlags(self) + extra_flags return pyauto.PyUITest.ExtraChromeFlags(self) + extra_flags
def GetUserMedia(self, tab_index, action='allow'): def GetUserMedia(self, tab_index, action='allow',
request_video=True, request_audio=True):
"""Acquires webcam or mic for one tab and returns the result. """Acquires webcam or mic for one tab and returns the result.
Args: Args:
tab_index: The tab to request user media on. tab_index: The tab to request user media on.
action: The action to take on the info bar. Can be 'allow', 'deny' or action: The action to take on the info bar. Can be 'allow', 'deny' or
'dismiss'. 'dismiss'.
request_video: Whether to request video.
request_audio: Whether to request audio.
Returns: Returns:
A string as specified by the getUserMedia javascript function. A string as specified by the getUserMedia javascript function.
""" """
constraints = '{ video: %s, audio: %s }' % (str(request_video).lower(),
str(request_audio).lower())
self.assertEquals('ok-requested', self.ExecuteJavascript( self.assertEquals('ok-requested', self.ExecuteJavascript(
'getUserMedia("{ audio: true, video: true, }")', tab_index=tab_index)) 'getUserMedia("%s")' % constraints, tab_index=tab_index))
self.WaitForInfobarCount(1, tab_index=tab_index) self.WaitForInfobarCount(1, tab_index=tab_index)
self.PerformActionOnInfobar(action, infobar_index=0, tab_index=tab_index) self.PerformActionOnInfobar(action, infobar_index=0, tab_index=tab_index)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment