[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / content / test / webrtc_content_browsertest_base.cc
blob5b0df6f59ee87b7e1c9c599907b4aca3f1a3a976
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 namespace content {
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() {
33 EnablePixelOutput();
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) {
41 std::string result;
42 EXPECT_TRUE(ExecuteScriptAndExtractString(shell()->web_contents(),
43 javascript,
44 &result));
45 return result;
48 void WebRtcContentBrowserTest::ExecuteJavascriptAndWaitForOk(
49 const std::string& javascript) {
50 std::string result = ExecuteJavascriptAndReturnResult(javascript);
51 if (result != "OK") {
52 printf("From javascript: %s", result.c_str());
53 FAIL();
57 std::string WebRtcContentBrowserTest::GenerateGetUserMediaCall(
58 const char* function_name,
59 int min_width,
60 int max_width,
61 int min_height,
62 int max_height,
63 int min_frame_rate,
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}, "
68 "optional: []}});",
69 function_name,
70 min_width,
71 max_width,
72 min_height,
73 max_height,
74 min_frame_rate,
75 max_frame_rate);
78 } // namespace content