| 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() {} |
| 26 virtual ~WebRtcAecDumpBrowserTest() {} | 27 virtual ~WebRtcAecDumpBrowserTest() {} |
| 27 | 28 |
| 28 virtual void SetUp() OVERRIDE { | 29 virtual void SetUp() OVERRIDE { |
| 29 // Find a safe place to write the dump to. | 30 // Find a safe place to write the dump to. |
| 30 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 31 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 31 ASSERT_TRUE(CreateTemporaryFileInDir(temp_dir_.path(), &dump_file_)); | 32 ASSERT_TRUE(CreateTemporaryFileInDir(temp_dir_.path(), &dump_file_)); |
| 32 | 33 |
| 33 EnablePixelOutput(); | 34 EnablePixelOutput(); |
| 34 ContentBrowserTest::SetUp(); | 35 ContentBrowserTest::SetUp(); |
| 35 } | 36 } |
| 36 | 37 |
| 37 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 38 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 38 WebRtcContentBrowserTest::SetUpCommandLine(command_line); | 39 WebRtcContentBrowserTest::SetUpCommandLine(command_line); |
| 39 | 40 |
| 40 // Enable AEC dump with the command line flag. | 41 // Enable AEC dump with the command line flag. |
| 41 command_line->AppendSwitchPath(switches::kEnableWebRtcAecRecordings, | 42 command_line->AppendSwitchPath(switches::kEnableWebRtcAecRecordings, |
| 42 dump_file_); | 43 dump_file_); |
| 44 |
| 45 bool enable_audio_track_processing = GetParam(); |
| 46 if (enable_audio_track_processing) |
| 47 command_line->AppendSwitch(switches::kEnableAudioTrackProcessing); |
| 43 } | 48 } |
| 44 | 49 |
| 45 protected: | 50 protected: |
| 46 base::ScopedTempDir temp_dir_; | 51 base::ScopedTempDir temp_dir_; |
| 47 base::FilePath dump_file_; | 52 base::FilePath dump_file_; |
| 48 | 53 |
| 49 private: | 54 private: |
| 50 DISALLOW_COPY_AND_ASSIGN(WebRtcAecDumpBrowserTest); | 55 DISALLOW_COPY_AND_ASSIGN(WebRtcAecDumpBrowserTest); |
| 51 }; | 56 }; |
| 52 | 57 |
| 58 static const bool kRunTestsWithFlag[] = { false, true }; |
| 59 INSTANTIATE_TEST_CASE_P(WebRtcAecDumpBrowserTests, |
| 60 WebRtcAecDumpBrowserTest, |
| 61 testing::ValuesIn(kRunTestsWithFlag)); |
| 62 |
| 53 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 63 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 54 // Timing out on ARM linux bot: http://crbug.com/238490 | 64 // Timing out on ARM linux bot: http://crbug.com/238490 |
| 55 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump | 65 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump |
| 56 #else | 66 #else |
| 57 #define MAYBE_CallWithAecDump CallWithAecDump | 67 #define MAYBE_CallWithAecDump CallWithAecDump |
| 58 #endif | 68 #endif |
| 59 | 69 |
| 60 // This tests will make a complete PeerConnection-based call, verify that | 70 // 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 | 71 // video is playing for the call, and verify that a non-empty AEC dump file |
| 62 // exists. | 72 // exists. |
| 63 IN_PROC_BROWSER_TEST_F(WebRtcAecDumpBrowserTest, MAYBE_CallWithAecDump) { | 73 IN_PROC_BROWSER_TEST_P(WebRtcAecDumpBrowserTest, MAYBE_CallWithAecDump) { |
| 64 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 74 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 65 | 75 |
| 66 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); | 76 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); |
| 67 NavigateToURL(shell(), url); | 77 NavigateToURL(shell(), url); |
| 68 | 78 |
| 69 #if defined (OS_ANDROID) | 79 #if defined (OS_ANDROID) |
| 70 // Always force iSAC 16K on Android for now (Opus is broken). | 80 // Always force iSAC 16K on Android for now (Opus is broken). |
| 71 EXPECT_EQ("isac-forced", | 81 EXPECT_EQ("isac-forced", |
| 72 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();")); | 82 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();")); |
| 73 #endif | 83 #endif |
| 74 | 84 |
| 75 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});"); | 85 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});"); |
| 76 | 86 |
| 77 EXPECT_TRUE(base::PathExists(dump_file_)); | 87 EXPECT_TRUE(base::PathExists(dump_file_)); |
| 78 int64 file_size = 0; | 88 int64 file_size = 0; |
| 79 EXPECT_TRUE(base::GetFileSize(dump_file_, &file_size)); | 89 EXPECT_TRUE(base::GetFileSize(dump_file_, &file_size)); |
| 80 EXPECT_GT(file_size, 0); | 90 EXPECT_GT(file_size, 0); |
| 81 } | 91 } |
| 82 | 92 |
| 83 } // namespace content | 93 } // namespace content |
| OLD | NEW |