OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 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. | |
4 | |
5 #include "base/command_line.h" | |
6 #include "base/files/file_util.h" | |
7 #include "base/threading/platform_thread.h" | |
8 #include "build/build_config.h" | |
9 #include "content/browser/web_contents/web_contents_impl.h" | |
10 #include "content/public/common/content_switches.h" | |
11 #include "content/public/common/webrtc_ip_handling_policy.h" | |
12 #include "content/public/test/browser_test_utils.h" | |
13 #include "content/public/test/content_browser_test_utils.h" | |
14 #include "content/public/test/test_utils.h" | |
15 #include "content/test/webrtc_content_browsertest_base.h" | |
16 #include "media/audio/audio_manager.h" | |
17 #include "media/base/media_switches.h" | |
18 #include "net/test/embedded_test_server/embedded_test_server.h" | |
19 | |
20 namespace content { | |
21 | |
22 #if defined(OS_ANDROID) && defined(ADDRESS_SANITIZER) | |
23 // Renderer crashes under Android ASAN: https://crbug.com/408496. | |
24 #define MAYBE_WebRtcBrowserAudioTest DISABLED_WebRtcBrowserAudioTest | |
25 #else | |
26 #define MAYBE_WebRtcBrowserAudioTest WebRtcBrowserAudioTest | |
27 #endif | |
28 | |
29 // This class tests the scenario when permission to access mic or camera is | |
30 // granted. | |
31 class MAYBE_WebRtcBrowserAudioTest : public WebRtcContentBrowserTest { | |
32 public: | |
33 MAYBE_WebRtcBrowserAudioTest() {} | |
34 ~MAYBE_WebRtcBrowserAudioTest() override {} | |
35 | |
36 void SetUpCommandLine(base::CommandLine* command_line) override { | |
37 WebRtcContentBrowserTest::SetUpCommandLine(command_line); | |
38 // Automatically grant device permission. | |
39 AppendUseFakeUIForMediaStreamFlag(); | |
40 } | |
41 | |
42 protected: | |
43 // Convenience method for making calls that detect if audio os playing (which | |
44 // has some special prerequisites, such that there needs to be an audio output | |
45 // device on the executing machine). | |
46 void MakeAudioDetectingPeerConnectionCall(const std::string& javascript) { | |
47 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { | |
48 // Bots with no output devices will force the audio code into a state | |
49 // where it doesn't manage to set either the low or high latency path. | |
50 // This test will compute useless values in that case, so skip running on | |
51 // such bots (see crbug.com/326338). | |
52 LOG(INFO) << "Missing output devices: skipping test..."; | |
53 return; | |
54 } | |
55 | |
56 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( | |
57 switches::kUseFakeDeviceForMediaStream)) | |
58 << "Must run with fake devices since the test will explicitly look " | |
59 << "for the fake device signal."; | |
60 | |
61 MakeTypicalCall(javascript, "/media/peerconnection-call-audio.html"); | |
62 } | |
63 }; | |
64 | |
65 // Causes asserts in libjingle: http://crbug.com/484826. | |
66 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserAudioTest, | |
67 CanMakeVideoCallAndThenRenegotiateToAudio) { | |
phoglund_chromium
2016/07/22 08:53:28
So this test worked? In that case you should remov
ehmaldonado_chromium
2016/07/22 08:59:11
Yes it worked.
Done.
| |
68 MakeAudioDetectingPeerConnectionCall( | |
69 "callAndRenegotiateToAudio({audio: true, video:true}, {audio: true});"); | |
70 } | |
71 | |
72 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserAudioTest, | |
73 EstablishAudioVideoCallAndEnsureAudioIsPlaying) { | |
74 MakeAudioDetectingPeerConnectionCall( | |
75 "callAndEnsureAudioIsPlaying({audio:true, video:true});"); | |
76 } | |
77 | |
78 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserAudioTest, | |
79 EstablishAudioOnlyCallAndEnsureAudioIsPlaying) { | |
80 MakeAudioDetectingPeerConnectionCall( | |
81 "callAndEnsureAudioIsPlaying({audio:true});"); | |
82 } | |
83 | |
84 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserAudioTest, | |
85 EstablishIsac16KCallAndEnsureAudioIsPlaying) { | |
86 MakeAudioDetectingPeerConnectionCall( | |
87 "callWithIsac16KAndEnsureAudioIsPlaying({audio:true});"); | |
88 } | |
89 | |
90 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserAudioTest, | |
91 EstablishAudioVideoCallAndVerifyRemoteMutingWorks) { | |
92 MakeAudioDetectingPeerConnectionCall( | |
93 "callAndEnsureRemoteAudioTrackMutingWorks();"); | |
94 } | |
95 | |
96 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserAudioTest, | |
97 EstablishAudioVideoCallAndVerifyLocalMutingWorks) { | |
98 MakeAudioDetectingPeerConnectionCall( | |
99 "callAndEnsureLocalAudioTrackMutingWorks();"); | |
100 } | |
101 | |
102 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserAudioTest, | |
103 EnsureLocalVideoMuteDoesntMuteAudio) { | |
104 MakeAudioDetectingPeerConnectionCall( | |
105 "callAndEnsureLocalVideoMutingDoesntMuteAudio();"); | |
106 } | |
107 | |
108 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserAudioTest, | |
109 EnsureRemoteVideoMuteDoesntMuteAudio) { | |
110 MakeAudioDetectingPeerConnectionCall( | |
111 "callAndEnsureRemoteVideoMutingDoesntMuteAudio();"); | |
112 } | |
113 | |
114 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserAudioTest, | |
115 EstablishAudioVideoCallAndVerifyUnmutingWorks) { | |
116 MakeAudioDetectingPeerConnectionCall( | |
117 "callAndEnsureAudioTrackUnmutingWorks();"); | |
118 } | |
119 | |
120 } // namespace content | |
OLD | NEW |