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/utf_string_conversions.h" | |
6 #include "content/browser/web_contents/web_contents_impl.h" | |
7 #include "content/public/test/browser_test_utils.h" | |
8 #include "content/shell/shell.h" | |
9 #include "content/test/content_browser_test.h" | |
10 #include "content/test/content_browser_test_utils.h" | |
11 #include "net/test/test_server.h" | |
12 | |
13 namespace content { | |
14 | |
15 // Tests The WebRTC getUserMedia call. | |
16 // Note: Requires --use-fake-device-for-media-stream (this flag is set by | |
17 // default in content_browsertests). | |
18 class WebrtcGetUserMediaTest: public ContentBrowserTest { | |
19 public: | |
20 WebrtcGetUserMediaTest() {} | |
21 protected: | |
22 void TestGetUserMediaWithConstraints(const std::string& constraints) { | |
23 ASSERT_TRUE(test_server()->Start()); | |
24 GURL empty_url(test_server()->GetURL( | |
25 "files/media/getusermedia_and_stop.html")); | |
26 NavigateToURL(shell(), empty_url); | |
27 | |
28 RenderViewHost* render_view_host = | |
29 shell()->web_contents()->GetRenderViewHost(); | |
30 | |
31 EXPECT_TRUE(ExecuteJavaScript(render_view_host, L"", | |
32 ASCIIToWide(constraints))); | |
33 | |
34 ExpectTitle("OK"); | |
35 } | |
36 | |
37 void ExpectTitle(const std::string& expected_title) const { | |
38 string16 expected_title16(ASCIIToUTF16(expected_title)); | |
39 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); | |
40 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | |
41 } | |
42 }; | |
43 | |
44 // These tests will all make a getUserMedia call with different constraints and | |
45 // see that the success callback is called. If the error callback is called or | |
46 // none of the callbacks are called the tests will simply time out and fail. | |
47 IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetVideoStreamAndStop) { | |
48 TestGetUserMediaWithConstraints("getUserMedia({video: true});"); | |
49 } | |
50 | |
51 IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetAudioAndVideoStreamAndStop) { | |
52 TestGetUserMediaWithConstraints("getUserMedia({video: true, audio: true});"); | |
53 } | |
54 | |
55 // TODO(phoglund): enable once we have fake audio device support. | |
56 IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, DISABLED_GetAudioStreamAndStop) { | |
57 TestGetUserMediaWithConstraints("getUserMedia({audio: true});"); | |
58 } | |
59 | |
60 } // namespace content | |
61 | |
OLD | NEW |