| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/test/trace_event_analyzer.h" | 11 #include "base/test/trace_event_analyzer.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/public/test/browser_test_utils.h" | 13 #include "content/public/test/browser_test_utils.h" |
| 14 #include "content/shell/browser/shell.h" | 14 #include "content/shell/browser/shell.h" |
| 15 #include "content/test/content_browser_test_utils.h" | 15 #include "content/test/content_browser_test_utils.h" |
| 16 #include "content/test/webrtc_content_browsertest_base.h" | 16 #include "content/test/webrtc_content_browsertest_base.h" |
| 17 #include "net/test/embedded_test_server/embedded_test_server.h" | 17 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 // This tests AEC dump enabled using the command line flag. It does not test AEC | 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). | 22 // dump enabled using webrtc-internals (that's tested in webrtc_browsertest.cc). |
| 23 class WebRtcAecDumpBrowserTest : public WebRtcContentBrowserTest { | 23 class WebRtcAecDumpBrowserTest : public WebRtcContentBrowserTest, |
| 24 public testing::WithParamInterface<bool> { |
| 24 public: | 25 public: |
| 25 WebRtcAecDumpBrowserTest() {} | 26 WebRtcAecDumpBrowserTest() : enable_audio_track_processing_(GetParam()) { |
| 27 } |
| 26 virtual ~WebRtcAecDumpBrowserTest() {} | 28 virtual ~WebRtcAecDumpBrowserTest() {} |
| 27 | 29 |
| 28 virtual void SetUp() OVERRIDE { | 30 virtual void SetUp() OVERRIDE { |
| 29 // Find a safe place to write the dump to. | 31 // Find a safe place to write the dump to. |
| 30 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 32 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 31 ASSERT_TRUE(CreateTemporaryFileInDir(temp_dir_.path(), &dump_file_)); | 33 ASSERT_TRUE(CreateTemporaryFileInDir(temp_dir_.path(), &dump_file_)); |
| 32 | 34 |
| 33 EnablePixelOutput(); | 35 EnablePixelOutput(); |
| 34 ContentBrowserTest::SetUp(); | 36 ContentBrowserTest::SetUp(); |
| 35 } | 37 } |
| 36 | 38 |
| 37 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 39 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 38 WebRtcContentBrowserTest::SetUpCommandLine(command_line); | 40 WebRtcContentBrowserTest::SetUpCommandLine(command_line); |
| 39 | 41 |
| 40 // Enable AEC dump with the command line flag. | 42 // Enable AEC dump with the command line flag. |
| 41 command_line->AppendSwitchPath(switches::kEnableWebRtcAecRecordings, | 43 command_line->AppendSwitchPath(switches::kEnableWebRtcAecRecordings, |
| 42 dump_file_); | 44 dump_file_); |
| 45 |
| 46 if (enable_audio_track_processing_) { |
| 47 command_line->AppendSwitch(switches::kEnableAudioTrackProcessing); |
| 48 } |
| 43 } | 49 } |
| 44 | 50 |
| 45 protected: | 51 protected: |
| 46 base::ScopedTempDir temp_dir_; | 52 base::ScopedTempDir temp_dir_; |
| 47 base::FilePath dump_file_; | 53 base::FilePath dump_file_; |
| 48 | 54 |
| 49 private: | 55 private: |
| 56 bool enable_audio_track_processing_; |
| 50 DISALLOW_COPY_AND_ASSIGN(WebRtcAecDumpBrowserTest); | 57 DISALLOW_COPY_AND_ASSIGN(WebRtcAecDumpBrowserTest); |
| 51 }; | 58 }; |
| 52 | 59 |
| 60 static const bool kRunTestsWithFlag[] = { false, true }; |
| 61 INSTANTIATE_TEST_CASE_P(WebRtcAecDumpBrowserTests, |
| 62 WebRtcAecDumpBrowserTest, |
| 63 testing::ValuesIn(kRunTestsWithFlag)); |
| 64 |
| 53 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 65 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 54 // Timing out on ARM linux bot: http://crbug.com/238490 | 66 // Timing out on ARM linux bot: http://crbug.com/238490 |
| 55 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump | 67 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump |
| 56 #else | 68 #else |
| 57 #define MAYBE_CallWithAecDump CallWithAecDump | 69 #define MAYBE_CallWithAecDump CallWithAecDump |
| 58 #endif | 70 #endif |
| 59 | 71 |
| 60 // This tests will make a complete PeerConnection-based call, verify that | 72 // This tests will make a complete PeerConnection-based call, verify that |
| 61 // video is playing for the call, and verify that a non-empty AEC dump file | 73 // video is playing for the call, and verify that a non-empty AEC dump file |
| 62 // exists. | 74 // exists. |
| 63 IN_PROC_BROWSER_TEST_F(WebRtcAecDumpBrowserTest, MAYBE_CallWithAecDump) { | 75 IN_PROC_BROWSER_TEST_P(WebRtcAecDumpBrowserTest, MAYBE_CallWithAecDump) { |
| 64 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 76 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 65 | 77 |
| 66 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); | 78 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); |
| 67 NavigateToURL(shell(), url); | 79 NavigateToURL(shell(), url); |
| 68 | 80 |
| 69 #if defined (OS_ANDROID) | 81 #if defined (OS_ANDROID) |
| 70 // Always force iSAC 16K on Android for now (Opus is broken). | 82 // Always force iSAC 16K on Android for now (Opus is broken). |
| 71 EXPECT_EQ("isac-forced", | 83 EXPECT_EQ("isac-forced", |
| 72 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();")); | 84 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();")); |
| 73 #endif | 85 #endif |
| 74 | 86 |
| 75 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});"); | 87 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});"); |
| 76 | 88 |
| 77 EXPECT_TRUE(base::PathExists(dump_file_)); | 89 EXPECT_TRUE(base::PathExists(dump_file_)); |
| 78 int64 file_size = 0; | 90 int64 file_size = 0; |
| 79 EXPECT_TRUE(base::GetFileSize(dump_file_, &file_size)); | 91 EXPECT_TRUE(base::GetFileSize(dump_file_, &file_size)); |
| 80 EXPECT_GT(file_size, 0); | 92 EXPECT_GT(file_size, 0); |
| 81 } | 93 } |
| 82 | 94 |
| 83 } // namespace content | 95 } // namespace content |
| OLD | NEW |