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

Side by Side Diff: content/browser/webrtc_getusermedia_browsertest.cc

Issue 11428136: Added a basic WebRTC peerconnection browser test with video verification. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "content/browser/web_contents/web_contents_impl.h" 6 #include "content/browser/web_contents/web_contents_impl.h"
7 #include "content/public/test/browser_test_utils.h" 7 #include "content/public/test/browser_test_utils.h"
8 #include "content/shell/shell.h" 8 #include "content/shell/shell.h"
9 #include "content/test/content_browser_test.h" 9 #include "content/test/content_browser_test.h"
10 #include "content/test/content_browser_test_utils.h" 10 #include "content/test/content_browser_test_utils.h"
11 #include "net/test/test_server.h" 11 #include "net/test/test_server.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 // Tests The WebRTC getUserMedia call. 15 // Tests The WebRTC getUserMedia call.
16 // Note: Requires --use-fake-device-for-media-stream (this flag is set by 16 // Note: Requires --use-fake-device-for-media-stream (this flag is set by
17 // default in content_browsertests). 17 // default in content_browsertests).
18 class WebrtcGetUserMediaTest: public ContentBrowserTest { 18 class WebrtcGetUserMediaTest: public ContentBrowserTest {
19 public: 19 public:
20 WebrtcGetUserMediaTest() {} 20 WebrtcGetUserMediaTest() {}
21
22 virtual void SetUp() OVERRIDE {
23 ASSERT_TRUE(test_server()->Start());
24 ContentBrowserTest::SetUp();
25 }
26
27 virtual void TearDown() OVERRIDE {
28 ContentBrowserTest::TearDown();
29 ASSERT_TRUE(test_server()->Stop());
jam 2012/12/03 15:55:54 test_server's destructor already calls Stop(), so
phoglund_chromium 2012/12/03 17:34:51 Done.
30 }
21 protected: 31 protected:
22 void TestGetUserMediaWithConstraints(const std::string& constraints) { 32 bool ExecuteJavascript(const std::string& javascript) {
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 = 33 RenderViewHost* render_view_host =
29 shell()->web_contents()->GetRenderViewHost(); 34 shell()->web_contents()->GetRenderViewHost();
30 35
31 EXPECT_TRUE(ExecuteJavaScript(render_view_host, L"", 36 return ExecuteJavaScript(render_view_host, L"", ASCIIToWide(javascript));
32 ASCIIToWide(constraints)));
33
34 ExpectTitle("OK");
35 } 37 }
36 38
37 void ExpectTitle(const std::string& expected_title) const { 39 void ExpectTitle(const std::string& expected_title) const {
38 string16 expected_title16(ASCIIToUTF16(expected_title)); 40 string16 expected_title16(ASCIIToUTF16(expected_title));
39 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); 41 TitleWatcher title_watcher(shell()->web_contents(), expected_title16);
40 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); 42 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle());
41 } 43 }
42 }; 44 };
43 45
44 // These tests will all make a getUserMedia call with different constraints and 46 // 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 47 // 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. 48 // none of the callbacks are called the tests will simply time out and fail.
47 IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetVideoStreamAndStop) { 49 IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetVideoStreamAndStop) {
phoglund_chromium 2012/12/03 14:25:08 I think this way of organizing the test made a bit
jam 2012/12/03 15:55:54 to me they're both as easy to understand, but if y
phoglund_chromium 2012/12/03 17:34:51 Yeah, I think we will go in a direction where we m
48 TestGetUserMediaWithConstraints("getUserMedia({video: true});"); 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");
49 } 56 }
50 57
51 IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetAudioAndVideoStreamAndStop) { 58 IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetAudioAndVideoStreamAndStop) {
52 TestGetUserMediaWithConstraints("getUserMedia({video: true, audio: true});"); 59 GURL url(test_server()->GetURL("files/media/getusermedia_and_stop.html"));
53 } 60 NavigateToURL(shell(), url);
54 61
55 // TODO(phoglund): enable once we have fake audio device support. 62 EXPECT_TRUE(ExecuteJavascript("getUserMedia({video: true, audio: true});"));
56 IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, DISABLED_GetAudioStreamAndStop) { 63
57 TestGetUserMediaWithConstraints("getUserMedia({audio: true});"); 64 ExpectTitle("OK");
58 } 65 }
59 66
60 } // namespace content 67 } // namespace content
61 68
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698