1 // Copyright 2014 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.
5 #include "content/test/webrtc_content_browsertest_base.h"
7 #include "base/command_line.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/common/content_switches.h"
11 #include "content/public/test/browser_test_utils.h"
12 #include "content/public/test/content_browser_test_utils.h"
13 #include "content/shell/browser/shell.h"
14 #include "media/base/media_switches.h"
18 void WebRtcContentBrowserTest::SetUpCommandLine(CommandLine
* command_line
) {
19 // We need fake devices in this test since we want to run on naked VMs. We
20 // assume these switches are set by default in content_browsertests.
21 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
22 switches::kUseFakeDeviceForMediaStream
));
23 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
24 switches::kUseFakeUIForMediaStream
));
26 // Always include loopback interface in network list, in case the test device
27 // doesn't have other interfaces available.
28 CommandLine::ForCurrentProcess()->AppendSwitch(
29 switches::kAllowLoopbackInPeerConnection
);
32 void WebRtcContentBrowserTest::SetUp() {
34 ContentBrowserTest::SetUp();
37 // Executes |javascript|. The script is required to use
38 // window.domAutomationController.send to send a string value back to here.
39 std::string
WebRtcContentBrowserTest::ExecuteJavascriptAndReturnResult(
40 const std::string
& javascript
) {
42 EXPECT_TRUE(ExecuteScriptAndExtractString(shell()->web_contents(),
48 void WebRtcContentBrowserTest::ExecuteJavascriptAndWaitForOk(
49 const std::string
& javascript
) {
50 std::string result
= ExecuteJavascriptAndReturnResult(javascript
);
52 printf("From javascript: %s", result
.c_str());
57 std::string
WebRtcContentBrowserTest::GenerateGetUserMediaCall(
58 const char* function_name
,
64 int max_frame_rate
) const {
65 return base::StringPrintf(
66 "%s({video: {mandatory: {minWidth: %d, maxWidth: %d, "
67 "minHeight: %d, maxHeight: %d, minFrameRate: %d, maxFrameRate: %d}, "
78 } // namespace content