Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: content/browser/webrtc/webrtc_audio_debug_recordings_browsertest.cc

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Rebase. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/process/process_handle.h" 7 #include "base/process/process_handle.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "content/browser/web_contents/web_contents_impl.h" 11 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" 12 #include "content/browser/webrtc/webrtc_content_browsertest_base.h"
13 #include "content/browser/webrtc/webrtc_internals.h" 13 #include "content/browser/webrtc/webrtc_internals.h"
14 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
15 #include "content/public/test/content_browser_test_utils.h" 15 #include "content/public/test/content_browser_test_utils.h"
16 #include "content/shell/browser/shell.h" 16 #include "content/shell/browser/shell.h"
17 #include "media/audio/audio_manager.h" 17 #include "media/audio/audio_manager.h"
18 #include "net/test/embedded_test_server/embedded_test_server.h" 18 #include "net/test/embedded_test_server/embedded_test_server.h"
19 19
20 #if defined(OS_WIN) 20 #if defined(OS_WIN)
21 #define IntToStringType base::IntToString16 21 #define IntToStringType base::IntToString16
22 #else 22 #else
23 #define IntToStringType base::IntToString 23 #define IntToStringType base::IntToString
24 #endif 24 #endif
25 25
26 namespace { 26 namespace {
27 27
28 const int kExpectedConsumerId = 1; 28 const int kExpectedConsumerId = 1;
29 const int kExpectedStreamId = 1; 29 const int kExpectedInputStreamId = 1;
30 const int kExpectedFirstOutputStreamId = 1;
31
32 const int kWaveHeaderSizeBytes = 44;
33
34 const char kBaseFilename[] = "audio_debug";
35 const char kWaveExtension[] = "wav";
30 36
31 // Get the ID for the render process host when there should only be one. 37 // Get the ID for the render process host when there should only be one.
32 bool GetRenderProcessHostId(base::ProcessId* id) { 38 bool GetRenderProcessHostId(base::ProcessId* id) {
33 content::RenderProcessHost::iterator it( 39 content::RenderProcessHost::iterator it(
34 content::RenderProcessHost::AllHostsIterator()); 40 content::RenderProcessHost::AllHostsIterator());
35 *id = base::GetProcId(it.GetCurrentValue()->GetHandle()); 41 *id = base::GetProcId(it.GetCurrentValue()->GetHandle());
36 EXPECT_NE(base::kNullProcessId, *id); 42 EXPECT_NE(base::kNullProcessId, *id);
37 if (*id == base::kNullProcessId) 43 if (*id == base::kNullProcessId)
38 return false; 44 return false;
39 it.Advance(); 45 it.Advance();
40 EXPECT_TRUE(it.IsAtEnd()); 46 EXPECT_TRUE(it.IsAtEnd());
41 return it.IsAtEnd(); 47 return it.IsAtEnd();
42 } 48 }
43 49
44 // Get the expected AEC dump file name. The name will be 50 // Get the expected AEC dump file name. The name will be
45 // <temporary path>.<render process id>.aec_dump.<consumer id>, for example 51 // <temporary path>.<render process id>.aec_dump.<consumer id>, for example
46 // "/tmp/.com.google.Chrome.Z6UC3P.12345.aec_dump.1". 52 // "/tmp/.com.google.Chrome.Z6UC3P.12345.aec_dump.1".
47 base::FilePath GetExpectedAecDumpFileName(const base::FilePath& base_file, 53 base::FilePath GetExpectedAecDumpFileName(const base::FilePath& base_file_path,
48 int render_process_id) { 54 int render_process_id) {
49 return base_file.AddExtension(IntToStringType(render_process_id)) 55 return base_file_path.AddExtension(IntToStringType(render_process_id))
50 .AddExtension(FILE_PATH_LITERAL("aec_dump")) 56 .AddExtension(FILE_PATH_LITERAL("aec_dump"))
51 .AddExtension(IntToStringType(kExpectedConsumerId)); 57 .AddExtension(IntToStringType(kExpectedConsumerId));
52 } 58 }
53 59
54 // Get the expected input audio file name. The name will be 60 // Get the expected input audio file name. The name will be
55 // <temporary path>.<render process id>.source_input.<stream id>.pcm, for 61 // <temporary path>.<render process id>.source_input.<stream id>.wav, for
56 // example "/tmp/.com.google.Chrome.Z6UC3P.12345.source_input.1.pcm". 62 // example "/tmp/.com.google.Chrome.Z6UC3P.12345.source_input.1.wav".
57 base::FilePath GetExpectedInputAudioFileName(const base::FilePath& base_file, 63 base::FilePath GetExpectedInputAudioFileName(
58 int render_process_id) { 64 const base::FilePath& base_file_path,
59 return base_file.AddExtension(IntToStringType(render_process_id)) 65 int render_process_id) {
60 .AddExtension(FILE_PATH_LITERAL("source_input")) 66 return base_file_path.AddExtension(IntToStringType(render_process_id))
61 .AddExtension(IntToStringType(kExpectedStreamId)) 67 .AddExtension(FILE_PATH_LITERAL("source_input"))
62 .AddExtension(FILE_PATH_LITERAL("wav")); 68 .AddExtension(IntToStringType(kExpectedInputStreamId))
69 .AddExtension(kWaveExtension);
70 }
71
72 // Get the expected output audio file name. The name will be
73 // <temporary path>.output.<running stream id>.wav, for example
74 // "/tmp/.com.google.Chrome.Z6UC3P.output.1.wav".
75 base::FilePath GetExpectedOutputAudioFileName(
76 const base::FilePath& base_file_path,
77 int id) {
78 return base_file_path.AddExtension(FILE_PATH_LITERAL("output"))
79 .AddExtension(IntToStringType(id))
80 .AddExtension(kWaveExtension);
63 } 81 }
64 82
65 } // namespace 83 } // namespace
66 84
67 namespace content { 85 namespace content {
68 86
69 class WebRtcAudioDebugRecordingsBrowserTest 87 class WebRtcAudioDebugRecordingsBrowserTest
70 : public WebRtcContentBrowserTestBase { 88 : public WebRtcContentBrowserTestBase {
71 public: 89 public:
72 WebRtcAudioDebugRecordingsBrowserTest() { 90 WebRtcAudioDebugRecordingsBrowserTest() {
73 // Automatically grant device permission. 91 // Automatically grant device permission.
74 AppendUseFakeUIForMediaStreamFlag(); 92 AppendUseFakeUIForMediaStreamFlag();
75 } 93 }
76 ~WebRtcAudioDebugRecordingsBrowserTest() override {} 94 ~WebRtcAudioDebugRecordingsBrowserTest() override {}
77 }; 95 };
78 96
79 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 97 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
80 // Timing out on ARM linux bot: http://crbug.com/238490 98 // Timing out on ARM linux bot: http://crbug.com/238490
99 // TODO(grunell): Re-enable for ARM Linux. Bug is closed as fixed.
81 #define MAYBE_CallWithAudioDebugRecordings DISABLED_CallWithAudioDebugRecordings 100 #define MAYBE_CallWithAudioDebugRecordings DISABLED_CallWithAudioDebugRecordings
82 #elif defined(OS_ANDROID) && defined(ADDRESS_SANITIZER) 101 #elif defined(OS_ANDROID) && defined(ADDRESS_SANITIZER)
83 // Renderer crashes under Android ASAN: https://crbug.com/408496. 102 // Renderer crashes under Android ASAN: https://crbug.com/408496.
84 #define MAYBE_CallWithAudioDebugRecordings DISABLED_CallWithAudioDebugRecordings 103 #define MAYBE_CallWithAudioDebugRecordings DISABLED_CallWithAudioDebugRecordings
85 #elif defined(OS_ANDROID) 104 #elif defined(OS_ANDROID)
86 // Renderer crashes on Android M. https://crbug.com/535728. 105 // Renderer crashes on Android M. https://crbug.com/535728.
87 #define MAYBE_CallWithAudioDebugRecordings DISABLED_CallWithAudioDebugRecordings 106 #define MAYBE_CallWithAudioDebugRecordings DISABLED_CallWithAudioDebugRecordings
88 #else 107 #else
89 #define MAYBE_CallWithAudioDebugRecordings CallWithAudioDebugRecordings 108 #define MAYBE_CallWithAudioDebugRecordings CallWithAudioDebugRecordings
90 #endif 109 #endif
91 110
92 // This tests will make a complete PeerConnection-based call, verify that 111 // This tests will make a complete PeerConnection-based call, verify that
93 // video is playing for the call, and verify that a non-empty AEC dump file 112 // video is playing for the call, and verify that non-empty audio debug
94 // exists. The AEC dump is enabled through webrtc-internals. The HTML and 113 // recording files exist. The recording is enabled through webrtc-internals. The
95 // Javascript is bypassed since it would trigger a file picker dialog. Instead, 114 // HTML and Javascript is bypassed since it would trigger a file picker dialog.
96 // the dialog callback FileSelected() is invoked directly. In fact, there's 115 // Instead, the dialog callback FileSelected() is invoked directly. In fact,
97 // never a webrtc-internals page opened at all since that's not needed. 116 // there's never a webrtc-internals page opened at all since that's not needed.
98 IN_PROC_BROWSER_TEST_F(WebRtcAudioDebugRecordingsBrowserTest, 117 IN_PROC_BROWSER_TEST_F(WebRtcAudioDebugRecordingsBrowserTest,
99 MAYBE_CallWithAudioDebugRecordings) { 118 MAYBE_CallWithAudioDebugRecordings) {
100 bool prev = base::ThreadRestrictions::SetIOAllowed(true);
101 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { 119 if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
102 LOG(INFO) << "Missing output devices: skipping test..."; 120 LOG(INFO) << "Missing output devices: skipping test...";
103 return; 121 return;
104 } 122 }
105 123
124 bool prev_io_allowed = base::ThreadRestrictions::SetIOAllowed(true);
125
106 ASSERT_TRUE(embedded_test_server()->Start()); 126 ASSERT_TRUE(embedded_test_server()->Start());
107 127
108 // We must navigate somewhere first so that the render process is created. 128 // We must navigate somewhere first so that the render process is created.
109 NavigateToURL(shell(), GURL("")); 129 NavigateToURL(shell(), GURL(""));
110 130
111 base::FilePath base_file; 131 // Create a temp directory and setup base file path.
112 ASSERT_TRUE(CreateTemporaryFile(&base_file)); 132 base::FilePath temp_dir_path;
113 base::DeleteFile(base_file, false); 133 ASSERT_TRUE(
134 CreateNewTempDirectory(base::FilePath::StringType(), &temp_dir_path));
135 base::FilePath base_file_path = temp_dir_path.Append(kBaseFilename);
114 136
115 // This fakes the behavior of another open tab with webrtc-internals, and 137 // This fakes the behavior of another open tab with webrtc-internals, and
116 // enabling AEC dump in that tab. 138 // enabling audio debug recordings in that tab.
117 WebRTCInternals::GetInstance()->FileSelected(base_file, -1, NULL); 139 WebRTCInternals::GetInstance()->FileSelected(base_file_path, -1, NULL);
118 140
141 // Make a call.
119 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); 142 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
120 NavigateToURL(shell(), url); 143 NavigateToURL(shell(), url);
121 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});"); 144 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
122 145
123 EXPECT_FALSE(base::PathExists(base_file));
124
125 // Verify that the expected AEC dump file exists and contains some data. 146 // Verify that the expected AEC dump file exists and contains some data.
126 base::ProcessId render_process_id = base::kNullProcessId; 147 base::ProcessId render_process_id = base::kNullProcessId;
127 EXPECT_TRUE(GetRenderProcessHostId(&render_process_id)); 148 EXPECT_TRUE(GetRenderProcessHostId(&render_process_id));
128 base::FilePath aec_dump_file = GetExpectedAecDumpFileName(base_file, 149 base::FilePath file_path =
129 render_process_id); 150 GetExpectedAecDumpFileName(base_file_path, render_process_id);
130 151 EXPECT_TRUE(base::PathExists(file_path));
131 EXPECT_TRUE(base::PathExists(aec_dump_file));
132 int64_t file_size = 0; 152 int64_t file_size = 0;
133 EXPECT_TRUE(base::GetFileSize(aec_dump_file, &file_size)); 153 EXPECT_TRUE(base::GetFileSize(file_path, &file_size));
134 EXPECT_GT(file_size, 0); 154 EXPECT_GT(file_size, 0);
135 155 EXPECT_TRUE(base::DeleteFile(file_path, false));
136 base::DeleteFile(aec_dump_file, false);
137 156
138 // Verify that the expected input audio file exists and contains some data. 157 // Verify that the expected input audio file exists and contains some data.
139 base::FilePath input_audio_file = 158 file_path = GetExpectedInputAudioFileName(base_file_path, render_process_id);
140 GetExpectedInputAudioFileName(base_file, render_process_id); 159 EXPECT_TRUE(base::PathExists(file_path));
160 file_size = 0;
161 EXPECT_TRUE(base::GetFileSize(file_path, &file_size));
162 EXPECT_GT(file_size, kWaveHeaderSizeBytes);
163 EXPECT_TRUE(base::DeleteFile(file_path, false));
141 164
142 EXPECT_TRUE(base::PathExists(input_audio_file)); 165 // Verify that the expected output audio files exists and contains some data.
143 file_size = 0; 166 // Two files are expected, one for each peer in the call.
144 EXPECT_TRUE(base::GetFileSize(input_audio_file, &file_size)); 167 for (int i = 0; i < 2; ++i) {
145 EXPECT_GT(file_size, 0); 168 file_path = GetExpectedOutputAudioFileName(
169 base_file_path, kExpectedFirstOutputStreamId + i);
170 EXPECT_TRUE(base::PathExists(file_path));
171 file_size = 0;
172 EXPECT_TRUE(base::GetFileSize(file_path, &file_size));
173 EXPECT_GT(file_size, kWaveHeaderSizeBytes);
174 EXPECT_TRUE(base::DeleteFile(file_path, false));
175 }
146 176
147 base::DeleteFile(input_audio_file, false); 177 // Verify that no other files exist and remove temp dir.
148 base::ThreadRestrictions::SetIOAllowed(prev); 178 EXPECT_TRUE(base::IsDirectoryEmpty(temp_dir_path));
179 EXPECT_TRUE(base::DeleteFile(temp_dir_path, false));
180
181 base::ThreadRestrictions::SetIOAllowed(prev_io_allowed);
149 } 182 }
150 183
151 // TODO(grunell): Add test for multiple dumps when re-use of 184 // TODO(grunell): Add test for multiple dumps when re-use of
152 // MediaStreamAudioProcessor in AudioCapturer has been removed. 185 // MediaStreamAudioProcessor in AudioCapturer has been removed.
153 186
154 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 187 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
155 // Timing out on ARM linux bot: http://crbug.com/238490 188 // Timing out on ARM linux bot: http://crbug.com/238490
189 // TODO(grunell): Re-enable for ARM Linux. Bug is closed as fixed.
156 #define MAYBE_CallWithAudioDebugRecordingsEnabledThenDisabled DISABLED_CallWithA udioDebugRecordingsEnabledThenDisabled 190 #define MAYBE_CallWithAudioDebugRecordingsEnabledThenDisabled DISABLED_CallWithA udioDebugRecordingsEnabledThenDisabled
157 #elif defined(OS_ANDROID) && defined(ADDRESS_SANITIZER) 191 #elif defined(OS_ANDROID) && defined(ADDRESS_SANITIZER)
158 // Renderer crashes under Android ASAN: https://crbug.com/408496. 192 // Renderer crashes under Android ASAN: https://crbug.com/408496.
159 #define MAYBE_CallWithAudioDebugRecordingsEnabledThenDisabled DISABLED_CallWithA udioDebugRecordingsEnabledThenDisabled 193 #define MAYBE_CallWithAudioDebugRecordingsEnabledThenDisabled DISABLED_CallWithA udioDebugRecordingsEnabledThenDisabled
160 #else 194 #else
161 #define MAYBE_CallWithAudioDebugRecordingsEnabledThenDisabled CallWithAudioDebug RecordingsEnabledThenDisabled 195 #define MAYBE_CallWithAudioDebugRecordingsEnabledThenDisabled CallWithAudioDebug RecordingsEnabledThenDisabled
162 #endif 196 #endif
163 197
164 // As above, but enable and disable dump before starting a call. The file should 198 // As above, but enable and disable recordings before starting a call. No files
165 // be created, but should be empty. 199 // should be created.
166 IN_PROC_BROWSER_TEST_F(WebRtcAudioDebugRecordingsBrowserTest, 200 IN_PROC_BROWSER_TEST_F(WebRtcAudioDebugRecordingsBrowserTest,
167 MAYBE_CallWithAudioDebugRecordingsEnabledThenDisabled) { 201 MAYBE_CallWithAudioDebugRecordingsEnabledThenDisabled) {
168 bool prev = base::ThreadRestrictions::SetIOAllowed(true);
169 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { 202 if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
170 LOG(INFO) << "Missing output devices: skipping test..."; 203 LOG(INFO) << "Missing output devices: skipping test...";
171 return; 204 return;
172 } 205 }
173 206
207 bool prev_io_allowed = base::ThreadRestrictions::SetIOAllowed(true);
208
174 ASSERT_TRUE(embedded_test_server()->Start()); 209 ASSERT_TRUE(embedded_test_server()->Start());
175 210
176 // We must navigate somewhere first so that the render process is created. 211 // We must navigate somewhere first so that the render process is created.
177 NavigateToURL(shell(), GURL("")); 212 NavigateToURL(shell(), GURL(""));
178 213
179 base::FilePath base_file; 214 // Create a temp directory and setup base file path.
180 ASSERT_TRUE(CreateTemporaryFile(&base_file)); 215 base::FilePath temp_dir_path;
181 base::DeleteFile(base_file, false); 216 ASSERT_TRUE(
217 CreateNewTempDirectory(base::FilePath::StringType(), &temp_dir_path));
218 base::FilePath base_file_path = temp_dir_path.Append(kBaseFilename);
182 219
183 // This fakes the behavior of another open tab with webrtc-internals, and 220 // This fakes the behavior of another open tab with webrtc-internals, and
184 // enabling AEC dump in that tab, then disabling it. 221 // enabling audio debug recordings in that tab, then disabling it.
185 WebRTCInternals::GetInstance()->FileSelected(base_file, -1, NULL); 222 WebRTCInternals::GetInstance()->FileSelected(base_file_path, -1, NULL);
186 WebRTCInternals::GetInstance()->DisableAudioDebugRecordings(); 223 WebRTCInternals::GetInstance()->DisableAudioDebugRecordings();
187 224
225 // Make a call.
188 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); 226 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
189 NavigateToURL(shell(), url); 227 NavigateToURL(shell(), url);
190 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});"); 228 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
191 229
192 // Verify that the expected AEC dump file doesn't exist. 230 // Verify that no files exist and remove temp dir.
193 base::ProcessId render_process_id = base::kNullProcessId; 231 EXPECT_TRUE(base::IsDirectoryEmpty(temp_dir_path));
194 EXPECT_TRUE(GetRenderProcessHostId(&render_process_id)); 232 EXPECT_TRUE(base::DeleteFile(temp_dir_path, false));
195 base::FilePath aec_dump_file = GetExpectedAecDumpFileName(base_file,
196 render_process_id);
197 EXPECT_FALSE(base::PathExists(aec_dump_file));
198 base::DeleteFile(aec_dump_file, false);
199 233
200 // Verify that the expected input audio file doesn't exist. 234 base::ThreadRestrictions::SetIOAllowed(prev_io_allowed);
201 base::FilePath input_audio_file =
202 GetExpectedInputAudioFileName(base_file, render_process_id);
203 EXPECT_FALSE(base::PathExists(input_audio_file));
204 base::DeleteFile(input_audio_file, false);
205 base::ThreadRestrictions::SetIOAllowed(prev);
206 } 235 }
207 236
208 // Timing out on ARM linux bot: http://crbug.com/238490 237 // Timing out on ARM linux bot: http://crbug.com/238490
209 // Renderer crashes under Android ASAN: https://crbug.com/408496. 238 // Renderer crashes under Android ASAN: https://crbug.com/408496.
239 // TODO(grunell): Re-enable on all but Android ASAN. ARM Linux bug is closed
240 // as fixed. See conditions for the above two tests.
210 IN_PROC_BROWSER_TEST_F(WebRtcAudioDebugRecordingsBrowserTest, 241 IN_PROC_BROWSER_TEST_F(WebRtcAudioDebugRecordingsBrowserTest,
211 DISABLED_TwoCallsWithAudioDebugRecordings) { 242 DISABLED_TwoCallsWithAudioDebugRecordings) {
212 bool prev = base::ThreadRestrictions::SetIOAllowed(true);
213 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { 243 if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
214 LOG(INFO) << "Missing output devices: skipping test..."; 244 LOG(INFO) << "Missing output devices: skipping test...";
215 return; 245 return;
216 } 246 }
217 247
248 bool prev_io_allowed = base::ThreadRestrictions::SetIOAllowed(true);
249
218 ASSERT_TRUE(embedded_test_server()->Start()); 250 ASSERT_TRUE(embedded_test_server()->Start());
219 251
220 // We must navigate somewhere first so that the render process is created. 252 // We must navigate somewhere first so that the render process is created.
221 NavigateToURL(shell(), GURL("")); 253 NavigateToURL(shell(), GURL(""));
222 254
223 // Create a second window. 255 // Create a second window.
224 Shell* shell2 = CreateBrowser(); 256 Shell* shell2 = CreateBrowser();
225 NavigateToURL(shell2, GURL("")); 257 NavigateToURL(shell2, GURL(""));
226 258
227 base::FilePath base_file; 259 // Create a temp directory and setup base file path.
228 ASSERT_TRUE(CreateTemporaryFile(&base_file)); 260 base::FilePath temp_dir_path;
229 base::DeleteFile(base_file, false); 261 ASSERT_TRUE(
262 CreateNewTempDirectory(base::FilePath::StringType(), &temp_dir_path));
263 base::FilePath base_file_path = temp_dir_path.Append(kBaseFilename);
230 264
231 // This fakes the behavior of another open tab with webrtc-internals, and 265 // This fakes the behavior of another open tab with webrtc-internals, and
232 // enabling AEC dump in that tab. 266 // enabling audio debug recordings in that tab.
233 WebRTCInternals::GetInstance()->FileSelected(base_file, -1, NULL); 267 WebRTCInternals::GetInstance()->FileSelected(base_file_path, -1, NULL);
234 268
269 // Make the calls.
235 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); 270 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
236
237 NavigateToURL(shell(), url); 271 NavigateToURL(shell(), url);
238 NavigateToURL(shell2, url); 272 NavigateToURL(shell2, url);
239 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});"); 273 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
240 std::string result; 274 std::string result;
241 EXPECT_TRUE(ExecuteScriptAndExtractString( 275 EXPECT_TRUE(ExecuteScriptAndExtractString(
242 shell2, "call({video: true, audio: true});", &result)); 276 shell2, "call({video: true, audio: true});", &result));
243 ASSERT_STREQ("OK", result.c_str()); 277 ASSERT_STREQ("OK", result.c_str());
244 278
245 EXPECT_FALSE(base::PathExists(base_file));
246
247 RenderProcessHost::iterator it = 279 RenderProcessHost::iterator it =
248 content::RenderProcessHost::AllHostsIterator(); 280 content::RenderProcessHost::AllHostsIterator();
281 base::FilePath file_path;
282 int64_t file_size = 0;
249 283
250 for (; !it.IsAtEnd(); it.Advance()) { 284 for (; !it.IsAtEnd(); it.Advance()) {
251 base::ProcessId render_process_id = 285 base::ProcessId render_process_id =
252 base::GetProcId(it.GetCurrentValue()->GetHandle()); 286 base::GetProcId(it.GetCurrentValue()->GetHandle());
253 EXPECT_NE(base::kNullProcessId, render_process_id); 287 EXPECT_NE(base::kNullProcessId, render_process_id);
254 288
255 // Verify that the expected AEC dump file exists and contains some data. 289 // Verify that the expected AEC dump file exists and contains some data.
256 base::FilePath aec_dump_file = 290 file_path = GetExpectedAecDumpFileName(base_file_path, render_process_id);
257 GetExpectedAecDumpFileName(base_file, render_process_id); 291 EXPECT_TRUE(base::PathExists(file_path));
258 292 file_size = 0;
259 EXPECT_TRUE(base::PathExists(aec_dump_file)); 293 EXPECT_TRUE(base::GetFileSize(file_path, &file_size));
260 int64_t file_size = 0;
261 EXPECT_TRUE(base::GetFileSize(aec_dump_file, &file_size));
262 EXPECT_GT(file_size, 0); 294 EXPECT_GT(file_size, 0);
263 295 EXPECT_TRUE(base::DeleteFile(file_path, false));
264 base::DeleteFile(aec_dump_file, false);
265 296
266 // Verify that the expected input audio file exists and contains some data. 297 // Verify that the expected input audio file exists and contains some data.
267 base::FilePath input_audio_file = 298 file_path =
268 GetExpectedInputAudioFileName(base_file, render_process_id); 299 GetExpectedInputAudioFileName(base_file_path, render_process_id);
300 EXPECT_TRUE(base::PathExists(file_path));
301 file_size = 0;
302 EXPECT_TRUE(base::GetFileSize(file_path, &file_size));
303 EXPECT_GT(file_size, kWaveHeaderSizeBytes);
304 EXPECT_TRUE(base::DeleteFile(file_path, false));
305 }
269 306
270 EXPECT_TRUE(base::PathExists(input_audio_file)); 307 // Verify that the expected output audio files exists and contains some data.
308 // Four files are expected, one for each peer in each call. (Two calls * two
309 // peers.)
310 for (int i = 0; i < 4; ++i) {
311 file_path = GetExpectedOutputAudioFileName(
312 base_file_path, kExpectedFirstOutputStreamId + i);
313 EXPECT_TRUE(base::PathExists(file_path));
271 file_size = 0; 314 file_size = 0;
272 EXPECT_TRUE(base::GetFileSize(input_audio_file, &file_size)); 315 EXPECT_TRUE(base::GetFileSize(file_path, &file_size));
273 EXPECT_GT(file_size, 0); 316 EXPECT_GT(file_size, kWaveHeaderSizeBytes);
317 EXPECT_TRUE(base::DeleteFile(file_path, false));
318 }
274 319
275 base::DeleteFile(input_audio_file, false); 320 // Verify that no other files exist and remove temp dir.
276 } 321 EXPECT_TRUE(base::IsDirectoryEmpty(temp_dir_path));
277 base::ThreadRestrictions::SetIOAllowed(prev); 322 EXPECT_TRUE(base::DeleteFile(temp_dir_path, false));
323
324 base::ThreadRestrictions::SetIOAllowed(prev_io_allowed);
278 } 325 }
279 326
280 } // namespace content 327 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698