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

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

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

Powered by Google App Engine
This is Rietveld 408576698