Commit cded042b authored by phoglund@chromium.org's avatar phoglund@chromium.org

Fixed race condition in media_stream_infobar.py.


BUG=
NOTRY=true


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149401 0039d316-1c4b-4281-b951-d872f2087c98
parent 75b558c7
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
import pyauto_functional import pyauto_functional
import pyauto import pyauto
import webrtc_test_base
class MediaStreamInfobarTest(pyauto.PyUITest): class MediaStreamInfobarTest(webrtc_test_base.WebrtcTestBase):
"""Performs basic tests on the media stream infobar. """Performs basic tests on the media stream infobar.
This infobar is used to grant or deny access to WebRTC capabilities for a This infobar is used to grant or deny access to WebRTC capabilities for a
...@@ -73,8 +74,9 @@ class MediaStreamInfobarTest(pyauto.PyUITest): ...@@ -73,8 +74,9 @@ class MediaStreamInfobarTest(pyauto.PyUITest):
self.WaitForInfobarCount(1) self.WaitForInfobarCount(1)
self.PerformActionOnInfobar(with_action, infobar_index=0) self.PerformActionOnInfobar(with_action, infobar_index=0)
self.WaitForGetUserMediaResult(tab_index=0)
return self.ExecuteJavascript('obtainGetUserMediaResult()') return self.GetUserMediaResult(tab_index=0)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -5,18 +5,16 @@ ...@@ -5,18 +5,16 @@
import os import os
import subprocess import subprocess
import time
import unittest
import pyauto_functional import pyauto_functional
import pyauto import pyauto
import webrtc_test_base
class MissingRequiredBinaryException(Exception): class MissingRequiredBinaryException(Exception):
pass pass
class WebRTCCallTest(pyauto.PyUITest): class WebRTCCallTest(webrtc_test_base.WebrtcTestBase):
"""Test we can set up a WebRTC call and disconnect it. """Test we can set up a WebRTC call and disconnect it.
Prerequisites: This test case must run on a machine with a webcam, either Prerequisites: This test case must run on a machine with a webcam, either
...@@ -149,9 +147,9 @@ class WebRTCCallTest(pyauto.PyUITest): ...@@ -149,9 +147,9 @@ class WebRTCCallTest(pyauto.PyUITest):
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)
self._WaitForGetUserMediaResult(tab_index=0) self.WaitForGetUserMediaResult(tab_index=0)
result = self._GetUserMediaResult(tab_index=0) result = self.GetUserMediaResult(tab_index=0)
self._AssertNoFailures(tab_index) self._AssertNoFailures(tab_index)
return result return result
...@@ -184,16 +182,6 @@ class WebRTCCallTest(pyauto.PyUITest): ...@@ -184,16 +182,6 @@ class WebRTCCallTest(pyauto.PyUITest):
self.assertEquals('ok-disconnected', self.ExecuteJavascript( self.assertEquals('ok-disconnected', self.ExecuteJavascript(
'disconnect()', tab_index=tab_index)) 'disconnect()', tab_index=tab_index))
def _WaitForGetUserMediaResult(self, tab_index):
def HasResult():
return self._GetUserMediaResult(tab_index) != 'not-called-yet'
self.assertTrue(self.WaitUntil(HasResult),
msg='Timed out while waiting for getUserMedia callback.')
def _GetUserMediaResult(self, tab_index):
return self.ExecuteJavascript(
'obtainGetUserMediaResult()', tab_index=tab_index)
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(
'startDetection("%s", "frame_buffer", 320, 240)' % video_element, 'startDetection("%s", "frame_buffer", 320, 240)' % video_element,
......
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import pyauto
class WebrtcTestBase(pyauto.PyUITest):
"""This base class provides helpers for getUserMedia calls."""
def WaitForGetUserMediaResult(self, tab_index):
"""Waits until WebRTC has responded to a getUserMedia query.
Fails an assert if WebRTC doesn't respond within the default timeout.
Args:
tab_index: the tab to query.
"""
def HasResult():
return self.GetUserMediaResult(tab_index) != 'not-called-yet'
self.assertTrue(self.WaitUntil(HasResult),
msg='Timed out while waiting for getUserMedia callback.')
def GetUserMediaResult(self, tab_index):
"""Retrieves WebRTC's answer to a user media query.
Args:
tab_index: the tab to query.
Returns:
Specified in obtainGetUserMediaResult() in getusermedia.js.
"""
return self.ExecuteJavascript(
'obtainGetUserMediaResult()', tab_index=tab_index)
\ No newline at end of file
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