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

Unified Diff: content/renderer/media/webrtc_audio_capturer_unittest.cc

Issue 1721273002: MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mcasas's 1st round comments, plus REBASE. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webrtc_audio_capturer_unittest.cc
diff --git a/content/renderer/media/webrtc_audio_capturer_unittest.cc b/content/renderer/media/webrtc_audio_capturer_unittest.cc
index a93aede2bca997dc9877fd076f485beb06d9aacf..3abd3cdfcedba44496f0d0db09495c41d0125004 100644
--- a/content/renderer/media/webrtc_audio_capturer_unittest.cc
+++ b/content/renderer/media/webrtc_audio_capturer_unittest.cc
@@ -76,25 +76,28 @@ class WebRtcAudioCapturerTest : public testing::Test {
void VerifyAudioParams(const blink::WebMediaConstraints& constraints,
bool need_audio_processing) {
- capturer_ = WebRtcAudioCapturer::CreateCapturer(
- -1, StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "", "",
- params_.sample_rate(), params_.channel_layout(),
- params_.frames_per_buffer()),
- constraints, NULL, NULL);
- capturer_source_ = new MockCapturerSource();
- EXPECT_CALL(*capturer_source_.get(), Initialize(_, capturer_.get(), -1));
- EXPECT_CALL(*capturer_source_.get(), SetAutomaticGainControl(true));
- EXPECT_CALL(*capturer_source_.get(), Start());
- capturer_->SetCapturerSource(capturer_source_, params_);
+ const scoped_ptr<WebRtcAudioCapturer> capturer =
+ WebRtcAudioCapturer::CreateCapturer(
+ -1, StreamDeviceInfo(
+ MEDIA_DEVICE_AUDIO_CAPTURE, "", "", params_.sample_rate(),
+ params_.channel_layout(), params_.frames_per_buffer()),
+ constraints, nullptr, nullptr);
+ const scoped_refptr<MockCapturerSource> capturer_source(
+ new MockCapturerSource());
+ EXPECT_CALL(*capturer_source.get(), Initialize(_, capturer.get(), -1));
+ EXPECT_CALL(*capturer_source.get(), SetAutomaticGainControl(true));
+ EXPECT_CALL(*capturer_source.get(), Start());
+ capturer->SetCapturerSource(capturer_source, params_);
scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter(
WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL));
- track_.reset(new WebRtcLocalAudioTrack(adapter.get(), capturer_, NULL));
- track_->Start();
+ const scoped_ptr<WebRtcLocalAudioTrack> track(
+ new WebRtcLocalAudioTrack(adapter.get()));
+ capturer->AddTrack(track.get());
// Connect a mock sink to the track.
scoped_ptr<MockMediaStreamAudioSink> sink(new MockMediaStreamAudioSink());
- track_->AddSink(sink.get());
+ track->AddSink(sink.get());
int delay_ms = 65;
bool key_pressed = true;
@@ -105,22 +108,19 @@ class WebRtcAudioCapturerTest : public testing::Test {
media::AudioCapturerSource::CaptureCallback* callback =
static_cast<media::AudioCapturerSource::CaptureCallback*>(
- capturer_.get());
+ capturer.get());
// Verify the sink is getting the correct values.
EXPECT_CALL(*sink, FormatIsSet());
EXPECT_CALL(*sink, OnDataCallback()).Times(AtLeast(1));
callback->Capture(audio_bus.get(), delay_ms, volume, key_pressed);
- track_->RemoveSink(sink.get());
- EXPECT_CALL(*capturer_source_.get(), Stop());
- capturer_->Stop();
+ track->RemoveSink(sink.get());
+ EXPECT_CALL(*capturer_source.get(), Stop());
+ capturer->Stop();
}
media::AudioParameters params_;
- scoped_refptr<MockCapturerSource> capturer_source_;
- scoped_refptr<WebRtcAudioCapturer> capturer_;
- scoped_ptr<WebRtcLocalAudioTrack> track_;
};
TEST_F(WebRtcAudioCapturerTest, VerifyAudioParamsWithAudioProcessing) {
@@ -137,12 +137,11 @@ TEST_F(WebRtcAudioCapturerTest, FailToCreateCapturerWithWrongConstraints) {
// Set a non-audio constraint.
constraint_factory.basic().width.setExact(240);
- scoped_refptr<WebRtcAudioCapturer> capturer(
- WebRtcAudioCapturer::CreateCapturer(
- 0, StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "", "",
- params_.sample_rate(), params_.channel_layout(),
- params_.frames_per_buffer()),
- constraint_factory.CreateWebMediaConstraints(), NULL, NULL));
+ scoped_ptr<WebRtcAudioCapturer> capturer(WebRtcAudioCapturer::CreateCapturer(
+ 0, StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "", "",
+ params_.sample_rate(), params_.channel_layout(),
+ params_.frames_per_buffer()),
+ constraint_factory.CreateWebMediaConstraints(), NULL, NULL));
EXPECT_TRUE(capturer.get() == NULL);
}

Powered by Google App Engine
This is Rietveld 408576698