Infobar material design refresh: bg color
[chromium-blink-merge.git] / content / test / webrtc_content_browsertest_base.cc
blobb01ac5349204fee15fe405c5b89850aacc908b51
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"
18 #endif
20 #if defined(OS_WIN)
21 #include "base/win/windows_version.h"
22 #endif
24 namespace content {
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.
42 EnablePixelOutput();
43 #if defined(OS_CHROMEOS)
44 chromeos::CrasAudioHandler::InitializeForTesting();
45 #endif
46 ContentBrowserTest::SetUp();
49 void WebRtcContentBrowserTest::TearDown() {
50 ContentBrowserTest::TearDown();
51 #if defined(OS_CHROMEOS)
52 chromeos::CrasAudioHandler::Shutdown();
53 #endif
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) {
60 std::string result;
61 EXPECT_TRUE(ExecuteScriptAndExtractString(
62 shell()->web_contents(), javascript, &result))
63 << "Failed to execute javascript " << javascript << ".";
64 return result;
67 void WebRtcContentBrowserTest::ExecuteJavascriptAndWaitForOk(
68 const std::string& javascript) {
69 std::string result = ExecuteJavascriptAndReturnResult(javascript);
70 if (result != "OK") {
71 if (result.empty())
72 result = "(nothing)";
73 printf("From javascript: %s\nWhen executing '%s'\n", result.c_str(),
74 javascript.c_str());
75 FAIL();
79 std::string WebRtcContentBrowserTest::GenerateGetUserMediaCall(
80 const char* function_name,
81 int min_width,
82 int max_width,
83 int min_height,
84 int max_height,
85 int min_frame_rate,
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}, "
90 "optional: []}});",
91 function_name,
92 min_width,
93 max_width,
94 min_height,
95 max_height,
96 min_frame_rate,
97 max_frame_rate);
100 bool WebRtcContentBrowserTest::OnWinXp() const {
101 #if defined(OS_WIN)
102 return base::win::GetVersion() <= base::win::VERSION_XP;
103 #else
104 return false;
105 #endif
108 } // namespace content