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"
16 #if defined(OS_CHROMEOS)
17 #include "chromeos/audio/cras_audio_handler.h"
21 #include "base/win/windows_version.h"
26 void WebRtcContentBrowserTest::SetUpCommandLine(
27 base::CommandLine
* command_line
) {
28 // Assume this is set by the content test launcher.
29 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
30 switches::kUseFakeUIForMediaStream
));
31 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
32 switches::kUseFakeDeviceForMediaStream
));
34 // Always include loopback interface in network list, in case the test device
35 // doesn't have other interfaces available.
36 base::CommandLine::ForCurrentProcess()->AppendSwitch(
37 switches::kAllowLoopbackInPeerConnection
);
40 void WebRtcContentBrowserTest::SetUp() {
41 // We need pixel output when we dig pixels out of video tags for verification.
43 #if defined(OS_CHROMEOS)
44 chromeos::CrasAudioHandler::InitializeForTesting();
46 ContentBrowserTest::SetUp();
49 void WebRtcContentBrowserTest::TearDown() {
50 ContentBrowserTest::TearDown();
51 #if defined(OS_CHROMEOS)
52 chromeos::CrasAudioHandler::Shutdown();
56 // Executes |javascript|. The script is required to use
57 // window.domAutomationController.send to send a string value back to here.
58 std::string
WebRtcContentBrowserTest::ExecuteJavascriptAndReturnResult(
59 const std::string
& javascript
) {
61 EXPECT_TRUE(ExecuteScriptAndExtractString(
62 shell()->web_contents(), javascript
, &result
))
63 << "Failed to execute javascript " << javascript
<< ".";
67 void WebRtcContentBrowserTest::ExecuteJavascriptAndWaitForOk(
68 const std::string
& javascript
) {
69 std::string result
= ExecuteJavascriptAndReturnResult(javascript
);
73 printf("From javascript: %s\nWhen executing '%s'\n", result
.c_str(),
79 std::string
WebRtcContentBrowserTest::GenerateGetUserMediaCall(
80 const char* function_name
,
86 int max_frame_rate
) const {
87 return base::StringPrintf(
88 "%s({video: {mandatory: {minWidth: %d, maxWidth: %d, "
89 "minHeight: %d, maxHeight: %d, minFrameRate: %d, maxFrameRate: %d}, "
100 bool WebRtcContentBrowserTest::OnWinXp() const {
102 return base::win::GetVersion() <= base::win::VERSION_XP
;
108 } // namespace content