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

Unified Diff: content/browser/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: Disabled audio-only test for now: need proper fake device support first. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/content_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..04688eb48d788b2c6fe03eeeade065723979396a
--- /dev/null
+++ b/content/browser/webrtc_getusermedia_browsertest.cc
@@ -0,0 +1,61 @@
+// 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"
+#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 {
+
+// Tests The WebRTC getUserMedia call.
+// 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/media/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());
+ }
+};
+
+// These tests will all make a getUserMedia call with different constraints and
+// see that the success callback is called. If the error callback is called or
+// none of the callbacks are called the tests will simply time out and fail.
+IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetVideoStreamAndStop) {
+ TestGetUserMediaWithConstraints("getUserMedia({video: true});");
+}
+
+IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, GetAudioAndVideoStreamAndStop) {
+ TestGetUserMediaWithConstraints("getUserMedia({video: true, audio: true});");
+}
+
+// TODO(phoglund): enable once we have fake audio device support.
+IN_PROC_BROWSER_TEST_F(WebrtcGetUserMediaTest, DISABLED_GetAudioStreamAndStop) {
+ TestGetUserMediaWithConstraints("getUserMedia({audio: true});");
+}
+
+} // namespace content
+
« no previous file with comments | « no previous file | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698