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/json/json_reader.h"
8 #include "base/platform_file.h"
9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "base/test/trace_event_analyzer.h"
12 #include "content/public/common/content_switches.h"
13 #include "content/public/test/browser_test_utils.h"
14 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/shell/browser/shell.h"
16 #include "content/test/webrtc_content_browsertest_base.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h"
21 // This tests AEC dump enabled using the command line flag. It does not test AEC
22 // dump enabled using webrtc-internals (that's tested in webrtc_browsertest.cc).
23 class WebRtcAecDumpBrowserTest
: public WebRtcContentBrowserTest
,
24 public testing::WithParamInterface
<bool> {
26 WebRtcAecDumpBrowserTest() {}
27 virtual ~WebRtcAecDumpBrowserTest() {}
29 virtual void SetUp() OVERRIDE
{
30 // Find a safe place to write the dump to.
31 ASSERT_TRUE(temp_dir_
.CreateUniqueTempDir());
32 ASSERT_TRUE(CreateTemporaryFileInDir(temp_dir_
.path(), &dump_file_
));
35 ContentBrowserTest::SetUp();
38 virtual void SetUpCommandLine(CommandLine
* command_line
) OVERRIDE
{
39 WebRtcContentBrowserTest::SetUpCommandLine(command_line
);
41 // Enable AEC dump with the command line flag.
42 command_line
->AppendSwitchPath(switches::kEnableWebRtcAecRecordings
,
45 bool enable_audio_track_processing
= GetParam();
46 if (enable_audio_track_processing
)
47 command_line
->AppendSwitch(switches::kEnableAudioTrackProcessing
);
51 base::ScopedTempDir temp_dir_
;
52 base::FilePath dump_file_
;
55 DISALLOW_COPY_AND_ASSIGN(WebRtcAecDumpBrowserTest
);
58 static const bool kRunTestsWithFlag
[] = { false, true };
59 INSTANTIATE_TEST_CASE_P(WebRtcAecDumpBrowserTests
,
60 WebRtcAecDumpBrowserTest
,
61 testing::ValuesIn(kRunTestsWithFlag
));
63 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
64 // Timing out on ARM linux bot: http://crbug.com/238490
65 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump
67 #define MAYBE_CallWithAecDump CallWithAecDump
70 // This tests will make a complete PeerConnection-based call, verify that
71 // video is playing for the call, and verify that a non-empty AEC dump file
73 IN_PROC_BROWSER_TEST_P(WebRtcAecDumpBrowserTest
, MAYBE_CallWithAecDump
) {
74 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
76 GURL
url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
77 NavigateToURL(shell(), url
);
79 #if defined (OS_ANDROID)
80 // Always force iSAC 16K on Android for now (Opus is broken).
81 EXPECT_EQ("isac-forced",
82 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();"));
85 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
87 EXPECT_TRUE(base::PathExists(dump_file_
));
89 EXPECT_TRUE(base::GetFileSize(dump_file_
, &file_size
));
90 EXPECT_GT(file_size
, 0);
93 } // namespace content