OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/command_line.h" | |
6 #include "base/utf_string_conversions.h" | |
7 #include "content/browser/web_contents/web_contents_impl.h" | |
8 #include "content/public/common/content_switches.h" | |
9 #include "content/public/test/browser_test_utils.h" | |
10 #include "content/shell/shell.h" | |
11 #include "content/test/content_browser_test.h" | |
12 #include "content/test/content_browser_test_utils.h" | |
13 #include "net/test/test_server.h" | |
14 | |
15 namespace content { | |
16 | |
17 class WebrtcBrowserTest: public ContentBrowserTest { | |
18 public: | |
19 WebrtcBrowserTest() {} | |
20 virtual ~WebrtcBrowserTest() {} | |
21 | |
22 virtual void SetUp() OVERRIDE { | |
23 // We need fake devices in this test since we want to run on naked VMs. We | |
24 // assume this switch is set by default in content_browsertests. | |
25 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | |
26 switches::kUseFakeDeviceForMediaStream)); | |
27 | |
28 ASSERT_TRUE(test_server()->Start()); | |
29 ContentBrowserTest::SetUp(); | |
30 } | |
31 protected: | |
32 bool ExecuteJavascript(const std::string& javascript) { | |
33 return ExecuteScript(shell()->web_contents(), javascript); | |
34 } | |
35 | |
36 void ExpectTitle(const std::string& expected_title) const { | |
37 string16 expected_title16(ASCIIToUTF16(expected_title)); | |
38 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); | |
39 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | |
40 } | |
41 }; | |
42 | |
43 // These tests will all make a getUserMedia call with different constraints and | |
44 // see that the success callback is called. If the error callback is called or | |
45 // none of the callbacks are called the tests will simply time out and fail. | |
46 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetVideoStreamAndStop) { | |
47 GURL url(test_server()->GetURL("files/media/getusermedia_and_stop.html")); | |
48 NavigateToURL(shell(), url); | |
49 | |
50 EXPECT_TRUE(ExecuteJavascript("getUserMedia({video: true});")); | |
51 | |
52 ExpectTitle("OK"); | |
53 } | |
54 | |
55 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndStop) { | |
56 GURL url(test_server()->GetURL("files/media/getusermedia_and_stop.html")); | |
57 NavigateToURL(shell(), url); | |
58 | |
59 EXPECT_TRUE(ExecuteJavascript("getUserMedia({video: true, audio: true});")); | |
60 | |
61 ExpectTitle("OK"); | |
62 } | |
63 | |
64 // These tests will make a complete PeerConnection-based call and verify that | |
65 // video is playing for the call. | |
66 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CanSetupVideoCall) { | |
67 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); | |
68 NavigateToURL(shell(), url); | |
69 | |
70 EXPECT_TRUE(ExecuteJavascript("call({video: true});")); | |
71 ExpectTitle("OK"); | |
72 } | |
73 | |
74 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CanSetupAudioAndVideoCall) { | |
75 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); | |
76 NavigateToURL(shell(), url); | |
77 | |
78 EXPECT_TRUE(ExecuteJavascript("call({video: true, audio: true});")); | |
79 ExpectTitle("OK"); | |
80 } | |
81 | |
82 // This test will make a complete PeerConnection-based call but remove the | |
83 // MSID and bundle attribute from the initial offer to verify that | |
84 // video is playing for the call even if the initiating client don't support | |
85 // MSID. http://tools.ietf.org/html/draft-alvestrand-rtcweb-msid-02 | |
86 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | |
87 CanSetupAudioAndVideoCallWithoutMsidAndBundle) { | |
88 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); | |
89 NavigateToURL(shell(), url); | |
90 | |
91 EXPECT_TRUE(ExecuteJavascript("callWithoutMsidAndBundle();")); | |
92 ExpectTitle("OK"); | |
93 } | |
94 | |
95 } // namespace content | |
96 | |
OLD | NEW |