OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import pyauto |
| 7 |
| 8 |
| 9 class WebrtcTestBase(pyauto.PyUITest): |
| 10 """This base class provides helpers for getUserMedia calls.""" |
| 11 |
| 12 def WaitForGetUserMediaResult(self, tab_index): |
| 13 """Waits until WebRTC has responded to a getUserMedia query. |
| 14 |
| 15 Fails an assert if WebRTC doesn't respond within the default timeout. |
| 16 |
| 17 Args: |
| 18 tab_index: the tab to query. |
| 19 """ |
| 20 def HasResult(): |
| 21 return self.GetUserMediaResult(tab_index) != 'not-called-yet' |
| 22 self.assertTrue(self.WaitUntil(HasResult), |
| 23 msg='Timed out while waiting for getUserMedia callback.') |
| 24 |
| 25 def GetUserMediaResult(self, tab_index): |
| 26 """Retrieves WebRTC's answer to a user media query. |
| 27 |
| 28 Args: |
| 29 tab_index: the tab to query. |
| 30 |
| 31 Returns: |
| 32 Specified in obtainGetUserMediaResult() in getusermedia.js. |
| 33 """ |
| 34 return self.ExecuteJavascript( |
| 35 'obtainGetUserMediaResult()', tab_index=tab_index) |
OLD | NEW |