IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / browser / media / webrtc_browsertest.cc
blob7663f975d4f53e0605b3ba548ba32bfdc79a8a57
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/debug/trace_event_impl.h"
7 #include "base/json/json_reader.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h"
11 #include "content/browser/media/webrtc_internals.h"
12 #include "content/browser/web_contents/web_contents_impl.h"
13 #include "content/public/common/content_switches.h"
14 #include "content/public/test/browser_test_utils.h"
15 #include "content/shell/browser/shell.h"
16 #include "content/test/content_browser_test.h"
17 #include "content/test/content_browser_test_utils.h"
18 #include "media/audio/audio_manager.h"
19 #include "net/test/embedded_test_server/embedded_test_server.h"
20 #include "testing/perf/perf_test.h"
22 #if defined(OS_WIN)
23 #include "base/win/windows_version.h"
24 #endif
26 namespace {
28 static const char kGetUserMediaAndStop[] = "getUserMediaAndStop";
29 static const char kGetUserMediaAndWaitAndStop[] = "getUserMediaAndWaitAndStop";
30 static const char kGetUserMediaAndAnalyseAndStop[] =
31 "getUserMediaAndAnalyseAndStop";
33 // Results returned by JS.
34 static const char kOK[] = "OK";
35 static const char kGetUserMediaFailed[] =
36 "GetUserMedia call failed with code undefined";
38 std::string GenerateGetUserMediaCall(const char* function_name,
39 int min_width,
40 int max_width,
41 int min_height,
42 int max_height,
43 int min_frame_rate,
44 int max_frame_rate) {
45 return base::StringPrintf(
46 "%s({video: {mandatory: {minWidth: %d, maxWidth: %d, "
47 "minHeight: %d, maxHeight: %d, minFrameRate: %d, maxFrameRate: %d}, "
48 "optional: []}});",
49 function_name,
50 min_width,
51 max_width,
52 min_height,
53 max_height,
54 min_frame_rate,
55 max_frame_rate);
58 std::string GenerateGetUserMediaWithMandatorySourceID(
59 const std::string& function_name,
60 const std::string& audio_source_id,
61 const std::string& video_source_id) {
62 const std::string audio_constraint =
63 "audio: {mandatory: { sourceId:\"" + audio_source_id + "\"}}, ";
65 const std::string video_constraint =
66 "video: {mandatory: { sourceId:\"" + video_source_id + "\"}}";
67 return function_name + "({" + audio_constraint + video_constraint + "});";
70 std::string GenerateGetUserMediaWithOptionalSourceID(
71 const std::string& function_name,
72 const std::string& audio_source_id,
73 const std::string& video_source_id) {
74 const std::string audio_constraint =
75 "audio: {optional: [{sourceId:\"" + audio_source_id + "\"}]}, ";
77 const std::string video_constraint =
78 "video: {optional: [{ sourceId:\"" + video_source_id + "\"}]}";
79 return function_name + "({" + audio_constraint + video_constraint + "});";
84 namespace content {
86 class WebrtcBrowserTest: public ContentBrowserTest {
87 public:
88 WebrtcBrowserTest() {}
89 virtual ~WebrtcBrowserTest() {}
91 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
92 // We need fake devices in this test since we want to run on naked VMs. We
93 // assume these switches are set by default in content_browsertests.
94 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
95 switches::kUseFakeDeviceForMediaStream));
96 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
97 switches::kUseFakeUIForMediaStream));
100 void DumpChromeTraceCallback(
101 const scoped_refptr<base::RefCountedString>& events,
102 bool has_more_events) {
103 // Convert the dump output into a correct JSON List.
104 std::string contents = "[" + events->data() + "]";
106 int error_code;
107 std::string error_message;
108 scoped_ptr<base::Value> value(
109 base::JSONReader::ReadAndReturnError(contents,
110 base::JSON_ALLOW_TRAILING_COMMAS,
111 &error_code,
112 &error_message));
114 ASSERT_TRUE(value.get() != NULL) << error_message;
115 ASSERT_EQ(value->GetType(), base::Value::TYPE_LIST);
117 base::ListValue* values;
118 ASSERT_TRUE(value->GetAsList(&values));
120 int duration_ns = 0;
121 std::string samples_duration;
122 double timestamp_ns = 0.0;
123 double previous_timestamp_ns = 0.0;
124 std::string samples_interarrival_ns;
125 for (base::ListValue::iterator it = values->begin();
126 it != values->end(); ++it) {
127 const base::DictionaryValue* dict;
128 EXPECT_TRUE((*it)->GetAsDictionary(&dict));
130 if (dict->GetInteger("dur", &duration_ns))
131 samples_duration.append(base::StringPrintf("%d,", duration_ns));
132 if (dict->GetDouble("ts", &timestamp_ns)) {
133 if (previous_timestamp_ns) {
134 samples_interarrival_ns.append(
135 base::StringPrintf("%f,", timestamp_ns - previous_timestamp_ns));
137 previous_timestamp_ns = timestamp_ns;
140 ASSERT_GT(samples_duration.size(), 0u)
141 << "Could not collect any samples during test, this is bad";
142 perf_test::PrintResultList("video_capture",
144 "sample_duration",
145 samples_duration,
146 "ns",
147 true);
148 perf_test::PrintResultList("video_capture",
150 "interarrival_time",
151 samples_interarrival_ns,
152 "ns",
153 true);
156 void GetSources(std::vector<std::string>* audio_ids,
157 std::vector<std::string>* video_ids) {
158 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
159 NavigateToURL(shell(), url);
161 std::string sources_as_json = ExecuteJavascriptAndReturnResult(
162 "getSources()");
163 EXPECT_FALSE(sources_as_json.empty());
165 int error_code;
166 std::string error_message;
167 scoped_ptr<base::Value> value(
168 base::JSONReader::ReadAndReturnError(sources_as_json,
169 base::JSON_ALLOW_TRAILING_COMMAS,
170 &error_code,
171 &error_message));
173 ASSERT_TRUE(value.get() != NULL) << error_message;
174 EXPECT_EQ(value->GetType(), base::Value::TYPE_LIST);
176 base::ListValue* values;
177 ASSERT_TRUE(value->GetAsList(&values));
179 for (base::ListValue::iterator it = values->begin();
180 it != values->end(); ++it) {
181 const base::DictionaryValue* dict;
182 std::string kind;
183 std::string id;
184 ASSERT_TRUE((*it)->GetAsDictionary(&dict));
185 ASSERT_TRUE(dict->GetString("kind", &kind));
186 ASSERT_TRUE(dict->GetString("id", &id));
187 ASSERT_FALSE(id.empty());
188 EXPECT_TRUE(kind == "audio" || kind == "video");
189 if (kind == "audio") {
190 audio_ids->push_back(id);
191 } else if (kind == "video") {
192 video_ids->push_back(id);
195 ASSERT_FALSE(audio_ids->empty());
196 ASSERT_FALSE(video_ids->empty());
199 protected:
200 bool ExecuteJavascript(const std::string& javascript) {
201 return ExecuteScript(shell()->web_contents(), javascript);
204 // Executes |javascript|. The script is required to use
205 // window.domAutomationController.send to send a string value back to here.
206 std::string ExecuteJavascriptAndReturnResult(const std::string& javascript) {
207 std::string result;
208 EXPECT_TRUE(ExecuteScriptAndExtractString(shell()->web_contents(),
209 javascript,
210 &result));
211 return result;
214 void ExpectTitle(const std::string& expected_title) const {
215 base::string16 expected_title16(base::ASCIIToUTF16(expected_title));
216 TitleWatcher title_watcher(shell()->web_contents(), expected_title16);
217 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle());
220 // Convenience function since most peerconnection-call.html tests just load
221 // the page, kick off some javascript and wait for the title to change to OK.
222 void MakeTypicalPeerConnectionCall(const std::string& javascript) {
223 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
225 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
226 NavigateToURL(shell(), url);
227 ExecuteTestAndWaitForOk(javascript);
230 void ExecuteTestAndWaitForOk(const std::string& javascript) {
231 #if defined (OS_ANDROID)
232 // Always force iSAC 16K on Android for now (Opus is broken).
233 ASSERT_TRUE(ExecuteJavascript("forceIsac16KInSdp();"));
234 #endif
236 ASSERT_TRUE(ExecuteJavascript(javascript));
237 ExpectTitle("OK");
241 // These tests will all make a getUserMedia call with different constraints and
242 // see that the success callback is called. If the error callback is called or
243 // none of the callbacks are called the tests will simply time out and fail.
244 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetVideoStreamAndStop) {
245 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
247 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
248 NavigateToURL(shell(), url);
250 ASSERT_TRUE(ExecuteJavascript(
251 base::StringPrintf("%s({video: true});", kGetUserMediaAndStop)));
253 ExpectTitle("OK");
256 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndStop) {
257 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
259 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
260 NavigateToURL(shell(), url);
262 ASSERT_TRUE(ExecuteJavascript(base::StringPrintf(
263 "%s({video: true, audio: true});", kGetUserMediaAndStop)));
265 ExpectTitle("OK");
268 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndClone) {
269 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
271 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
272 NavigateToURL(shell(), url);
274 ASSERT_TRUE(ExecuteJavascript("getUserMediaAndClone();"));
276 ExpectTitle("OK");
279 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetUserMediaWithMandatorySourceID) {
280 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
282 std::vector<std::string> audio_ids;
283 std::vector<std::string> video_ids;
284 GetSources(&audio_ids, &video_ids);
286 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
288 // Test all combinations of mandatory sourceID;
289 for (std::vector<std::string>::const_iterator video_it = video_ids.begin();
290 video_it != video_ids.end(); ++video_it) {
291 for (std::vector<std::string>::const_iterator audio_it = audio_ids.begin();
292 audio_it != audio_ids.end(); ++audio_it) {
293 NavigateToURL(shell(), url);
294 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult(
295 GenerateGetUserMediaWithMandatorySourceID(
296 kGetUserMediaAndStop,
297 *audio_it,
298 *video_it)));
303 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
304 GetUserMediaWithInvalidMandatorySourceID) {
305 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
307 std::vector<std::string> audio_ids;
308 std::vector<std::string> video_ids;
309 GetSources(&audio_ids, &video_ids);
311 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
313 // Test with invalid mandatory audio sourceID.
314 NavigateToURL(shell(), url);
315 EXPECT_EQ(kGetUserMediaFailed, ExecuteJavascriptAndReturnResult(
316 GenerateGetUserMediaWithMandatorySourceID(
317 kGetUserMediaAndStop,
318 "something invalid",
319 video_ids[0])));
321 // Test with invalid mandatory video sourceID.
322 EXPECT_EQ(kGetUserMediaFailed, ExecuteJavascriptAndReturnResult(
323 GenerateGetUserMediaWithMandatorySourceID(
324 kGetUserMediaAndStop,
325 audio_ids[0],
326 "something invalid")));
328 // Test with empty mandatory audio sourceID.
329 EXPECT_EQ(kGetUserMediaFailed, ExecuteJavascriptAndReturnResult(
330 GenerateGetUserMediaWithMandatorySourceID(
331 kGetUserMediaAndStop,
333 video_ids[0])));
336 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetUserMediaWithOptionalSourceID) {
337 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
339 std::vector<std::string> audio_ids;
340 std::vector<std::string> video_ids;
341 GetSources(&audio_ids, &video_ids);
343 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
344 NavigateToURL(shell(), url);
346 // Test all combinations of mandatory sourceID;
347 for (std::vector<std::string>::const_iterator video_it = video_ids.begin();
348 video_it != video_ids.end(); ++video_it) {
349 for (std::vector<std::string>::const_iterator audio_it = audio_ids.begin();
350 audio_it != audio_ids.end(); ++audio_it) {
351 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult(
352 GenerateGetUserMediaWithOptionalSourceID(
353 kGetUserMediaAndStop,
354 *audio_it,
355 *video_it)));
360 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
361 GetUserMediaWithInvalidOptionalSourceID) {
362 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
364 std::vector<std::string> audio_ids;
365 std::vector<std::string> video_ids;
366 GetSources(&audio_ids, &video_ids);
368 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
370 // Test with invalid optional audio sourceID.
371 NavigateToURL(shell(), url);
372 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult(
373 GenerateGetUserMediaWithOptionalSourceID(
374 kGetUserMediaAndStop,
375 "something invalid",
376 video_ids[0])));
378 // Test with invalid optional video sourceID.
379 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult(
380 GenerateGetUserMediaWithOptionalSourceID(
381 kGetUserMediaAndStop,
382 audio_ids[0],
383 "something invalid")));
385 // Test with empty optional audio sourceID.
386 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult(
387 GenerateGetUserMediaWithOptionalSourceID(
388 kGetUserMediaAndStop,
390 video_ids[0])));
393 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
394 // Timing out on ARM linux bot: http://crbug.com/238490
395 #define MAYBE_CanSetupVideoCall DISABLED_CanSetupVideoCall
396 #else
397 #define MAYBE_CanSetupVideoCall CanSetupVideoCall
398 #endif
400 // These tests will make a complete PeerConnection-based call and verify that
401 // video is playing for the call.
402 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupVideoCall) {
403 MakeTypicalPeerConnectionCall("call({video: true});");
406 // This test will make a simple getUserMedia page, verify that video is playing
407 // in a simple local <video>, and for a couple of seconds, collect some
408 // performance traces.
409 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, TracePerformanceDuringGetUserMedia) {
410 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
412 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
413 NavigateToURL(shell(), url);
414 // Put getUserMedia to work and let it run for a couple of seconds.
415 ASSERT_TRUE(ExecuteJavascript(base::StringPrintf(
416 "%s({video: true}, 10);", kGetUserMediaAndWaitAndStop)));
418 // Make sure the stream is up and running, then start collecting traces.
419 ExpectTitle("Running...");
420 base::debug::TraceLog* trace_log = base::debug::TraceLog::GetInstance();
421 trace_log->SetEnabled(base::debug::CategoryFilter("video"),
422 base::debug::TraceLog::RECORDING_MODE,
423 base::debug::TraceLog::ENABLE_SAMPLING);
424 // Check that we are indeed recording.
425 ASSERT_EQ(trace_log->GetNumTracesRecorded(), 1);
427 // Wait until the page title changes to "OK". Do not sleep() here since that
428 // would stop both this code and the browser underneath.
429 ExpectTitle("OK");
431 // Note that we need to stop the trace recording before flushing the data.
432 trace_log->SetDisabled();
433 trace_log->Flush(base::Bind(&WebrtcBrowserTest::DumpChromeTraceCallback,
434 base::Unretained(this)));
437 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
438 // Timing out on ARM linux, see http://crbug.com/240376
439 #define MAYBE_CanSetupAudioAndVideoCall DISABLED_CanSetupAudioAndVideoCall
440 #else
441 #define MAYBE_CanSetupAudioAndVideoCall CanSetupAudioAndVideoCall
442 #endif
444 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupAudioAndVideoCall) {
445 MakeTypicalPeerConnectionCall("call({video: true, audio: true});");
448 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CanSetupCallAndSendDtmf) {
449 MakeTypicalPeerConnectionCall("callAndSendDtmf(\'123,abc\');");
452 // TODO(phoglund): this test fails because the peer connection state will be
453 // stable in the second negotiation round rather than have-local-offer.
454 // http://crbug.com/293125.
455 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
456 DISABLED_CanMakeEmptyCallThenAddStreamsAndRenegotiate) {
457 const char* kJavascript =
458 "callEmptyThenAddOneStreamAndRenegotiate({video: true, audio: true});";
459 MakeTypicalPeerConnectionCall(kJavascript);
462 // Below 2 test will make a complete PeerConnection-based call between pc1 and
463 // pc2, and then use the remote stream to setup a call between pc3 and pc4, and
464 // then verify that video is received on pc3 and pc4.
465 // Flaky on win xp. http://crbug.com/304775
466 #if defined(OS_WIN)
467 #define MAYBE_CanForwardRemoteStream DISABLED_CanForwardRemoteStream
468 #define MAYBE_CanForwardRemoteStream720p DISABLED_CanForwardRemoteStream720p
469 #else
470 #define MAYBE_CanForwardRemoteStream CanForwardRemoteStream
471 #define MAYBE_CanForwardRemoteStream720p CanForwardRemoteStream720p
472 #endif
473 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanForwardRemoteStream) {
474 MakeTypicalPeerConnectionCall(
475 "callAndForwardRemoteStream({video: true, audio: true});");
478 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanForwardRemoteStream720p) {
479 const std::string javascript = GenerateGetUserMediaCall(
480 "callAndForwardRemoteStream", 1280, 1280, 720, 720, 30, 30);
481 MakeTypicalPeerConnectionCall(javascript);
484 // This test will make a complete PeerConnection-based call but remove the
485 // MSID and bundle attribute from the initial offer to verify that
486 // video is playing for the call even if the initiating client don't support
487 // MSID. http://tools.ietf.org/html/draft-alvestrand-rtcweb-msid-02
488 #if defined(OS_WIN) && defined(USE_AURA)
489 // Disabled for win7_aura, see http://crbug.com/235089.
490 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
491 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle
492 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
493 // Timing out on ARM linux, see http://crbug.com/240373
494 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
495 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle
496 #else
497 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
498 CanSetupAudioAndVideoCallWithoutMsidAndBundle
499 #endif
500 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
501 MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle) {
502 MakeTypicalPeerConnectionCall("callWithoutMsidAndBundle();");
505 // This test will modify the SDP offer to an unsupported codec, which should
506 // cause SetLocalDescription to fail.
507 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, NegotiateUnsupportedVideoCodec) {
508 MakeTypicalPeerConnectionCall("negotiateUnsupportedVideoCodec();");
511 // This test will modify the SDP offer to use no encryption, which should
512 // cause SetLocalDescription to fail.
513 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, NegotiateNonCryptoCall) {
514 MakeTypicalPeerConnectionCall("negotiateNonCryptoCall();");
517 // This test will make a complete PeerConnection-based call using legacy SDP
518 // settings: GIce, external SDES, and no BUNDLE.
519 #if defined(OS_WIN) && defined(USE_AURA)
520 // Disabled for win7_aura, see http://crbug.com/235089.
521 #define MAYBE_CanSetupLegacyCall DISABLED_CanSetupLegacyCall
522 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
523 // Timing out on ARM linux, see http://crbug.com/240373
524 #define MAYBE_CanSetupLegacyCall DISABLED_CanSetupLegacyCall
525 #else
526 #define MAYBE_CanSetupLegacyCall CanSetupLegacyCall
527 #endif
529 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupLegacyCall) {
530 MakeTypicalPeerConnectionCall("callWithLegacySdp();");
533 // This test will make a PeerConnection-based call and test an unreliable text
534 // dataChannel.
535 // TODO(mallinath) - Remove this test after rtp based data channel is disabled.
536 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithDataOnly) {
537 MakeTypicalPeerConnectionCall("callWithDataOnly();");
540 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithSctpDataOnly) {
541 MakeTypicalPeerConnectionCall("callWithSctpDataOnly();");
544 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
545 // Timing out on ARM linux bot: http://crbug.com/238490
546 #define MAYBE_CallWithDataAndMedia DISABLED_CallWithDataAndMedia
547 #else
548 #define MAYBE_CallWithDataAndMedia CallWithDataAndMedia
549 #endif
551 // This test will make a PeerConnection-based call and test an unreliable text
552 // dataChannel and audio and video tracks.
553 // TODO(mallinath) - Remove this test after rtp based data channel is disabled.
554 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndMedia) {
555 MakeTypicalPeerConnectionCall("callWithDataAndMedia();");
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_CallWithSctpDataAndMedia DISABLED_CallWithSctpDataAndMedia
562 #else
563 #define MAYBE_CallWithSctpDataAndMedia CallWithSctpDataAndMedia
564 #endif
566 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
567 MAYBE_CallWithSctpDataAndMedia) {
568 MakeTypicalPeerConnectionCall("callWithSctpDataAndMedia();");
571 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
572 // Timing out on ARM linux bot: http://crbug.com/238490
573 #define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia
574 #else
575 // Temporarily disable the test on all platforms. http://crbug.com/293252
576 #define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia
577 #endif
579 // This test will make a PeerConnection-based call and test an unreliable text
580 // dataChannel and later add an audio and video track.
581 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndLaterAddMedia) {
582 MakeTypicalPeerConnectionCall("callWithDataAndLaterAddMedia();");
585 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
586 // Timing out on ARM linux bot: http://crbug.com/238490
587 #define MAYBE_CallWithNewVideoMediaStream DISABLED_CallWithNewVideoMediaStream
588 #else
589 #define MAYBE_CallWithNewVideoMediaStream CallWithNewVideoMediaStream
590 #endif
592 // This test will make a PeerConnection-based call and send a new Video
593 // MediaStream that has been created based on a MediaStream created with
594 // getUserMedia.
595 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithNewVideoMediaStream) {
596 MakeTypicalPeerConnectionCall("callWithNewVideoMediaStream();");
599 // This test will make a PeerConnection-based call and send a new Video
600 // MediaStream that has been created based on a MediaStream created with
601 // getUserMedia. When video is flowing, the VideoTrack is removed and an
602 // AudioTrack is added instead.
603 // TODO(phoglund): This test is manual since not all buildbots has an audio
604 // input.
605 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CallAndModifyStream) {
606 MakeTypicalPeerConnectionCall(
607 "callWithNewVideoMediaStreamLaterSwitchToAudio();");
610 // This test calls getUserMedia in sequence with different constraints.
611 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, TestGetUserMediaConstraints) {
612 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
614 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
616 std::vector<std::string> list_of_get_user_media_calls;
617 list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
618 kGetUserMediaAndStop, 320, 320, 180, 180, 30, 30));
619 list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
620 kGetUserMediaAndStop, 320, 320, 240, 240, 30, 30));
621 list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
622 kGetUserMediaAndStop, 640, 640, 360, 360, 30, 30));
623 list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
624 kGetUserMediaAndStop, 640, 640, 480, 480, 30, 30));
625 list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
626 kGetUserMediaAndStop, 960, 960, 720, 720, 30, 30));
627 list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
628 kGetUserMediaAndStop, 1280, 1280, 720, 720, 30, 30));
629 list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
630 kGetUserMediaAndStop, 1920, 1920, 1080, 1080, 30, 30));
632 for (std::vector<std::string>::iterator const_iterator =
633 list_of_get_user_media_calls.begin();
634 const_iterator != list_of_get_user_media_calls.end();
635 ++const_iterator) {
636 DVLOG(1) << "Calling getUserMedia: " << *const_iterator;
637 NavigateToURL(shell(), url);
638 ASSERT_TRUE(ExecuteJavascript(*const_iterator));
639 ExpectTitle("OK");
643 // This test calls getUserMedia and checks for aspect ratio behavior.
644 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, TestGetUserMediaAspectRatio) {
645 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
647 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
649 std::string constraints_4_3 = GenerateGetUserMediaCall(
650 kGetUserMediaAndAnalyseAndStop, 640, 640, 480, 480, 30, 30);
651 std::string constraints_16_9 = GenerateGetUserMediaCall(
652 kGetUserMediaAndAnalyseAndStop, 640, 640, 360, 360, 30, 30);
654 // TODO(mcasas): add more aspect ratios, in particular 16:10 crbug.com/275594.
656 NavigateToURL(shell(), url);
657 ASSERT_TRUE(ExecuteJavascript(constraints_4_3));
658 ExpectTitle("4:3 letterbox");
660 NavigateToURL(shell(), url);
661 ASSERT_TRUE(ExecuteJavascript(constraints_16_9));
662 ExpectTitle("16:9 letterbox");
665 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, AddTwoMediaStreamsToOnePC) {
666 MakeTypicalPeerConnectionCall("addTwoMediaStreamsToOneConnection();");
669 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
670 EstablishAudioVideoCallAndMeasureOutputLevel) {
671 if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
672 // Bots with no output devices will force the audio code into a different
673 // path where it doesn't manage to set either the low or high latency path.
674 // This test will compute useless values in that case, so skip running on
675 // such bots (see crbug.com/326338).
676 LOG(INFO) << "Missing output devices: skipping test...";
677 return;
680 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
681 switches::kUseFakeDeviceForMediaStream))
682 << "Must run with fake devices since the test will explicitly look "
683 << "for the fake device signal.";
685 MakeTypicalPeerConnectionCall("callAndEnsureAudioIsPlaying();");
688 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
689 EstablishAudioVideoCallAndVerifyMutingWorks) {
690 if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
691 // Bots with no output devices will force the audio code into a different
692 // path where it doesn't manage to set either the low or high latency path.
693 // This test will compute useless values in that case, so skip running on
694 // such bots (see crbug.com/326338).
695 LOG(INFO) << "Missing output devices: skipping test...";
696 return;
699 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
700 switches::kUseFakeDeviceForMediaStream))
701 << "Must run with fake devices since the test will explicitly look "
702 << "for the fake device signal.";
704 MakeTypicalPeerConnectionCall("callAndEnsureAudioMutingWorks();");
707 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallAndVerifyVideoMutingWorks) {
708 MakeTypicalPeerConnectionCall("callAndEnsureVideoMutingWorks();");
711 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY))
712 // Timing out on ARM linux bot: http://crbug.com/238490
713 // Failing on Windows: http://crbug.com/331035
714 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump
715 #else
716 #define MAYBE_CallWithAecDump CallWithAecDump
717 #endif
719 // This tests will make a complete PeerConnection-based call, verify that
720 // video is playing for the call, and verify that a non-empty AEC dump file
721 // exists. The AEC dump is enabled through webrtc-internals, in contrast to
722 // using a command line flag (tested in webrtc_aecdump_browsertest.cc). The HTML
723 // and Javascript is bypassed since it would trigger a file picker dialog.
724 // Instead, the dialog callback FileSelected() is invoked directly. In fact,
725 // there's never a webrtc-internals page opened at all since that's not needed.
726 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithAecDump) {
727 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
729 // We must navigate somewhere first so that the render process is created.
730 NavigateToURL(shell(), GURL(""));
732 base::FilePath dump_file;
733 ASSERT_TRUE(CreateTemporaryFile(&dump_file));
735 // This fakes the behavior of another open tab with webrtc-internals, and
736 // enabling AEC dump in that tab.
737 WebRTCInternals::GetInstance()->FileSelected(dump_file, -1, NULL);
739 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
740 NavigateToURL(shell(), url);
741 ExecuteTestAndWaitForOk("call({video: true, audio: true});");
743 EXPECT_TRUE(base::PathExists(dump_file));
744 int64 file_size = 0;
745 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size));
746 EXPECT_GT(file_size, 0);
748 base::DeleteFile(dump_file, false);
751 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
752 // Timing out on ARM linux bot: http://crbug.com/238490
753 #define MAYBE_CallWithAecDumpEnabledThenDisabled DISABLED_CallWithAecDumpEnabledThenDisabled
754 #else
755 #define MAYBE_CallWithAecDumpEnabledThenDisabled CallWithAecDumpEnabledThenDisabled
756 #endif
758 // As above, but enable and disable dump before starting a call. The file should
759 // be created, but should be empty.
760 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
761 MAYBE_CallWithAecDumpEnabledThenDisabled) {
762 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
764 // We must navigate somewhere first so that the render process is created.
765 NavigateToURL(shell(), GURL(""));
767 base::FilePath dump_file;
768 ASSERT_TRUE(CreateTemporaryFile(&dump_file));
770 // This fakes the behavior of another open tab with webrtc-internals, and
771 // enabling AEC dump in that tab, then disabling it.
772 WebRTCInternals::GetInstance()->FileSelected(dump_file, -1, NULL);
773 WebRTCInternals::GetInstance()->DisableAecDump();
775 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
776 NavigateToURL(shell(), url);
777 ExecuteTestAndWaitForOk("call({video: true, audio: true});");
779 EXPECT_TRUE(base::PathExists(dump_file));
780 int64 file_size = 0;
781 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size));
782 EXPECT_EQ(0, file_size);
784 base::DeleteFile(dump_file, false);
788 } // namespace content