1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/file_util.h"
7 #include "base/process/process_handle.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h"
10 #include "base/threading/platform_thread.h"
11 #include "base/values.h"
12 #include "content/browser/media/webrtc_internals.h"
13 #include "content/browser/web_contents/web_contents_impl.h"
14 #include "content/public/common/content_switches.h"
15 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/content_browser_test_utils.h"
17 #include "content/public/test/test_utils.h"
18 #include "content/shell/browser/shell.h"
19 #include "content/test/webrtc_content_browsertest_base.h"
20 #include "media/audio/audio_manager.h"
21 #include "media/base/media_switches.h"
22 #include "net/test/embedded_test_server/embedded_test_server.h"
25 #include "base/win/windows_version.h"
30 #if defined (OS_ANDROID) || defined(THREAD_SANITIZER)
31 // Just do the bare minimum of audio checking on Android and under TSAN since
32 // it's a bit sensitive to device performance.
33 const char kUseLenientAudioChecking
[] = "true";
35 const char kUseLenientAudioChecking
[] = "false";
38 const int kExpectedConsumerId
= 0;
40 // Get the ID for the render process host when there should only be one.
41 bool GetRenderProcessHostId(base::ProcessId
* id
) {
42 content::RenderProcessHost::iterator
it(
43 content::RenderProcessHost::AllHostsIterator());
44 *id
= base::GetProcId(it
.GetCurrentValue()->GetHandle());
45 EXPECT_NE(base::kNullProcessId
, *id
);
46 if (*id
== base::kNullProcessId
)
49 EXPECT_TRUE(it
.IsAtEnd());
57 class WebRtcBrowserTest
: public WebRtcContentBrowserTest
{
59 WebRtcBrowserTest() {}
60 virtual ~WebRtcBrowserTest() {}
62 // Convenience function since most peerconnection-call.html tests just load
63 // the page, kick off some javascript and wait for the title to change to OK.
64 void MakeTypicalPeerConnectionCall(const std::string
& javascript
) {
65 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
67 GURL
url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
68 NavigateToURL(shell(), url
);
70 DisableOpusIfOnAndroid();
71 ExecuteJavascriptAndWaitForOk(javascript
);
74 // Convenience method for making calls that detect if audio os playing (which
75 // has some special prerequisites, such that there needs to be an audio output
76 // device on the executing machine).
77 void MakeAudioDetectingPeerConnectionCall(const std::string
& javascript
) {
78 if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
79 // Bots with no output devices will force the audio code into a state
80 // where it doesn't manage to set either the low or high latency path.
81 // This test will compute useless values in that case, so skip running on
82 // such bots (see crbug.com/326338).
83 LOG(INFO
) << "Missing output devices: skipping test...";
87 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
88 switches::kUseFakeDeviceForMediaStream
))
89 << "Must run with fake devices since the test will explicitly look "
90 << "for the fake device signal.";
92 MakeTypicalPeerConnectionCall(javascript
);
95 void DisableOpusIfOnAndroid() {
96 #if defined(OS_ANDROID)
97 // Always force iSAC 16K on Android for now (Opus is broken).
98 EXPECT_EQ("isac-forced",
99 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();"));
104 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
105 // Timing out on ARM linux bot: http://crbug.com/238490
106 #define MAYBE_CanSetupDefaultVideoCall DISABLED_CanSetupDefaultVideoCall
107 // Flaky on TSAN v2. http://crbug.com/408006
108 #elif defined(THREAD_SANITIZER)
109 #define MAYBE_CanSetupDefaultVideoCall DISABLED_CanSetupDefaultVideoCall
111 #define MAYBE_CanSetupDefaultVideoCall CanSetupDefaultVideoCall
114 // These tests will make a complete PeerConnection-based call and verify that
115 // video is playing for the call.
116 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MAYBE_CanSetupDefaultVideoCall
) {
117 MakeTypicalPeerConnectionCall(
118 "callAndExpectResolution({video: true}, 640, 480);");
121 // Flaky on TSAN v2. http://crbug.com/408006
122 #if defined(THREAD_SANITIZER)
123 #define MAYBE_CanSetupVideoCallWith1To1AspectRatio \
124 DISABLED_CanSetupVideoCallWith1To1AspectRatio
126 #define MAYBE_CanSetupVideoCallWith1To1AspectRatio \
127 CanSetupVideoCallWith1To1AspectRatio
129 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
130 MAYBE_CanSetupVideoCallWith1To1AspectRatio
) {
131 const std::string javascript
=
132 "callAndExpectResolution({video: {mandatory: {minWidth: 320,"
133 " maxWidth: 320, minHeight: 320, maxHeight: 320}}}, 320, 320);";
134 MakeTypicalPeerConnectionCall(javascript
);
137 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARM64)
138 // Failing on ARM64 Android bot: http://crbug.com/408179
139 #define MAYBE_CanSetupVideoCallWith16To9AspectRatio \
140 DISABLED_CanSetupVideoCallWith16To9AspectRatio
141 // Flaky on TSAN v2. http://crbug.com/408006
142 #elif defined(THREAD_SANITIZER)
143 #define MAYBE_CanSetupVideoCallWith16To9AspectRatio \
144 DISABLED_CanSetupVideoCallWith16To9AspectRatio
146 #define MAYBE_CanSetupVideoCallWith16To9AspectRatio \
147 CanSetupVideoCallWith16To9AspectRatio
149 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
150 MAYBE_CanSetupVideoCallWith16To9AspectRatio
) {
151 const std::string javascript
=
152 "callAndExpectResolution({video: {mandatory: {minWidth: 640,"
153 " maxWidth: 640, minAspectRatio: 1.777}}}, 640, 360);";
154 MakeTypicalPeerConnectionCall(javascript
);
157 // Flaky on TSAN v2. http://crbug.com/408006
158 #if defined(THREAD_SANITIZER)
159 #define MAYBE_CanSetupVideoCallWith4To3AspectRatio \
160 DISABLED_CanSetupVideoCallWith4To3AspectRatio
162 #define MAYBE_CanSetupVideoCallWith4To3AspectRatio \
163 CanSetupVideoCallWith4To3AspectRatio
165 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
166 MAYBE_CanSetupVideoCallWith4To3AspectRatio
) {
167 const std::string javascript
=
168 "callAndExpectResolution({video: {mandatory: {minWidth: 960,"
169 "maxAspectRatio: 1.333}}}, 960, 720);";
170 MakeTypicalPeerConnectionCall(javascript
);
173 // Flaky on TSAN v2. http://crbug.com/408006
174 #if defined(THREAD_SANITIZER)
175 #define MAYBE_CanSetupVideoCallAndDisableLocalVideo \
176 DISABLED_CanSetupVideoCallAndDisableLocalVideo
178 #define MAYBE_CanSetupVideoCallAndDisableLocalVideo \
179 CanSetupVideoCallAndDisableLocalVideo
181 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
182 MAYBE_CanSetupVideoCallAndDisableLocalVideo
) {
183 const std::string javascript
=
184 "callAndDisableLocalVideo({video: true});";
185 MakeTypicalPeerConnectionCall(javascript
);
188 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
189 // Timing out on ARM linux, see http://crbug.com/240376
190 #define MAYBE_CanSetupAudioAndVideoCall DISABLED_CanSetupAudioAndVideoCall
192 #define MAYBE_CanSetupAudioAndVideoCall CanSetupAudioAndVideoCall
195 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MAYBE_CanSetupAudioAndVideoCall
) {
196 MakeTypicalPeerConnectionCall("call({video: true, audio: true});");
199 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MANUAL_CanSetupCallAndSendDtmf
) {
200 MakeTypicalPeerConnectionCall("callAndSendDtmf(\'123,abc\');");
203 // TODO(phoglund): this test fails because the peer connection state will be
204 // stable in the second negotiation round rather than have-local-offer.
205 // http://crbug.com/293125.
206 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
207 DISABLED_CanMakeEmptyCallThenAddStreamsAndRenegotiate
) {
208 const char* kJavascript
=
209 "callEmptyThenAddOneStreamAndRenegotiate({video: true, audio: true});";
210 MakeTypicalPeerConnectionCall(kJavascript
);
213 // Below 2 test will make a complete PeerConnection-based call between pc1 and
214 // pc2, and then use the remote stream to setup a call between pc3 and pc4, and
215 // then verify that video is received on pc3 and pc4.
216 // The stream sent from pc3 to pc4 is the stream received on pc1.
217 // The stream sent from pc4 to pc3 is cloned from stream the stream received
219 // Flaky on win xp. http://crbug.com/304775
221 #define MAYBE_CanForwardRemoteStream DISABLED_CanForwardRemoteStream
222 #define MAYBE_CanForwardRemoteStream720p DISABLED_CanForwardRemoteStream720p
224 #define MAYBE_CanForwardRemoteStream CanForwardRemoteStream
225 // Flaky on TSAN v2. http://crbug.com/373637
226 #if defined(THREAD_SANITIZER)
227 #define MAYBE_CanForwardRemoteStream720p DISABLED_CanForwardRemoteStream720p
229 #define MAYBE_CanForwardRemoteStream720p CanForwardRemoteStream720p
232 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MAYBE_CanForwardRemoteStream
) {
233 #if defined (OS_ANDROID)
234 // This test fails on Nexus 5 devices.
235 // TODO(henrika): see http://crbug.com/362437 and http://crbug.com/359389
237 base::CommandLine::ForCurrentProcess()->AppendSwitch(
238 switches::kDisableWebRtcHWDecoding
);
240 MakeTypicalPeerConnectionCall(
241 "callAndForwardRemoteStream({video: true, audio: false});");
244 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MAYBE_CanForwardRemoteStream720p
) {
245 #if defined (OS_ANDROID)
246 // This test fails on Nexus 5 devices.
247 // TODO(henrika): see http://crbug.com/362437 and http://crbug.com/359389
249 base::CommandLine::ForCurrentProcess()->AppendSwitch(
250 switches::kDisableWebRtcHWDecoding
);
252 const std::string javascript
= GenerateGetUserMediaCall(
253 "callAndForwardRemoteStream", 1280, 1280, 720, 720, 10, 30);
254 MakeTypicalPeerConnectionCall(javascript
);
257 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
258 NoCrashWhenConnectChromiumSinkToRemoteTrack
) {
259 MakeTypicalPeerConnectionCall("ConnectChromiumSinkToRemoteAudioTrack();");
262 // This test will make a complete PeerConnection-based call but remove the
263 // MSID and bundle attribute from the initial offer to verify that
264 // video is playing for the call even if the initiating client don't support
265 // MSID. http://tools.ietf.org/html/draft-alvestrand-rtcweb-msid-02
266 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
267 // Timing out on ARM linux, see http://crbug.com/240373
268 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
269 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle
271 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
272 CanSetupAudioAndVideoCallWithoutMsidAndBundle
274 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
275 MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle
) {
276 MakeTypicalPeerConnectionCall("callWithoutMsidAndBundle();");
279 // This test will modify the SDP offer to an unsupported codec, which should
280 // cause SetLocalDescription to fail.
281 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, NegotiateUnsupportedVideoCodec
) {
282 MakeTypicalPeerConnectionCall("negotiateUnsupportedVideoCodec();");
285 // This test will modify the SDP offer to use no encryption, which should
286 // cause SetLocalDescription to fail.
287 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, NegotiateNonCryptoCall
) {
288 MakeTypicalPeerConnectionCall("negotiateNonCryptoCall();");
291 // This test can negotiate an SDP offer that includes a b=AS:xx to control
292 // the bandwidth for audio and video
293 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, NegotiateOfferWithBLine
) {
294 MakeTypicalPeerConnectionCall("negotiateOfferWithBLine();");
297 // This test will make a complete PeerConnection-based call using legacy SDP
298 // settings: GIce, external SDES, and no BUNDLE.
299 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
300 // Timing out on ARM linux, see http://crbug.com/240373
301 #define MAYBE_CanSetupLegacyCall DISABLED_CanSetupLegacyCall
303 #define MAYBE_CanSetupLegacyCall CanSetupLegacyCall
306 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MAYBE_CanSetupLegacyCall
) {
307 MakeTypicalPeerConnectionCall("callWithLegacySdp();");
310 // This test will make a PeerConnection-based call and test an unreliable text
312 // TODO(mallinath) - Remove this test after rtp based data channel is disabled.
313 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, CallWithDataOnly
) {
314 MakeTypicalPeerConnectionCall("callWithDataOnly();");
317 #if defined(MEMORY_SANITIZER)
318 // Fails under MemorySanitizer: http://crbug.com/405951
319 #define MAYBE_CallWithSctpDataOnly DISABLED_CallWithSctpDataOnly
321 #define MAYBE_CallWithSctpDataOnly CallWithSctpDataOnly
323 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MAYBE_CallWithSctpDataOnly
) {
324 MakeTypicalPeerConnectionCall("callWithSctpDataOnly();");
327 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
328 // Timing out on ARM linux bot: http://crbug.com/238490
329 #define MAYBE_CallWithDataAndMedia DISABLED_CallWithDataAndMedia
331 #define MAYBE_CallWithDataAndMedia CallWithDataAndMedia
334 // This test will make a PeerConnection-based call and test an unreliable text
335 // dataChannel and audio and video tracks.
336 // TODO(mallinath) - Remove this test after rtp based data channel is disabled.
337 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, DISABLED_CallWithDataAndMedia
) {
338 MakeTypicalPeerConnectionCall("callWithDataAndMedia();");
342 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS) && \
343 defined(ARCH_CPU_ARM_FAMILY)) || defined(MEMORY_SANITIZER)
344 // Timing out on ARM linux bot: http://crbug.com/238490
345 // Fails under MemorySanitizer: http://crbug.com/405951
346 #define MAYBE_CallWithSctpDataAndMedia DISABLED_CallWithSctpDataAndMedia
348 #define MAYBE_CallWithSctpDataAndMedia CallWithSctpDataAndMedia
351 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
352 MAYBE_CallWithSctpDataAndMedia
) {
353 MakeTypicalPeerConnectionCall("callWithSctpDataAndMedia();");
356 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
357 // Timing out on ARM linux bot: http://crbug.com/238490
358 #define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia
360 // Temporarily disable the test on all platforms. http://crbug.com/293252
361 #define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia
364 // This test will make a PeerConnection-based call and test an unreliable text
365 // dataChannel and later add an audio and video track.
366 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MAYBE_CallWithDataAndLaterAddMedia
) {
367 MakeTypicalPeerConnectionCall("callWithDataAndLaterAddMedia();");
370 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
371 // Timing out on ARM linux bot: http://crbug.com/238490
372 #define MAYBE_CallWithNewVideoMediaStream DISABLED_CallWithNewVideoMediaStream
374 #define MAYBE_CallWithNewVideoMediaStream CallWithNewVideoMediaStream
377 // This test will make a PeerConnection-based call and send a new Video
378 // MediaStream that has been created based on a MediaStream created with
380 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MAYBE_CallWithNewVideoMediaStream
) {
381 MakeTypicalPeerConnectionCall("callWithNewVideoMediaStream();");
384 // This test will make a PeerConnection-based call and send a new Video
385 // MediaStream that has been created based on a MediaStream created with
386 // getUserMedia. When video is flowing, the VideoTrack is removed and an
387 // AudioTrack is added instead.
388 // TODO(phoglund): This test is manual since not all buildbots has an audio
390 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MANUAL_CallAndModifyStream
) {
391 MakeTypicalPeerConnectionCall(
392 "callWithNewVideoMediaStreamLaterSwitchToAudio();");
395 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, AddTwoMediaStreamsToOnePC
) {
396 MakeTypicalPeerConnectionCall("addTwoMediaStreamsToOneConnection();");
399 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
400 EstablishAudioVideoCallAndEnsureAudioIsPlaying
) {
401 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
402 "callAndEnsureAudioIsPlaying(%s, {audio:true, video:true});",
403 kUseLenientAudioChecking
));
406 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
407 EstablishAudioOnlyCallAndEnsureAudioIsPlaying
) {
408 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
409 "callAndEnsureAudioIsPlaying(%s, {audio:true});",
410 kUseLenientAudioChecking
));
413 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
414 EstablishAudioVideoCallAndVerifyRemoteMutingWorks
) {
415 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
416 "callAndEnsureRemoteAudioTrackMutingWorks(%s);",
417 kUseLenientAudioChecking
));
420 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
421 EstablishAudioVideoCallAndVerifyLocalMutingWorks
) {
422 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
423 "callAndEnsureLocalAudioTrackMutingWorks(%s);",
424 kUseLenientAudioChecking
));
427 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
428 EnsureLocalVideoMuteDoesntMuteAudio
) {
429 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
430 "callAndEnsureLocalVideoMutingDoesntMuteAudio(%s);",
431 kUseLenientAudioChecking
));
434 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
435 EnsureRemoteVideoMuteDoesntMuteAudio
) {
436 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
437 "callAndEnsureRemoteVideoMutingDoesntMuteAudio(%s);",
438 kUseLenientAudioChecking
));
441 // Flaky on TSAN v2: http://crbug.com/373637
442 #if defined(THREAD_SANITIZER)
443 #define MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks\
444 DISABLED_EstablishAudioVideoCallAndVerifyUnmutingWorks
446 #define MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks\
447 EstablishAudioVideoCallAndVerifyUnmutingWorks
449 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
450 MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks
) {
451 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
452 "callAndEnsureAudioTrackUnmutingWorks(%s);", kUseLenientAudioChecking
));
455 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, CallAndVerifyVideoMutingWorks
) {
456 MakeTypicalPeerConnectionCall("callAndEnsureVideoTrackMutingWorks();");
460 #define IntToStringType base::IntToString16
462 #define IntToStringType base::IntToString
465 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
466 // Timing out on ARM linux bot: http://crbug.com/238490
467 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump
469 #define MAYBE_CallWithAecDump CallWithAecDump
472 // This tests will make a complete PeerConnection-based call, verify that
473 // video is playing for the call, and verify that a non-empty AEC dump file
474 // exists. The AEC dump is enabled through webrtc-internals. The HTML and
475 // Javascript is bypassed since it would trigger a file picker dialog. Instead,
476 // the dialog callback FileSelected() is invoked directly. In fact, there's
477 // never a webrtc-internals page opened at all since that's not needed.
478 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MAYBE_CallWithAecDump
) {
479 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
481 // We must navigate somewhere first so that the render process is created.
482 NavigateToURL(shell(), GURL(""));
484 base::FilePath dump_file
;
485 ASSERT_TRUE(CreateTemporaryFile(&dump_file
));
486 base::DeleteFile(dump_file
, false);
488 // This fakes the behavior of another open tab with webrtc-internals, and
489 // enabling AEC dump in that tab.
490 WebRTCInternals::GetInstance()->FileSelected(dump_file
, -1, NULL
);
492 GURL
url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
493 NavigateToURL(shell(), url
);
494 DisableOpusIfOnAndroid();
495 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
497 EXPECT_FALSE(base::PathExists(dump_file
));
499 // Add file extensions that we expect to be added. The dump name will be
500 // <temporary path>.<render process id>.<consumer id>, for example
501 // "/tmp/.com.google.Chrome.Z6UC3P.12345.0".
502 base::ProcessId render_process_id
= base::kNullProcessId
;
503 EXPECT_TRUE(GetRenderProcessHostId(&render_process_id
));
504 dump_file
= dump_file
.AddExtension(IntToStringType(render_process_id
))
505 .AddExtension(IntToStringType(kExpectedConsumerId
));
507 EXPECT_TRUE(base::PathExists(dump_file
));
509 EXPECT_TRUE(base::GetFileSize(dump_file
, &file_size
));
510 EXPECT_GT(file_size
, 0);
512 base::DeleteFile(dump_file
, false);
515 // TODO(grunell): Add test for multiple dumps when re-use of
516 // MediaStreamAudioProcessor in AudioCapturer has been removed.
518 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
519 // Timing out on ARM linux bot: http://crbug.com/238490
520 #define MAYBE_CallWithAecDumpEnabledThenDisabled DISABLED_CallWithAecDumpEnabledThenDisabled
522 #define MAYBE_CallWithAecDumpEnabledThenDisabled CallWithAecDumpEnabledThenDisabled
525 // As above, but enable and disable dump before starting a call. The file should
526 // be created, but should be empty.
527 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
,
528 MAYBE_CallWithAecDumpEnabledThenDisabled
) {
529 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
531 // We must navigate somewhere first so that the render process is created.
532 NavigateToURL(shell(), GURL(""));
534 base::FilePath dump_file
;
535 ASSERT_TRUE(CreateTemporaryFile(&dump_file
));
536 base::DeleteFile(dump_file
, false);
538 // This fakes the behavior of another open tab with webrtc-internals, and
539 // enabling AEC dump in that tab, then disabling it.
540 WebRTCInternals::GetInstance()->FileSelected(dump_file
, -1, NULL
);
541 WebRTCInternals::GetInstance()->DisableAecDump();
543 GURL
url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
544 NavigateToURL(shell(), url
);
545 DisableOpusIfOnAndroid();
546 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
548 // Add file extensions that we expect to be added.
549 base::ProcessId render_process_id
= base::kNullProcessId
;
550 EXPECT_TRUE(GetRenderProcessHostId(&render_process_id
));
551 dump_file
= dump_file
.AddExtension(IntToStringType(render_process_id
))
552 .AddExtension(IntToStringType(kExpectedConsumerId
));
554 EXPECT_FALSE(base::PathExists(dump_file
));
556 base::DeleteFile(dump_file
, false);
559 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
560 // Timing out on ARM linux bot: http://crbug.com/238490
561 #define MAYBE_TwoCallsWithAecDump DISABLED_TwoCallsWithAecDump
563 #define MAYBE_TwoCallsWithAecDump TwoCallsWithAecDump
566 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, MAYBE_TwoCallsWithAecDump
) {
567 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
569 // We must navigate somewhere first so that the render process is created.
570 NavigateToURL(shell(), GURL(""));
572 // Create a second window.
573 Shell
* shell2
= CreateBrowser();
574 NavigateToURL(shell2
, GURL(""));
576 base::FilePath dump_file
;
577 ASSERT_TRUE(CreateTemporaryFile(&dump_file
));
578 base::DeleteFile(dump_file
, false);
580 // This fakes the behavior of another open tab with webrtc-internals, and
581 // enabling AEC dump in that tab.
582 WebRTCInternals::GetInstance()->FileSelected(dump_file
, -1, NULL
);
584 GURL
url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
586 NavigateToURL(shell(), url
);
587 NavigateToURL(shell2
, url
);
588 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
590 EXPECT_TRUE(ExecuteScriptAndExtractString(
591 shell2
->web_contents(),
592 "call({video: true, audio: true});",
594 ASSERT_STREQ("OK", result
.c_str());
596 EXPECT_FALSE(base::PathExists(dump_file
));
598 RenderProcessHost::iterator it
=
599 content::RenderProcessHost::AllHostsIterator();
600 for (; !it
.IsAtEnd(); it
.Advance()) {
601 base::ProcessId render_process_id
=
602 base::GetProcId(it
.GetCurrentValue()->GetHandle());
603 EXPECT_NE(base::kNullProcessId
, render_process_id
);
605 // Add file extensions that we expect to be added.
606 base::FilePath unique_dump_file
=
607 dump_file
.AddExtension(IntToStringType(render_process_id
))
608 .AddExtension(IntToStringType(kExpectedConsumerId
));
610 EXPECT_TRUE(base::PathExists(unique_dump_file
));
612 EXPECT_TRUE(base::GetFileSize(unique_dump_file
, &file_size
));
613 EXPECT_GT(file_size
, 0);
615 base::DeleteFile(unique_dump_file
, false);
619 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest
, CreateOfferWithOfferOptions
) {
620 MakeTypicalPeerConnectionCall("testCreateOfferOptions();");
623 } // namespace content