| Index: content/renderer/media/webrtc_getusermedia_browsertest.cc
|
| diff --git a/content/renderer/media/webrtc_getusermedia_browsertest.cc b/content/renderer/media/webrtc_getusermedia_browsertest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..863e860c1dfa57a0225f6c3189f39b69fd07ec97
|
| --- /dev/null
|
| +++ b/content/renderer/media/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"
|
| +#include "content/public/browser/web_contents.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) {
|
| + 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
|
| +
|
|
|