Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(790)

Side by Side Diff: content/renderer/media/webrtc_getusermedia_browsertest.cc

Issue 11413065: Adding first WebRTC browser test to content_browsertests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/public/browser/web_contents.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 // Note: Requires --use-fake-device-for-media-stream (this flag is set by
16 // default in content_browsertests).
17 class WebrtcGetUserMediaTest: public ContentBrowserTest {
18 public:
19 WebrtcGetUserMediaTest() {}
20 protected:
21 void TestGetUserMediaWithConstraints(const std::string& constraints) {
22 ASSERT_TRUE(test_server()->Start());
23 GURL empty_url(test_server()->GetURL(
24 "files/webrtc/getusermedia_and_stop.html"));
25 NavigateToURL(shell(), empty_url);
26
27 RenderViewHost* render_view_host =
28 shell()->web_contents()->GetRenderViewHost();
29
30 EXPECT_TRUE(ExecuteJavaScript(render_view_host, L"",
31 ASCIIToWide(constraints)));
32
33 ExpectTitle("OK");
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 IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetAudioStreamAndStop) {
44 TestGetUserMediaWithConstraints("getUserMedia({audio: true});");
45 }
46
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 } // namespace content
56
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698