OLD | NEW |
---|---|
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 random | |
7 | |
6 # Note: pyauto_functional must come before pyauto. | 8 # Note: pyauto_functional must come before pyauto. |
7 import pyauto_functional | 9 import pyauto_functional |
8 import pyauto | 10 import pyauto |
9 import webrtc_test_base | 11 import webrtc_test_base |
10 | 12 |
11 | 13 |
12 class WebrtcApprtcCallTest(webrtc_test_base.WebrtcTestBase): | 14 class WebrtcApprtcCallTest(webrtc_test_base.WebrtcTestBase): |
13 """Tests calling apprtc.appspot.com and setting up a call. | 15 """Tests calling apprtc.appspot.com and setting up a call. |
14 | 16 |
15 Prerequisites: This test case must run on a machine with a webcam, either | 17 Prerequisites: This test case must run on a machine with a webcam, either |
16 fake or real, and with some kind of audio device. The machine must have access | 18 fake or real, and with some kind of audio device. The machine must have access |
17 to the public Internet. | 19 to the public Internet. |
18 | 20 |
19 This should be considered an integration test: test failures could mean | 21 This should be considered an integration test: test failures could mean |
20 that the AppRTC reference is broken, that WebRTC is broken, or both. | 22 that the AppRTC reference is broken, that WebRTC is broken, or both. |
21 """ | 23 """ |
22 | 24 |
23 def tearDown(self): | 25 def tearDown(self): |
24 pyauto.PyUITest.tearDown(self) | 26 pyauto.PyUITest.tearDown(self) |
25 self.assertEquals('', self.CheckErrorsAndCrashes(), | 27 self.assertEquals('', self.CheckErrorsAndCrashes(), |
26 'Chrome crashed or hit a critical error during test.') | 28 'Chrome crashed or hit a critical error during test.') |
27 | 29 |
28 def testApprtcLoopbackVideoAudioCall(self): | 30 def testApprtcLoopbackCall(self): |
29 self.NavigateToURL('http://apprtc.appspot.com/?debug=loopback') | 31 self.NavigateToURL('http://apprtc.appspot.com/?debug=loopback') |
30 self.WaitForInfobarCount(1, tab_index=0) | 32 self.WaitForInfobarCount(1, tab_index=0) |
31 self.PerformActionOnInfobar('accept', infobar_index=0, tab_index=0) | 33 self.PerformActionOnInfobar('accept', infobar_index=0, tab_index=0) |
32 | 34 |
33 self._WaitForCallEstablishment(tab_index=0) | 35 self._WaitForCallEstablishment(tab_index=0) |
34 | 36 |
37 def testApprtcTabToTabCall(self): | |
38 random_call_id = 'pyauto%d' % random.randint(0, 65536) | |
dennis_jeffrey
2012/12/19 18:13:32
what benefit do we get by using a random int in th
phoglund_chromium
2013/01/02 10:18:55
The ID is used to refer to a call session, which i
| |
39 apprtc_url = 'http://apprtc.appspot.com/?r=%s' % random_call_id | |
40 | |
41 self.NavigateToURL(apprtc_url) | |
42 self.AppendTab(pyauto.GURL(apprtc_url)) | |
43 | |
44 self.WaitForInfobarCount(1, tab_index=0) | |
45 self.WaitForInfobarCount(1, tab_index=1) | |
46 | |
47 self.PerformActionOnInfobar('accept', infobar_index=0, tab_index=0) | |
48 self.PerformActionOnInfobar('accept', infobar_index=0, tab_index=1) | |
49 | |
50 self._WaitForCallEstablishment(tab_index=0) | |
51 self._WaitForCallEstablishment(tab_index=1) | |
52 | |
35 def _WaitForCallEstablishment(self, tab_index): | 53 def _WaitForCallEstablishment(self, tab_index): |
36 # AppRTC will set opacity to 1 for remote video when the call is up. | 54 # AppRTC will set opacity to 1 for remote video when the call is up. |
37 video_playing = self.WaitUntil( | 55 video_playing = self.WaitUntil( |
38 function=lambda: self.GetDOMValue('remoteVideo.style.opacity', | 56 function=lambda: self.GetDOMValue('remoteVideo.style.opacity', |
39 tab_index=tab_index), | 57 tab_index=tab_index), |
40 expect_retval='1') | 58 expect_retval='1') |
41 self.assertTrue(video_playing, | 59 self.assertTrue(video_playing, |
42 msg=('Timed out while waiting for ' | 60 msg=('Timed out while waiting for ' |
43 'remoteVideo.style.opacity to return 1.')) | 61 'remoteVideo.style.opacity to return 1.')) |
44 | 62 |
45 | 63 |
46 if __name__ == '__main__': | 64 if __name__ == '__main__': |
47 pyauto_functional.Main() | 65 pyauto_functional.Main() |
OLD | NEW |