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

Side by Side Diff: content/browser/media/webrtc_browsertest.cc

Issue 252703003: Wrote a test which exercises audio-only WebRTC calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made fixes to audio detection Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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/values.h" 8 #include "base/values.h"
9 #include "content/browser/media/webrtc_internals.h" 9 #include "content/browser/media/webrtc_internals.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
(...skipping 27 matching lines...) Expand all
38 virtual ~WebRtcBrowserTest() {} 38 virtual ~WebRtcBrowserTest() {}
39 39
40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
41 WebRtcContentBrowserTest::SetUpCommandLine(command_line); 41 WebRtcContentBrowserTest::SetUpCommandLine(command_line);
42 42
43 bool enable_audio_track_processing = GetParam(); 43 bool enable_audio_track_processing = GetParam();
44 if (enable_audio_track_processing) 44 if (enable_audio_track_processing)
45 command_line->AppendSwitch(switches::kEnableAudioTrackProcessing); 45 command_line->AppendSwitch(switches::kEnableAudioTrackProcessing);
46 } 46 }
47 47
48 // Convenience function since most peerconnection-call.html tests just load 48 // Convenience method since most peerconnection-call.html tests just load
49 // the page, kick off some javascript and wait for the title to change to OK. 49 // the page, kick off some javascript and wait for the title to change to OK.
50 void MakeTypicalPeerConnectionCall(const std::string& javascript) { 50 void MakeTypicalPeerConnectionCall(const std::string& javascript) {
51 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 51 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
52 52
53 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); 53 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
54 NavigateToURL(shell(), url); 54 NavigateToURL(shell(), url);
55 55
56 DisableOpusIfOnAndroid(); 56 DisableOpusIfOnAndroid();
57 ExecuteJavascriptAndWaitForOk(javascript); 57 ExecuteJavascriptAndWaitForOk(javascript);
58 } 58 }
59 59
60 // Convenience method for making calls that detect if audio os playing (which
61 // has some special prerequisites, such that there needs to be an audio output
62 // device on the executing machine).
63 void MakeAudioDetectingPeerConnectionCall(const std::string& javascript) {
64 if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
65 // Bots with no output devices will force the audio code into a state
66 // where it doesn't manage to set either the low or high latency path.
67 // This test will compute useless values in that case, so skip running on
68 // such bots (see crbug.com/326338).
69 LOG(INFO) << "Missing output devices: skipping test...";
70 return;
71 }
72
73 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
74 switches::kUseFakeDeviceForMediaStream))
75 << "Must run with fake devices since the test will explicitly look "
76 << "for the fake device signal.";
77
78 MakeTypicalPeerConnectionCall(javascript);
79 }
80
60 void DisableOpusIfOnAndroid() { 81 void DisableOpusIfOnAndroid() {
61 #if defined (OS_ANDROID) 82 #if defined (OS_ANDROID)
62 // Always force iSAC 16K on Android for now (Opus is broken). 83 // Always force iSAC 16K on Android for now (Opus is broken).
63 EXPECT_EQ("isac-forced", 84 EXPECT_EQ("isac-forced",
64 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();")); 85 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();"));
65 #endif 86 #endif
66 } 87 }
67 }; 88 };
68 89
69 static const bool kRunTestsWithFlag[] = { false, true }; 90 static const bool kRunTestsWithFlag[] = { false, true };
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CallAndModifyStream) { 313 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CallAndModifyStream) {
293 MakeTypicalPeerConnectionCall( 314 MakeTypicalPeerConnectionCall(
294 "callWithNewVideoMediaStreamLaterSwitchToAudio();"); 315 "callWithNewVideoMediaStreamLaterSwitchToAudio();");
295 } 316 }
296 317
297 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, AddTwoMediaStreamsToOnePC) { 318 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, AddTwoMediaStreamsToOnePC) {
298 MakeTypicalPeerConnectionCall("addTwoMediaStreamsToOneConnection();"); 319 MakeTypicalPeerConnectionCall("addTwoMediaStreamsToOneConnection();");
299 } 320 }
300 321
301 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, 322 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
302 EstablishAudioVideoCallAndMeasureOutputLevel) { 323 EstablishAudioVideoCallAndEnsureSoundPlays) {
303 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { 324 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
304 // Bots with no output devices will force the audio code into a different 325 "callAndEnsureAudioIsPlaying(%s, {audio: true, video: true});",
305 // path where it doesn't manage to set either the low or high latency path. 326 kUseLenientAudioChecking));
306 // This test will compute useless values in that case, so skip running on 327 }
307 // such bots (see crbug.com/326338).
308 LOG(INFO) << "Missing output devices: skipping test...";
309 return;
310 }
311 328
312 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( 329 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
313 switches::kUseFakeDeviceForMediaStream)) 330 EstablishAudioOnlyCallAndEnsureSoundPlays) {
314 << "Must run with fake devices since the test will explicitly look " 331 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
315 << "for the fake device signal."; 332 "callAndEnsureAudioIsPlaying(%s, {audio: true});",
316 333 kUseLenientAudioChecking));
317 MakeTypicalPeerConnectionCall(base::StringPrintf(
318 "callAndEnsureAudioIsPlaying(%s);", kUseLenientAudioChecking));
319 } 334 }
320 335
321 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, 336 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
322 EstablishAudioVideoCallAndVerifyMutingWorks) { 337 EstablishAudioVideoCallAndVerifyMutingWorks) {
323 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { 338 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
324 // See comment on EstablishAudioVideoCallAndMeasureOutputLevel.
325 LOG(INFO) << "Missing output devices: skipping test...";
326 return;
327 }
328
329 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
330 switches::kUseFakeDeviceForMediaStream))
331 << "Must run with fake devices since the test will explicitly look "
332 << "for the fake device signal.";
333
334 MakeTypicalPeerConnectionCall(base::StringPrintf(
335 "callAndEnsureAudioTrackMutingWorks(%s);", kUseLenientAudioChecking)); 339 "callAndEnsureAudioTrackMutingWorks(%s);", kUseLenientAudioChecking));
336 } 340 }
337 341
338 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, 342 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
339 EstablishAudioVideoCallAndVerifyUnmutingWorks) { 343 EstablishAudioVideoCallAndVerifyUnmutingWorks) {
340 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { 344 MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
341 // See comment on EstablishAudioVideoCallAndMeasureOutputLevel.
342 LOG(INFO) << "Missing output devices: skipping test...";
343 return;
344 }
345
346 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
347 switches::kUseFakeDeviceForMediaStream))
348 << "Must run with fake devices since the test will explicitly look "
349 << "for the fake device signal.";
350
351 MakeTypicalPeerConnectionCall(base::StringPrintf(
352 "callAndEnsureAudioTrackUnmutingWorks(%s);", kUseLenientAudioChecking)); 345 "callAndEnsureAudioTrackUnmutingWorks(%s);", kUseLenientAudioChecking));
353 } 346 }
354 347
355 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CallAndVerifyVideoMutingWorks) { 348 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CallAndVerifyVideoMutingWorks) {
356 MakeTypicalPeerConnectionCall("callAndEnsureVideoTrackMutingWorks();"); 349 MakeTypicalPeerConnectionCall("callAndEnsureVideoTrackMutingWorks();");
357 } 350 }
358 351
359 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 352 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
360 // Timing out on ARM linux bot: http://crbug.com/238490 353 // Timing out on ARM linux bot: http://crbug.com/238490
361 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump 354 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 419
427 EXPECT_TRUE(base::PathExists(dump_file)); 420 EXPECT_TRUE(base::PathExists(dump_file));
428 int64 file_size = 0; 421 int64 file_size = 0;
429 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size)); 422 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size));
430 EXPECT_EQ(0, file_size); 423 EXPECT_EQ(0, file_size);
431 424
432 base::DeleteFile(dump_file, false); 425 base::DeleteFile(dump_file, false);
433 } 426 }
434 427
435 } // namespace content 428 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/test/data/media/peerconnection-call.html » ('j') | content/test/data/media/webrtc_test_audio.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698