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

Side by Side Diff: content/renderer/media/media_stream_audio_unittest.cc

Issue 2416123002: Stop media stream source when audio capture error occurs. (Closed)
Patch Set: Fix unit tests. Created 4 years, 2 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/message_loop/message_loop.h"
8 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
9 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
10 #include "base/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
11 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
12 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
13 #include "content/public/renderer/media_stream_audio_sink.h" 14 #include "content/public/renderer/media_stream_audio_sink.h"
14 #include "content/renderer/media/media_stream_audio_source.h" 15 #include "content/renderer/media/media_stream_audio_source.h"
15 #include "content/renderer/media/media_stream_audio_track.h" 16 #include "content/renderer/media/media_stream_audio_track.h"
16 #include "media/base/audio_bus.h" 17 #include "media/base/audio_bus.h"
17 #include "media/base/audio_parameters.h" 18 #include "media/base/audio_parameters.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 return static_cast<FakeMediaStreamAudioSource*>( 259 return static_cast<FakeMediaStreamAudioSource*>(
259 MediaStreamAudioSource::From(blink_audio_source_)); 260 MediaStreamAudioSource::From(blink_audio_source_));
260 } 261 }
261 262
262 MediaStreamAudioTrack* track() const { 263 MediaStreamAudioTrack* track() const {
263 return MediaStreamAudioTrack::From(blink_audio_track_); 264 return MediaStreamAudioTrack::From(blink_audio_track_);
264 } 265 }
265 266
266 blink::WebMediaStreamSource blink_audio_source_; 267 blink::WebMediaStreamSource blink_audio_source_;
267 blink::WebMediaStreamTrack blink_audio_track_; 268 blink::WebMediaStreamTrack blink_audio_track_;
269
270 base::MessageLoop message_loop_;
268 }; 271 };
269 272
270 // Tests that a simple source-->track-->sink connection and audio data flow 273 // Tests that a simple source-->track-->sink connection and audio data flow
271 // works. 274 // works.
272 TEST_F(MediaStreamAudioTest, BasicUsage) { 275 TEST_F(MediaStreamAudioTest, BasicUsage) {
273 // Create the source, but it should not be started yet. 276 // Create the source, but it should not be started yet.
274 ASSERT_FALSE(source()); 277 ASSERT_FALSE(source());
275 blink_audio_source_.setExtraData(new FakeMediaStreamAudioSource()); 278 blink_audio_source_.setExtraData(new FakeMediaStreamAudioSource());
276 ASSERT_TRUE(source()); 279 ASSERT_TRUE(source());
277 EXPECT_FALSE(source()->was_started()); 280 EXPECT_FALSE(source()->was_started());
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // enabled state of the second track and sink. They should still be disabled, 447 // enabled state of the second track and sink. They should still be disabled,
445 // with silent audio being consumed at the sink. 448 // with silent audio being consumed at the sink.
446 EXPECT_EQ(FakeMediaStreamAudioSink::WAS_DISABLED, sink.enable_state()); 449 EXPECT_EQ(FakeMediaStreamAudioSink::WAS_DISABLED, sink.enable_state());
447 EXPECT_TRUE(sink.is_audio_silent()); 450 EXPECT_TRUE(sink.is_audio_silent());
448 451
449 MediaStreamAudioTrack::From(another_blink_track)->RemoveSink(&another_sink); 452 MediaStreamAudioTrack::From(another_blink_track)->RemoveSink(&another_sink);
450 track()->RemoveSink(&sink); 453 track()->RemoveSink(&sink);
451 } 454 }
452 455
453 } // namespace content 456 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698