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 RenderViewHost* render_view_host = | |
34 shell()->web_contents()->GetRenderViewHost(); | |
35 | |
36 return ExecuteJavaScript(render_view_host, L"", ASCIIToWide(javascript)); | |
37 } | |
38 | |
39 void ExpectTitle(const std::string& expected_title) const { | |
40 string16 expected_title16(ASCIIToUTF16(expected_title)); | |
41 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); | |
42 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | |
43 } | |
44 }; | |
45 | |
46 // These tests will all make a getUserMedia call with different constraints and | |
47 // see that the success callback is called. If the error callback is called or | |
48 // none of the callbacks are called the tests will simply time out and fail. | |
49 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetVideoStreamAndStop) { | |
perkj_chrome
2012/12/04 10:51:43
Why are these tests called stop? you never call st
phoglund_chromium
2012/12/04 13:03:27
Yes, we do call stop in getusermedia_and_stop.html
| |
50 GURL url(test_server()->GetURL("files/media/getusermedia_and_stop.html")); | |
51 NavigateToURL(shell(), url); | |
52 | |
53 EXPECT_TRUE(ExecuteJavascript("getUserMedia({video: true});")); | |
54 | |
55 ExpectTitle("OK"); | |
56 } | |
57 | |
58 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndStop) { | |
59 GURL url(test_server()->GetURL("files/media/getusermedia_and_stop.html")); | |
60 NavigateToURL(shell(), url); | |
61 | |
62 EXPECT_TRUE(ExecuteJavascript("getUserMedia({video: true, audio: true});")); | |
63 | |
64 ExpectTitle("OK"); | |
65 } | |
66 | |
67 // These tests will make a complete PeerConnection-based call and verify that | |
68 // video is playing for the call. | |
69 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CanSetupVideoCall) { | |
70 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); | |
71 NavigateToURL(shell(), url); | |
72 | |
73 EXPECT_TRUE(ExecuteJavascript("call({video: true});")); | |
74 ExpectTitle("OK"); | |
75 } | |
76 | |
77 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CanSetupAudioAndVideoCall) { | |
78 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); | |
79 NavigateToURL(shell(), url); | |
80 | |
81 EXPECT_TRUE(ExecuteJavascript("call({video: true, audio: true});")); | |
82 ExpectTitle("OK"); | |
83 } | |
84 | |
85 } // namespace content | |
86 | |
OLD | NEW |