OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "content/browser/media/webrtc_internals.h" | 10 #include "content/browser/media/webrtc_internals.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // TODO(phoglund): this is a ugly workaround to let the IO thread | 52 // TODO(phoglund): this is a ugly workaround to let the IO thread |
53 // finish its work. The reason we need this on Android is that | 53 // finish its work. The reason we need this on Android is that |
54 // content_browsertests tearDown logic is broken with respect | 54 // content_browsertests tearDown logic is broken with respect |
55 // to threading, which causes the IO thread to compete with the | 55 // to threading, which causes the IO thread to compete with the |
56 // teardown. See http://crbug.com/362852. I also tried with 2 | 56 // teardown. See http://crbug.com/362852. I also tried with 2 |
57 // seconds, but that isn't enough. | 57 // seconds, but that isn't enough. |
58 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(5)); | 58 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(5)); |
59 #endif | 59 #endif |
60 } | 60 } |
61 | 61 |
62 // Convenience function since most peerconnection-call.html tests just load | 62 // Convenience method since most peerconnection-call.html tests just load |
63 // the page, kick off some javascript and wait for the title to change to OK. | 63 // the page, kick off some javascript and wait for the title to change to OK. |
64 void MakeTypicalPeerConnectionCall(const std::string& javascript) { | 64 void MakeTypicalPeerConnectionCall(const std::string& javascript) { |
65 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 65 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
66 | 66 |
67 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); | 67 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); |
68 NavigateToURL(shell(), url); | 68 NavigateToURL(shell(), url); |
69 | 69 |
70 DisableOpusIfOnAndroid(); | 70 DisableOpusIfOnAndroid(); |
71 ExecuteJavascriptAndWaitForOk(javascript); | 71 ExecuteJavascriptAndWaitForOk(javascript); |
72 } | 72 } |
73 | 73 |
| 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..."; |
| 84 return; |
| 85 } |
| 86 |
| 87 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( |
| 88 switches::kUseFakeDeviceForMediaStream)) |
| 89 << "Must run with fake devices since the test will explicitly look " |
| 90 << "for the fake device signal."; |
| 91 |
| 92 MakeTypicalPeerConnectionCall(javascript); |
| 93 } |
| 94 |
74 void DisableOpusIfOnAndroid() { | 95 void DisableOpusIfOnAndroid() { |
75 #if defined(OS_ANDROID) | 96 #if defined(OS_ANDROID) |
76 // Always force iSAC 16K on Android for now (Opus is broken). | 97 // Always force iSAC 16K on Android for now (Opus is broken). |
77 EXPECT_EQ("isac-forced", | 98 EXPECT_EQ("isac-forced", |
78 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();")); | 99 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();")); |
79 #endif | 100 #endif |
80 } | 101 } |
81 }; | 102 }; |
82 | 103 |
83 static const bool kRunTestsWithFlag[] = { false, true }; | 104 static const bool kRunTestsWithFlag[] = { false, true }; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CallAndModifyStream) { | 341 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CallAndModifyStream) { |
321 MakeTypicalPeerConnectionCall( | 342 MakeTypicalPeerConnectionCall( |
322 "callWithNewVideoMediaStreamLaterSwitchToAudio();"); | 343 "callWithNewVideoMediaStreamLaterSwitchToAudio();"); |
323 } | 344 } |
324 | 345 |
325 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, AddTwoMediaStreamsToOnePC) { | 346 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, AddTwoMediaStreamsToOnePC) { |
326 MakeTypicalPeerConnectionCall("addTwoMediaStreamsToOneConnection();"); | 347 MakeTypicalPeerConnectionCall("addTwoMediaStreamsToOneConnection();"); |
327 } | 348 } |
328 | 349 |
329 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, | 350 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, |
330 EstablishAudioVideoCallAndMeasureOutputLevel) { | 351 EstablishAudioVideoCallAndEnsureAudioIsPlaying) { |
331 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { | 352 MakeAudioDetectingPeerConnectionCall(base::StringPrintf( |
332 // Bots with no output devices will force the audio code into a different | 353 "callAndEnsureAudioIsPlaying(%s, {audio:true, video:true});", |
333 // path where it doesn't manage to set either the low or high latency path. | 354 kUseLenientAudioChecking)); |
334 // This test will compute useless values in that case, so skip running on | 355 } |
335 // such bots (see crbug.com/326338). | |
336 LOG(INFO) << "Missing output devices: skipping test..."; | |
337 return; | |
338 } | |
339 | 356 |
340 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | 357 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, |
341 switches::kUseFakeDeviceForMediaStream)) | 358 EstablishAudioOnlyCallAndEnsureAudioIsPlaying) { |
342 << "Must run with fake devices since the test will explicitly look " | 359 MakeAudioDetectingPeerConnectionCall(base::StringPrintf( |
343 << "for the fake device signal."; | 360 "callAndEnsureAudioIsPlaying(%s, {audio:true});", |
344 | 361 kUseLenientAudioChecking)); |
345 MakeTypicalPeerConnectionCall(base::StringPrintf( | |
346 "callAndEnsureAudioIsPlaying(%s);", kUseLenientAudioChecking)); | |
347 } | 362 } |
348 | 363 |
349 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, | 364 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, |
350 EstablishAudioVideoCallAndVerifyMutingWorks) { | 365 EstablishAudioVideoCallAndVerifyMutingWorks) { |
351 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { | 366 MakeAudioDetectingPeerConnectionCall(base::StringPrintf( |
352 // See comment on EstablishAudioVideoCallAndMeasureOutputLevel. | |
353 LOG(INFO) << "Missing output devices: skipping test..."; | |
354 return; | |
355 } | |
356 | |
357 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | |
358 switches::kUseFakeDeviceForMediaStream)) | |
359 << "Must run with fake devices since the test will explicitly look " | |
360 << "for the fake device signal."; | |
361 | |
362 MakeTypicalPeerConnectionCall(base::StringPrintf( | |
363 "callAndEnsureAudioTrackMutingWorks(%s);", kUseLenientAudioChecking)); | 367 "callAndEnsureAudioTrackMutingWorks(%s);", kUseLenientAudioChecking)); |
364 } | 368 } |
365 | 369 |
366 // Flaky on TSAN v2: http://crbug.com/373637 | 370 // Flaky on TSAN v2: http://crbug.com/373637 |
367 #if defined(THREAD_SANITIZER) | 371 #if defined(THREAD_SANITIZER) |
368 #define MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks\ | 372 #define MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks\ |
369 DISABLED_EstablishAudioVideoCallAndVerifyUnmutingWorks | 373 DISABLED_EstablishAudioVideoCallAndVerifyUnmutingWorks |
370 #else | 374 #else |
371 #define MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks\ | 375 #define MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks\ |
372 EstablishAudioVideoCallAndVerifyUnmutingWorks | 376 EstablishAudioVideoCallAndVerifyUnmutingWorks |
373 #endif | 377 #endif |
374 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, | 378 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, |
375 MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks) { | 379 MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks) { |
376 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { | 380 MakeAudioDetectingPeerConnectionCall(base::StringPrintf( |
377 // See comment on EstablishAudioVideoCallAndMeasureOutputLevel. | |
378 LOG(INFO) << "Missing output devices: skipping test..."; | |
379 return; | |
380 } | |
381 | |
382 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | |
383 switches::kUseFakeDeviceForMediaStream)) | |
384 << "Must run with fake devices since the test will explicitly look " | |
385 << "for the fake device signal."; | |
386 | |
387 MakeTypicalPeerConnectionCall(base::StringPrintf( | |
388 "callAndEnsureAudioTrackUnmutingWorks(%s);", kUseLenientAudioChecking)); | 381 "callAndEnsureAudioTrackUnmutingWorks(%s);", kUseLenientAudioChecking)); |
389 } | 382 } |
390 | 383 |
391 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CallAndVerifyVideoMutingWorks) { | 384 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CallAndVerifyVideoMutingWorks) { |
392 MakeTypicalPeerConnectionCall("callAndEnsureVideoTrackMutingWorks();"); | 385 MakeTypicalPeerConnectionCall("callAndEnsureVideoTrackMutingWorks();"); |
393 } | 386 } |
394 | 387 |
395 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 388 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
396 // Timing out on ARM linux bot: http://crbug.com/238490 | 389 // Timing out on ARM linux bot: http://crbug.com/238490 |
397 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump | 390 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 455 |
463 EXPECT_TRUE(base::PathExists(dump_file)); | 456 EXPECT_TRUE(base::PathExists(dump_file)); |
464 int64 file_size = 0; | 457 int64 file_size = 0; |
465 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size)); | 458 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size)); |
466 EXPECT_EQ(0, file_size); | 459 EXPECT_EQ(0, file_size); |
467 | 460 |
468 base::DeleteFile(dump_file, false); | 461 base::DeleteFile(dump_file, false); |
469 } | 462 } |
470 | 463 |
471 } // namespace content | 464 } // namespace content |
OLD | NEW |