OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/synchronization/waitable_event.h" | 5 #include "base/synchronization/waitable_event.h" |
6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
7 #include "content/renderer/media/media_stream_audio_source.h" | 7 #include "content/renderer/media/media_stream_audio_source.h" |
8 #include "content/renderer/media/mock_media_constraint_factory.h" | 8 #include "content/renderer/media/mock_media_constraint_factory.h" |
9 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 9 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
10 #include "content/renderer/media/webrtc_audio_capturer.h" | 10 #include "content/renderer/media/webrtc_audio_capturer.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 const media::AudioParameters& audio_params() const { return params_; } | 161 const media::AudioParameters& audio_params() const { return params_; } |
162 | 162 |
163 private: | 163 private: |
164 media::AudioParameters params_; | 164 media::AudioParameters params_; |
165 }; | 165 }; |
166 | 166 |
167 } // namespace | 167 } // namespace |
168 | 168 |
169 class WebRtcLocalAudioTrackTest : public ::testing::Test { | 169 class WebRtcLocalAudioTrackTest : public ::testing::Test { |
170 protected: | 170 protected: |
171 virtual void SetUp() override { | 171 void SetUp() override { |
172 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 172 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
173 media::CHANNEL_LAYOUT_STEREO, 2, 48000, 16, 480); | 173 media::CHANNEL_LAYOUT_STEREO, 2, 48000, 16, 480); |
174 MockMediaConstraintFactory constraint_factory; | 174 MockMediaConstraintFactory constraint_factory; |
175 blink_source_.initialize("dummy", blink::WebMediaStreamSource::TypeAudio, | 175 blink_source_.initialize("dummy", blink::WebMediaStreamSource::TypeAudio, |
176 "dummy"); | 176 "dummy"); |
177 MediaStreamAudioSource* audio_source = new MediaStreamAudioSource(); | 177 MediaStreamAudioSource* audio_source = new MediaStreamAudioSource(); |
178 blink_source_.setExtraData(audio_source); | 178 blink_source_.setExtraData(audio_source); |
179 | 179 |
180 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, | 180 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, |
181 std::string(), std::string()); | 181 std::string(), std::string()); |
182 capturer_ = WebRtcAudioCapturer::CreateCapturer( | 182 capturer_ = WebRtcAudioCapturer::CreateCapturer( |
183 -1, device, constraint_factory.CreateWebMediaConstraints(), NULL, | 183 -1, device, constraint_factory.CreateWebMediaConstraints(), NULL, |
184 audio_source); | 184 audio_source); |
185 audio_source->SetAudioCapturer(capturer_.get()); | 185 audio_source->SetAudioCapturer(capturer_.get()); |
186 capturer_source_ = new MockCapturerSource(capturer_.get()); | 186 capturer_source_ = new MockCapturerSource(capturer_.get()); |
187 EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), -1)) | 187 EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), -1)) |
188 .WillOnce(Return()); | 188 .WillOnce(Return()); |
189 EXPECT_CALL(*capturer_source_.get(), SetAutomaticGainControl(true)); | 189 EXPECT_CALL(*capturer_source_.get(), SetAutomaticGainControl(true)); |
190 EXPECT_CALL(*capturer_source_.get(), OnStart()); | 190 EXPECT_CALL(*capturer_source_.get(), OnStart()); |
191 capturer_->SetCapturerSourceForTesting(capturer_source_, params_); | 191 capturer_->SetCapturerSourceForTesting(capturer_source_, params_); |
192 } | 192 } |
193 | 193 |
194 virtual void TearDown() override { | 194 void TearDown() override { |
195 blink_source_.reset(); | 195 blink_source_.reset(); |
196 blink::WebHeap::collectAllGarbageForTesting(); | 196 blink::WebHeap::collectAllGarbageForTesting(); |
197 } | 197 } |
198 | 198 |
199 media::AudioParameters params_; | 199 media::AudioParameters params_; |
200 blink::WebMediaStreamSource blink_source_; | 200 blink::WebMediaStreamSource blink_source_; |
201 scoped_refptr<MockCapturerSource> capturer_source_; | 201 scoped_refptr<MockCapturerSource> capturer_source_; |
202 scoped_refptr<WebRtcAudioCapturer> capturer_; | 202 scoped_refptr<WebRtcAudioCapturer> capturer_; |
203 }; | 203 }; |
204 | 204 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 // Stopping the new source will stop the second track. | 534 // Stopping the new source will stop the second track. |
535 EXPECT_CALL(*source.get(), OnStop()).Times(1); | 535 EXPECT_CALL(*source.get(), OnStop()).Times(1); |
536 capturer->Stop(); | 536 capturer->Stop(); |
537 | 537 |
538 // Even though this test don't use |capturer_source_| it will be stopped | 538 // Even though this test don't use |capturer_source_| it will be stopped |
539 // during teardown of the test harness. | 539 // during teardown of the test harness. |
540 EXPECT_CALL(*capturer_source_.get(), OnStop()); | 540 EXPECT_CALL(*capturer_source_.get(), OnStop()); |
541 } | 541 } |
542 | 542 |
543 } // namespace content | 543 } // namespace content |
OLD | NEW |