1 // Copyright (c) 2013 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 "base/command_line.h"
6 #include "base/file_util.h"
7 #include "base/platform_file.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/common/content_switches.h"
10 #include "content/public/test/browser_test_utils.h"
11 #include "content/shell/browser/shell.h"
12 #include "content/test/content_browser_test.h"
13 #include "content/test/content_browser_test_utils.h"
14 #include "net/test/embedded_test_server/embedded_test_server.h"
18 // This tests AEC dump enabled using the command line flag. It does not test AEC
19 // dump enabled using webrtc-internals (that's tested in webrtc_browsertest.cc).
20 class WebrtcAecDumpBrowserTest
: public ContentBrowserTest
{
22 WebrtcAecDumpBrowserTest() {}
23 virtual ~WebrtcAecDumpBrowserTest() {}
25 virtual void SetUp() OVERRIDE
{
26 // Find a safe place to write the dump to.
27 ASSERT_TRUE(temp_dir_
.CreateUniqueTempDir());
28 ASSERT_TRUE(CreateTemporaryFileInDir(temp_dir_
.path(), &dump_file_
));
30 // These tests expect pixel output.
33 ContentBrowserTest::SetUp();
36 virtual void SetUpCommandLine(CommandLine
* command_line
) OVERRIDE
{
37 // We need fake devices in this test since we want to run on naked VMs. We
38 // assume these switches are set by default in content_browsertests.
39 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
40 switches::kUseFakeDeviceForMediaStream
));
41 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
42 switches::kUseFakeUIForMediaStream
));
44 // Enable AEC dump with the command line flag.
45 command_line
->AppendSwitchPath(switches::kEnableWebRtcAecRecordings
,
50 bool ExecuteJavascript(const std::string
& javascript
) {
51 return ExecuteScript(shell()->web_contents(), javascript
);
54 void ExpectTitle(const std::string
& expected_title
) const {
55 base::string16
expected_title16(base::ASCIIToUTF16(expected_title
));
56 TitleWatcher
title_watcher(shell()->web_contents(), expected_title16
);
57 EXPECT_EQ(expected_title16
, title_watcher
.WaitAndGetTitle());
60 base::ScopedTempDir temp_dir_
;
61 base::FilePath dump_file_
;
64 DISALLOW_COPY_AND_ASSIGN(WebrtcAecDumpBrowserTest
);
67 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY))
68 // Timing out on ARM linux bot: http://crbug.com/238490
69 // Failing on Windows: http://crbug.com/331035
70 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump
72 #define MAYBE_CallWithAecDump CallWithAecDump
75 // This tests will make a complete PeerConnection-based call, verify that
76 // video is playing for the call, and verify that a non-empty AEC dump file
78 IN_PROC_BROWSER_TEST_F(WebrtcAecDumpBrowserTest
, MAYBE_CallWithAecDump
) {
79 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
81 GURL
url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
82 NavigateToURL(shell(), url
);
84 #if defined (OS_ANDROID)
85 // Always force iSAC 16K on Android for now (Opus is broken).
86 ASSERT_TRUE(ExecuteJavascript("forceIsac16KInSdp();"));
89 EXPECT_TRUE(ExecuteJavascript("call({video: true, audio: true});"));
92 EXPECT_TRUE(base::PathExists(dump_file_
));
94 EXPECT_TRUE(base::GetFileSize(dump_file_
, &file_size
));
95 EXPECT_GT(file_size
, 0);
98 } // namespace content