Chromium Code Reviews| Index: content/browser/media/webrtc_aecdump_browsertest.cc |
| diff --git a/content/browser/media/webrtc_aecdump_browsertest.cc b/content/browser/media/webrtc_aecdump_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a89870c8f6601474b5390bb6979cb79fa597ae99 |
| --- /dev/null |
| +++ b/content/browser/media/webrtc_aecdump_browsertest.cc |
| @@ -0,0 +1,93 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/command_line.h" |
| +#include "base/file_util.h" |
| +#include "base/platform_file.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "content/public/common/content_switches.h" |
| +#include "content/public/test/browser_test_utils.h" |
| +#include "content/shell/browser/shell.h" |
| +#include "content/test/content_browser_test.h" |
| +#include "content/test/content_browser_test_utils.h" |
| +#include "net/test/embedded_test_server/embedded_test_server.h" |
| + |
| +namespace content { |
| + |
| +// This tests AEC dump enabled using the command line flag. It does not test AEC |
| +// dump enabled using webrtc-internals (that's tested in webrtc_browsertest.cc). |
| +class WebrtcAecDumpBrowserTest : public ContentBrowserTest { |
| + public: |
| + WebrtcAecDumpBrowserTest() {} |
| + virtual ~WebrtcAecDumpBrowserTest() {} |
| + |
| + virtual void SetUp() OVERRIDE { |
| + // Set up file name. |
|
phoglund_chromium
2013/12/18 14:20:46
You should be able to use https://code.google.com/
Henrik Grunell
2013/12/19 08:43:14
I suppose you mean delete it here; when test is do
phoglund_chromium
2013/12/19 11:57:04
Right, I mean you don't have to delete it here jus
|
| + ASSERT_TRUE(base::GetTempDir(&dump_file_)); |
| + dump_file_ = dump_file_.Append( |
| + base::FilePath(FILE_PATH_LITERAL("audio.aecdump"))); |
| + ASSERT_TRUE(base::DeleteFile(dump_file_, false)); |
| + |
| + ContentBrowserTest::SetUp(); |
| + } |
| + |
| + virtual void TearDown() OVERRIDE { |
| + EXPECT_TRUE(base::DeleteFile(dump_file_, false)); |
| + |
| + ContentBrowserTest::TearDown(); |
| + } |
| + |
| + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| + // We need fake devices in this test since we want to run on naked VMs. We |
| + // assume these switches are set by default in content_browsertests. |
| + ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kUseFakeDeviceForMediaStream)); |
| + ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kUseFakeUIForMediaStream)); |
| + |
| + // Enable AEC dump with the command line flag. |
| + command_line->AppendSwitchPath(switches::kEnableWebRtcAecRecordings, |
| + dump_file_); |
|
phoglund_chromium
2013/12/18 14:20:46
You should have this too:
// The video playba
Henrik Grunell
2013/12/19 08:43:14
Done.
|
| + } |
| + |
| + protected: |
| + bool ExecuteJavascript(const std::string& javascript) { |
| + return ExecuteScript(shell()->web_contents(), javascript); |
| + } |
| + |
| + void ExpectTitle(const std::string& expected_title) const { |
| + base::string16 expected_title16(ASCIIToUTF16(expected_title)); |
| + TitleWatcher title_watcher(shell()->web_contents(), expected_title16); |
| + EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| + } |
| + |
| + base::FilePath dump_file_; |
| +}; |
| + |
| +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| +// Timing out on ARM linux bot: http://crbug.com/238490 |
| +#define MAYBE_CallWithAecDump DISABLED_CallWithAecDump |
| +#else |
| +#define MAYBE_CallWithAecDump CallWithAecDump |
| +#endif |
| + |
| +// This tests will make a complete PeerConnection-based call, verify that |
| +// video is playing for the call, and verify that a non-empty AEC dump file |
| +// exists. |
| +IN_PROC_BROWSER_TEST_F(WebrtcAecDumpBrowserTest, MAYBE_CallWithAecDump) { |
| + ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| + |
| + GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); |
| + NavigateToURL(shell(), url); |
| + |
| + EXPECT_TRUE(ExecuteJavascript("call({video: true, audio: true});")); |
| + ExpectTitle("OK"); |
| + |
| + EXPECT_TRUE(base::PathExists(dump_file_)); |
| + int64 file_size = 0; |
| + EXPECT_TRUE(base::GetFileSize(dump_file_, &file_size)); |
| + EXPECT_GT(file_size, 0); |
| +} |
| + |
| +} // namespace content |