| Index: chrome/test/functional/webrtc_test_base.py
|
| diff --git a/chrome/test/functional/webrtc_test_base.py b/chrome/test/functional/webrtc_test_base.py
|
| index 4623aa2308eff3908292d6e18e8d86e7cba56e76..999c821a44a6dad56fb4dcaa4b015bc48e5a9071 100755
|
| --- a/chrome/test/functional/webrtc_test_base.py
|
| +++ b/chrome/test/functional/webrtc_test_base.py
|
| @@ -9,6 +9,28 @@ import pyauto
|
| class WebrtcTestBase(pyauto.PyUITest):
|
| """This base class provides helpers for getUserMedia calls."""
|
|
|
| + def GetUserMedia(self, tab_index, action='allow'):
|
| + """Acquires webcam or mic for one tab and returns the result.
|
| +
|
| + Args:
|
| + tab_index: The tab to request user media on.
|
| + action: The action to take on the info bar. Can be 'allow', 'deny' or
|
| + 'dismiss'.
|
| +
|
| + Returns:
|
| + A string as specified by the getUserMedia javascript function.
|
| + """
|
| + self.assertEquals('ok-requested', self.ExecuteJavascript(
|
| + 'getUserMedia(true, true)', tab_index=tab_index))
|
| +
|
| + self.WaitForInfobarCount(1, tab_index=tab_index)
|
| + self.PerformActionOnInfobar(action, infobar_index=0, tab_index=tab_index)
|
| + self.WaitForGetUserMediaResult(tab_index=0)
|
| +
|
| + result = self.GetUserMediaResult(tab_index=0)
|
| + self.AssertNoFailures(tab_index)
|
| + return result
|
| +
|
| def WaitForGetUserMediaResult(self, tab_index):
|
| """Waits until WebRTC has responded to a getUserMedia query.
|
|
|
| @@ -32,4 +54,13 @@ class WebrtcTestBase(pyauto.PyUITest):
|
| Specified in obtainGetUserMediaResult() in getusermedia.js.
|
| """
|
| return self.ExecuteJavascript(
|
| - 'obtainGetUserMediaResult()', tab_index=tab_index)
|
| + 'obtainGetUserMediaResult()', tab_index=tab_index)
|
| +
|
| + def AssertNoFailures(self, tab_index):
|
| + """Ensures the javascript hasn't registered any asynchronous errors.
|
| +
|
| + Args:
|
| + tab_index: The tab to check.
|
| + """
|
| + self.assertEquals('ok-no-errors', self.ExecuteJavascript(
|
| + 'getAnyTestFailures()', tab_index=tab_index))
|
|
|