| 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/platform_file.h" | 8 #include "base/platform_file.h" |
| 9 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/test/trace_event_analyzer.h" |
| 9 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 10 #include "content/public/test/browser_test_utils.h" | 13 #include "content/public/test/browser_test_utils.h" |
| 11 #include "content/shell/browser/shell.h" | 14 #include "content/shell/browser/shell.h" |
| 12 #include "content/test/content_browser_test.h" | |
| 13 #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" |
| 14 #include "net/test/embedded_test_server/embedded_test_server.h" | 17 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 15 | 18 |
| 16 namespace content { | 19 namespace content { |
| 17 | 20 |
| 18 // 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 |
| 19 // 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). |
| 20 class WebrtcAecDumpBrowserTest : public ContentBrowserTest { | 23 class WebRtcAecDumpBrowserTest : public WebRtcContentBrowserTest { |
| 21 public: | 24 public: |
| 22 WebrtcAecDumpBrowserTest() {} | 25 WebRtcAecDumpBrowserTest() {} |
| 23 virtual ~WebrtcAecDumpBrowserTest() {} | 26 virtual ~WebRtcAecDumpBrowserTest() {} |
| 24 | 27 |
| 25 virtual void SetUp() OVERRIDE { | 28 virtual void SetUp() OVERRIDE { |
| 26 // Find a safe place to write the dump to. | 29 // Find a safe place to write the dump to. |
| 27 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 30 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 28 ASSERT_TRUE(CreateTemporaryFileInDir(temp_dir_.path(), &dump_file_)); | 31 ASSERT_TRUE(CreateTemporaryFileInDir(temp_dir_.path(), &dump_file_)); |
| 29 | 32 |
| 30 // These tests expect pixel output. | 33 // These tests expect pixel output. |
| 31 UseRealGLContexts(); | 34 UseRealGLContexts(); |
| 32 | 35 |
| 33 ContentBrowserTest::SetUp(); | 36 ContentBrowserTest::SetUp(); |
| 34 } | 37 } |
| 35 | 38 |
| 36 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 39 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 37 // We need fake devices in this test since we want to run on naked VMs. We | 40 WebRtcContentBrowserTest::SetUpCommandLine(command_line); |
| 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)); | |
| 43 | 41 |
| 44 // Enable AEC dump with the command line flag. | 42 // Enable AEC dump with the command line flag. |
| 45 command_line->AppendSwitchPath(switches::kEnableWebRtcAecRecordings, | 43 command_line->AppendSwitchPath(switches::kEnableWebRtcAecRecordings, |
| 46 dump_file_); | 44 dump_file_); |
| 47 } | 45 } |
| 48 | 46 |
| 49 protected: | 47 protected: |
| 50 bool ExecuteJavascript(const std::string& javascript) { | |
| 51 return ExecuteScript(shell()->web_contents(), javascript); | |
| 52 } | |
| 53 | |
| 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()); | |
| 58 } | |
| 59 | |
| 60 base::ScopedTempDir temp_dir_; | 48 base::ScopedTempDir temp_dir_; |
| 61 base::FilePath dump_file_; | 49 base::FilePath dump_file_; |
| 62 | 50 |
| 63 private: | 51 private: |
| 64 DISALLOW_COPY_AND_ASSIGN(WebrtcAecDumpBrowserTest); | 52 DISALLOW_COPY_AND_ASSIGN(WebRtcAecDumpBrowserTest); |
| 65 }; | 53 }; |
| 66 | 54 |
| 67 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(AR
CH_CPU_ARM_FAMILY)) | 55 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(AR
CH_CPU_ARM_FAMILY)) |
| 68 // Timing out on ARM linux bot: http://crbug.com/238490 | 56 // Timing out on ARM linux bot: http://crbug.com/238490 |
| 69 // Failing on Windows: http://crbug.com/331035 | 57 // Failing on Windows: http://crbug.com/331035 |
| 70 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump | 58 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump |
| 71 #else | 59 #else |
| 72 #define MAYBE_CallWithAecDump CallWithAecDump | 60 #define MAYBE_CallWithAecDump CallWithAecDump |
| 73 #endif | 61 #endif |
| 74 | 62 |
| 75 // This tests will make a complete PeerConnection-based call, verify that | 63 // 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 | 64 // video is playing for the call, and verify that a non-empty AEC dump file |
| 77 // exists. | 65 // exists. |
| 78 IN_PROC_BROWSER_TEST_F(WebrtcAecDumpBrowserTest, MAYBE_CallWithAecDump) { | 66 IN_PROC_BROWSER_TEST_F(WebRtcAecDumpBrowserTest, MAYBE_CallWithAecDump) { |
| 79 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 67 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 80 | 68 |
| 81 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); | 69 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); |
| 82 NavigateToURL(shell(), url); | 70 NavigateToURL(shell(), url); |
| 83 | 71 |
| 84 #if defined (OS_ANDROID) | 72 #if defined (OS_ANDROID) |
| 85 // Always force iSAC 16K on Android for now (Opus is broken). | 73 // Always force iSAC 16K on Android for now (Opus is broken). |
| 86 ASSERT_TRUE(ExecuteJavascript("forceIsac16KInSdp();")); | 74 ASSERT_TRUE(ExecuteJavascript("forceIsac16KInSdp();")); |
| 87 #endif | 75 #endif |
| 88 | 76 |
| 89 EXPECT_TRUE(ExecuteJavascript("call({video: true, audio: true});")); | 77 EXPECT_TRUE(ExecuteJavascript("call({video: true, audio: true});")); |
| 90 ExpectTitle("OK"); | 78 ExpectTitle("OK"); |
| 91 | 79 |
| 92 EXPECT_TRUE(base::PathExists(dump_file_)); | 80 EXPECT_TRUE(base::PathExists(dump_file_)); |
| 93 int64 file_size = 0; | 81 int64 file_size = 0; |
| 94 EXPECT_TRUE(base::GetFileSize(dump_file_, &file_size)); | 82 EXPECT_TRUE(base::GetFileSize(dump_file_, &file_size)); |
| 95 EXPECT_GT(file_size, 0); | 83 EXPECT_GT(file_size, 0); |
| 96 } | 84 } |
| 97 | 85 |
| 98 } // namespace content | 86 } // namespace content |
| OLD | NEW |