Remove AEC dump command line flag and the test for it.
[chromium-blink-merge.git] / content / browser / media / webrtc_browsertest.cc
blobb187adc20ad30df88e92965fc164b1b7167022fb
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/strings/stringprintf.h"
7 #include "base/values.h"
8 #include "content/browser/media/webrtc_internals.h"
9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/public/common/content_switches.h"
11 #include "content/public/test/browser_test_utils.h"
12 #include "content/public/test/content_browser_test_utils.h"
13 #include "content/public/test/test_utils.h"
14 #include "content/shell/browser/shell.h"
15 #include "content/test/webrtc_content_browsertest_base.h"
16 #include "media/audio/audio_manager.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h"
19 #if defined(OS_WIN)
20 #include "base/win/windows_version.h"
21 #endif
23 namespace content {
25 class WebRtcBrowserTest : public WebRtcContentBrowserTest,
26 public testing::WithParamInterface<bool> {
27 public:
28 WebRtcBrowserTest() {}
29 virtual ~WebRtcBrowserTest() {}
31 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
32 WebRtcContentBrowserTest::SetUpCommandLine(command_line);
34 bool enable_audio_track_processing = GetParam();
35 if (enable_audio_track_processing)
36 command_line->AppendSwitch(switches::kEnableAudioTrackProcessing);
39 // Convenience function since most peerconnection-call.html tests just load
40 // the page, kick off some javascript and wait for the title to change to OK.
41 void MakeTypicalPeerConnectionCall(const std::string& javascript) {
42 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
44 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
45 NavigateToURL(shell(), url);
47 DisableOpusIfOnAndroid();
48 ExecuteJavascriptAndWaitForOk(javascript);
51 void DisableOpusIfOnAndroid() {
52 #if defined (OS_ANDROID)
53 // Always force iSAC 16K on Android for now (Opus is broken).
54 EXPECT_EQ("isac-forced",
55 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();"));
56 #endif
60 static const bool kRunTestsWithFlag[] = { false, true };
61 INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests,
62 WebRtcBrowserTest,
63 testing::ValuesIn(kRunTestsWithFlag));
65 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
66 // Timing out on ARM linux bot: http://crbug.com/238490
67 #define MAYBE_CanSetupDefaultVideoCall DISABLED_CanSetupDefaultVideoCall
68 #else
69 #define MAYBE_CanSetupDefaultVideoCall CanSetupDefaultVideoCall
70 #endif
72 // These tests will make a complete PeerConnection-based call and verify that
73 // video is playing for the call.
74 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CanSetupDefaultVideoCall) {
75 MakeTypicalPeerConnectionCall(
76 "callAndExpectResolution({video: true}, 640, 480);");
79 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CanSetupVideoCallWith1To1AspecRatio) {
80 const std::string javascript =
81 "callAndExpectResolution({video: {mandatory: {minWidth: 320,"
82 " maxWidth: 320, minHeight: 320, maxHeight: 320}}}, 320, 320);";
83 MakeTypicalPeerConnectionCall(javascript);
86 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
87 // Timing out on ARM linux, see http://crbug.com/240376
88 #define MAYBE_CanSetupAudioAndVideoCall DISABLED_CanSetupAudioAndVideoCall
89 #else
90 #define MAYBE_CanSetupAudioAndVideoCall CanSetupAudioAndVideoCall
91 #endif
93 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CanSetupAudioAndVideoCall) {
94 MakeTypicalPeerConnectionCall("call({video: true, audio: true});");
97 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CanSetupCallAndSendDtmf) {
98 MakeTypicalPeerConnectionCall("callAndSendDtmf(\'123,abc\');");
101 // TODO(phoglund): this test fails because the peer connection state will be
102 // stable in the second negotiation round rather than have-local-offer.
103 // http://crbug.com/293125.
104 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
105 DISABLED_CanMakeEmptyCallThenAddStreamsAndRenegotiate) {
106 const char* kJavascript =
107 "callEmptyThenAddOneStreamAndRenegotiate({video: true, audio: true});";
108 MakeTypicalPeerConnectionCall(kJavascript);
111 // Below 2 test will make a complete PeerConnection-based call between pc1 and
112 // pc2, and then use the remote stream to setup a call between pc3 and pc4, and
113 // then verify that video is received on pc3 and pc4.
114 // Flaky on win xp. http://crbug.com/304775
115 #if defined(OS_WIN)
116 #define MAYBE_CanForwardRemoteStream DISABLED_CanForwardRemoteStream
117 #define MAYBE_CanForwardRemoteStream720p DISABLED_CanForwardRemoteStream720p
118 #else
119 #define MAYBE_CanForwardRemoteStream CanForwardRemoteStream
120 #define MAYBE_CanForwardRemoteStream720p CanForwardRemoteStream720p
121 #endif
122 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CanForwardRemoteStream) {
123 MakeTypicalPeerConnectionCall(
124 "callAndForwardRemoteStream({video: true, audio: false});");
127 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CanForwardRemoteStream720p) {
128 const std::string javascript = GenerateGetUserMediaCall(
129 "callAndForwardRemoteStream", 1280, 1280, 720, 720, 10, 30);
130 MakeTypicalPeerConnectionCall(javascript);
133 // This test will make a complete PeerConnection-based call but remove the
134 // MSID and bundle attribute from the initial offer to verify that
135 // video is playing for the call even if the initiating client don't support
136 // MSID. http://tools.ietf.org/html/draft-alvestrand-rtcweb-msid-02
137 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
138 // Timing out on ARM linux, see http://crbug.com/240373
139 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
140 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle
141 #else
142 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
143 CanSetupAudioAndVideoCallWithoutMsidAndBundle
144 #endif
145 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
146 MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle) {
147 MakeTypicalPeerConnectionCall("callWithoutMsidAndBundle();");
150 // This test will modify the SDP offer to an unsupported codec, which should
151 // cause SetLocalDescription to fail.
152 #if defined(USE_OZONE)
153 // Disabled for Ozone, see http://crbug.com/315392#c15
154 #define MAYBE_NegotiateUnsupportedVideoCodec\
155 DISABLED_NegotiateUnsupportedVideoCodec
156 #else
157 #define MAYBE_NegotiateUnsupportedVideoCodec NegotiateUnsupportedVideoCodec
158 #endif
160 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
161 MAYBE_NegotiateUnsupportedVideoCodec) {
162 MakeTypicalPeerConnectionCall("negotiateUnsupportedVideoCodec();");
165 // This test will modify the SDP offer to use no encryption, which should
166 // cause SetLocalDescription to fail.
167 #if defined(USE_OZONE)
168 // Disabled for Ozone, see http://crbug.com/315392#c15
169 #define MAYBE_NegotiateNonCryptoCall DISABLED_NegotiateNonCryptoCall
170 #else
171 #define MAYBE_NegotiateNonCryptoCall NegotiateNonCryptoCall
172 #endif
174 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_NegotiateNonCryptoCall) {
175 MakeTypicalPeerConnectionCall("negotiateNonCryptoCall();");
178 // This test can negotiate an SDP offer that includes a b=AS:xx to control
179 // the bandwidth for audio and video
180 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, NegotiateOfferWithBLine) {
181 MakeTypicalPeerConnectionCall("negotiateOfferWithBLine();");
184 // This test will make a complete PeerConnection-based call using legacy SDP
185 // settings: GIce, external SDES, and no BUNDLE.
186 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
187 // Timing out on ARM linux, see http://crbug.com/240373
188 #define MAYBE_CanSetupLegacyCall DISABLED_CanSetupLegacyCall
189 #else
190 #define MAYBE_CanSetupLegacyCall CanSetupLegacyCall
191 #endif
193 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CanSetupLegacyCall) {
194 MakeTypicalPeerConnectionCall("callWithLegacySdp();");
197 // This test will make a PeerConnection-based call and test an unreliable text
198 // dataChannel.
199 // TODO(mallinath) - Remove this test after rtp based data channel is disabled.
200 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CallWithDataOnly) {
201 MakeTypicalPeerConnectionCall("callWithDataOnly();");
204 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CallWithSctpDataOnly) {
205 MakeTypicalPeerConnectionCall("callWithSctpDataOnly();");
208 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
209 // Timing out on ARM linux bot: http://crbug.com/238490
210 #define MAYBE_CallWithDataAndMedia DISABLED_CallWithDataAndMedia
211 #else
212 #define MAYBE_CallWithDataAndMedia CallWithDataAndMedia
213 #endif
215 // This test will make a PeerConnection-based call and test an unreliable text
216 // dataChannel and audio and video tracks.
217 // TODO(mallinath) - Remove this test after rtp based data channel is disabled.
218 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CallWithDataAndMedia) {
219 MakeTypicalPeerConnectionCall("callWithDataAndMedia();");
223 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
224 // Timing out on ARM linux bot: http://crbug.com/238490
225 #define MAYBE_CallWithSctpDataAndMedia DISABLED_CallWithSctpDataAndMedia
226 #else
227 #define MAYBE_CallWithSctpDataAndMedia CallWithSctpDataAndMedia
228 #endif
230 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
231 MAYBE_CallWithSctpDataAndMedia) {
232 MakeTypicalPeerConnectionCall("callWithSctpDataAndMedia();");
235 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
236 // Timing out on ARM linux bot: http://crbug.com/238490
237 #define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia
238 #else
239 // Temporarily disable the test on all platforms. http://crbug.com/293252
240 #define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia
241 #endif
243 // This test will make a PeerConnection-based call and test an unreliable text
244 // dataChannel and later add an audio and video track.
245 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CallWithDataAndLaterAddMedia) {
246 MakeTypicalPeerConnectionCall("callWithDataAndLaterAddMedia();");
249 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
250 // Timing out on ARM linux bot: http://crbug.com/238490
251 #define MAYBE_CallWithNewVideoMediaStream DISABLED_CallWithNewVideoMediaStream
252 #else
253 #define MAYBE_CallWithNewVideoMediaStream CallWithNewVideoMediaStream
254 #endif
256 // This test will make a PeerConnection-based call and send a new Video
257 // MediaStream that has been created based on a MediaStream created with
258 // getUserMedia.
259 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CallWithNewVideoMediaStream) {
260 MakeTypicalPeerConnectionCall("callWithNewVideoMediaStream();");
263 // This test will make a PeerConnection-based call and send a new Video
264 // MediaStream that has been created based on a MediaStream created with
265 // getUserMedia. When video is flowing, the VideoTrack is removed and an
266 // AudioTrack is added instead.
267 // TODO(phoglund): This test is manual since not all buildbots has an audio
268 // input.
269 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CallAndModifyStream) {
270 MakeTypicalPeerConnectionCall(
271 "callWithNewVideoMediaStreamLaterSwitchToAudio();");
274 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, AddTwoMediaStreamsToOnePC) {
275 MakeTypicalPeerConnectionCall("addTwoMediaStreamsToOneConnection();");
278 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
279 EstablishAudioVideoCallAndMeasureOutputLevel) {
280 if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
281 // Bots with no output devices will force the audio code into a different
282 // path where it doesn't manage to set either the low or high latency path.
283 // This test will compute useless values in that case, so skip running on
284 // such bots (see crbug.com/326338).
285 LOG(INFO) << "Missing output devices: skipping test...";
286 return;
289 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
290 switches::kUseFakeDeviceForMediaStream))
291 << "Must run with fake devices since the test will explicitly look "
292 << "for the fake device signal.";
294 MakeTypicalPeerConnectionCall("callAndEnsureAudioIsPlaying();");
297 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
298 EstablishAudioVideoCallAndVerifyMutingWorks) {
299 if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
300 // Bots with no output devices will force the audio code into a different
301 // path where it doesn't manage to set either the low or high latency path.
302 // This test will compute useless values in that case, so skip running on
303 // such bots (see crbug.com/326338).
304 LOG(INFO) << "Missing output devices: skipping test...";
305 return;
308 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
309 switches::kUseFakeDeviceForMediaStream))
310 << "Must run with fake devices since the test will explicitly look "
311 << "for the fake device signal.";
313 MakeTypicalPeerConnectionCall("callAndEnsureAudioTrackMutingWorks();");
316 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
317 EstablishAudioVideoCallAndVerifyUnmutingWorks) {
318 if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
319 // See comment on EstablishAudioVideoCallAndVerifyMutingWorks.
320 LOG(INFO) << "Missing output devices: skipping test...";
321 return;
324 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
325 switches::kUseFakeDeviceForMediaStream))
326 << "Must run with fake devices since the test will explicitly look "
327 << "for the fake device signal.";
329 MakeTypicalPeerConnectionCall("callAndEnsureAudioTrackUnmutingWorks();");
332 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CallAndVerifyVideoMutingWorks) {
333 MakeTypicalPeerConnectionCall("callAndEnsureVideoTrackMutingWorks();");
336 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
337 // Timing out on ARM linux bot: http://crbug.com/238490
338 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump
339 #else
340 #define MAYBE_CallWithAecDump CallWithAecDump
341 #endif
343 // This tests will make a complete PeerConnection-based call, verify that
344 // video is playing for the call, and verify that a non-empty AEC dump file
345 // exists. The AEC dump is enabled through webrtc-internals. The HTML and
346 // Javascript is bypassed since it would trigger a file picker dialog. Instead,
347 // the dialog callback FileSelected() is invoked directly. In fact, there's
348 // never a webrtc-internals page opened at all since that's not needed.
349 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CallWithAecDump) {
350 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
352 // We must navigate somewhere first so that the render process is created.
353 NavigateToURL(shell(), GURL(""));
355 base::FilePath dump_file;
356 ASSERT_TRUE(CreateTemporaryFile(&dump_file));
358 // This fakes the behavior of another open tab with webrtc-internals, and
359 // enabling AEC dump in that tab.
360 WebRTCInternals::GetInstance()->FileSelected(dump_file, -1, NULL);
362 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
363 NavigateToURL(shell(), url);
364 DisableOpusIfOnAndroid();
365 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
367 EXPECT_TRUE(base::PathExists(dump_file));
368 int64 file_size = 0;
369 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size));
370 EXPECT_GT(file_size, 0);
372 base::DeleteFile(dump_file, false);
375 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
376 // Timing out on ARM linux bot: http://crbug.com/238490
377 #define MAYBE_CallWithAecDumpEnabledThenDisabled DISABLED_CallWithAecDumpEnabledThenDisabled
378 #else
379 #define MAYBE_CallWithAecDumpEnabledThenDisabled CallWithAecDumpEnabledThenDisabled
380 #endif
382 // As above, but enable and disable dump before starting a call. The file should
383 // be created, but should be empty.
384 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
385 MAYBE_CallWithAecDumpEnabledThenDisabled) {
386 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
388 // We must navigate somewhere first so that the render process is created.
389 NavigateToURL(shell(), GURL(""));
391 base::FilePath dump_file;
392 ASSERT_TRUE(CreateTemporaryFile(&dump_file));
394 // This fakes the behavior of another open tab with webrtc-internals, and
395 // enabling AEC dump in that tab, then disabling it.
396 WebRTCInternals::GetInstance()->FileSelected(dump_file, -1, NULL);
397 WebRTCInternals::GetInstance()->DisableAecDump();
399 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
400 NavigateToURL(shell(), url);
401 DisableOpusIfOnAndroid();
402 ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
404 EXPECT_TRUE(base::PathExists(dump_file));
405 int64 file_size = 0;
406 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size));
407 EXPECT_EQ(0, file_size);
409 base::DeleteFile(dump_file, false);
412 } // namespace content