Index: content/browser/webrtc_getusermedia_browsertest.cc |
diff --git a/content/browser/webrtc_getusermedia_browsertest.cc b/content/browser/webrtc_getusermedia_browsertest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1bbb2207d0b25c58589339e7ca87d582cee375b0 |
--- /dev/null |
+++ b/content/browser/webrtc_getusermedia_browsertest.cc |
@@ -0,0 +1,56 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/utf_string_conversions.h" |
perkj_chrome
2012/11/20 14:20:16
Add comment what this file do. What kind of tests
|
+#include "content/browser/web_contents/web_contents_impl.h" |
+#include "content/public/test/browser_test_utils.h" |
+#include "content/shell/shell.h" |
+#include "content/test/content_browser_test.h" |
+#include "content/test/content_browser_test_utils.h" |
+#include "net/test/test_server.h" |
+ |
+namespace content { |
+ |
+// Note: Requires --use-fake-device-for-media-stream (this flag is set by |
+// default in content_browsertests). |
+class WebrtcGetUserMediaTest: public ContentBrowserTest { |
+ public: |
+ WebrtcGetUserMediaTest() {} |
+ protected: |
+ void TestGetUserMediaWithConstraints(const std::string& constraints) { |
+ ASSERT_TRUE(test_server()->Start()); |
+ GURL empty_url(test_server()->GetURL( |
+ "files/webrtc/getusermedia_and_stop.html")); |
+ NavigateToURL(shell(), empty_url); |
+ |
+ RenderViewHost* render_view_host = |
+ shell()->web_contents()->GetRenderViewHost(); |
+ |
+ EXPECT_TRUE(ExecuteJavaScript(render_view_host, L"", |
+ ASCIIToWide(constraints))); |
+ |
+ ExpectTitle("OK"); |
+ } |
+ |
+ void ExpectTitle(const std::string& expected_title) const { |
+ string16 expected_title16(ASCIIToUTF16(expected_title)); |
+ TitleWatcher title_watcher(shell()->web_contents(), expected_title16); |
+ EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
+ } |
+}; |
+ |
+IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetAudioStreamAndStop) { |
perkj_chrome
2012/11/20 14:20:16
Add comment what this test do here and below
|
+ TestGetUserMediaWithConstraints("getUserMedia({audio: true});"); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetVideoStreamAndStop) { |
+ TestGetUserMediaWithConstraints("getUserMedia({video: true});"); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetAudioAndVideoStreamAndStop) { |
+ TestGetUserMediaWithConstraints("getUserMedia({video: true, audio: true});"); |
+} |
+ |
+} // namespace content |
+ |