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

Unified Diff: media/audio/audio_input_controller_unittest.cc

Issue 2941773002: Added initial muted state to stream creation callback, to avoid races. (Closed)
Patch Set: Added mute information to DoCompleteCreation log message. Created 3 years, 6 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
« no previous file with comments | « media/audio/audio_input_controller.cc ('k') | media/audio/audio_input_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_input_controller_unittest.cc
diff --git a/media/audio/audio_input_controller_unittest.cc b/media/audio/audio_input_controller_unittest.cc
index fc290e655ee5b0dfcef543a210c84448e47d4f42..0b8ef9219e68135c1c0d9565ba9612f33f990b7d 100644
--- a/media/audio/audio_input_controller_unittest.cc
+++ b/media/audio/audio_input_controller_unittest.cc
@@ -61,7 +61,8 @@ class MockAudioInputControllerEventHandler
public:
MockAudioInputControllerEventHandler() {}
- MOCK_METHOD1(OnCreated, void(AudioInputController* controller));
+ MOCK_METHOD2(OnCreated,
+ void(AudioInputController* controller, bool initially_muted));
MOCK_METHOD2(OnError, void(AudioInputController* controller,
AudioInputController::ErrorCode error_code));
MOCK_METHOD2(OnLog,
@@ -136,7 +137,7 @@ TEST_F(AudioInputControllerTest, CreateAndClose) {
audio_manager_.get(), &event_handler, &sync_writer, nullptr, params,
AudioDeviceDescription::kDefaultDeviceId, false);
ASSERT_TRUE(controller.get());
- EXPECT_CALL(event_handler, OnCreated(controller.get())).Times(Exactly(1));
+ EXPECT_CALL(event_handler, OnCreated(controller.get(), _)).Times(Exactly(1));
EXPECT_CALL(event_handler, OnLog(controller.get(), _)).Times(Exactly(3));
EXPECT_CALL(sync_writer, Close()).Times(Exactly(1));
ResumeAudioThread();
@@ -151,7 +152,7 @@ TEST_F(AudioInputControllerTest, RecordAndClose) {
int count = 0;
// OnCreated() will be called once.
- EXPECT_CALL(event_handler, OnCreated(NotNull()))
+ EXPECT_CALL(event_handler, OnCreated(NotNull(), _))
.Times(Exactly(1));
// Write() should be called ten times.
@@ -186,7 +187,7 @@ TEST_F(AudioInputControllerTest, SamplesPerPacketTooLarge) {
MockSyncWriter sync_writer;
// OnCreated() shall not be called in this test.
- EXPECT_CALL(event_handler, OnCreated(NotNull())).Times(Exactly(0));
+ EXPECT_CALL(event_handler, OnCreated(NotNull(), _)).Times(Exactly(0));
AudioParameters params(AudioParameters::AUDIO_FAKE,
kChannelLayout,
@@ -205,7 +206,7 @@ TEST_F(AudioInputControllerTest, CloseTwice) {
MockSyncWriter sync_writer;
// OnCreated() will be called only once.
- EXPECT_CALL(event_handler, OnCreated(NotNull())).Times(Exactly(1));
+ EXPECT_CALL(event_handler, OnCreated(NotNull(), _)).Times(Exactly(1));
EXPECT_CALL(event_handler, OnLog(_, _)).Times(AnyNumber());
// This callback should still only be called once.
EXPECT_CALL(sync_writer, Close()).Times(Exactly(1));
@@ -252,7 +253,8 @@ TEST_F(AudioInputControllerTest, TestOnmutedCallbackInitiallyUnmuted) {
base::RunLoop unmute_run_loop;
base::RunLoop mute_run_loop;
base::RunLoop setup_run_loop;
- EXPECT_CALL(event_handler, OnCreated(_)).Times(Exactly(1));
+ EXPECT_CALL(event_handler, OnCreated(_, false))
+ .WillOnce(InvokeWithoutArgs([&] { setup_run_loop.QuitWhenIdle(); }));
EXPECT_CALL(event_handler, OnLog(_, _)).Times(Exactly(3));
EXPECT_CALL(sync_writer, Close()).Times(Exactly(1));
EXPECT_CALL(event_handler, OnMuted(_, true))
@@ -265,7 +267,7 @@ TEST_F(AudioInputControllerTest, TestOnmutedCallbackInitiallyUnmuted) {
audio_manager_.get(), &event_handler, &sync_writer, nullptr, params,
AudioDeviceDescription::kDefaultDeviceId, false);
ASSERT_TRUE(controller.get());
- setup_run_loop.RunUntilIdle();
+ RunLoopWithTimeout(&setup_run_loop, timeout);
FakeAudioInputStream::SetGlobalMutedState(true);
RunLoopWithTimeout(&mute_run_loop, timeout);
@@ -288,11 +290,10 @@ TEST_F(AudioInputControllerTest, TestOnmutedCallbackInitiallyMuted) {
base::RunLoop unmute_run_loop;
base::RunLoop setup_run_loop;
- EXPECT_CALL(event_handler, OnCreated(_)).Times(Exactly(1));
+ EXPECT_CALL(event_handler, OnCreated(_, true))
+ .WillOnce(InvokeWithoutArgs([&] { setup_run_loop.QuitWhenIdle(); }));
EXPECT_CALL(event_handler, OnLog(_, _)).Times(Exactly(3));
EXPECT_CALL(sync_writer, Close()).Times(Exactly(1));
- EXPECT_CALL(event_handler, OnMuted(_, true))
- .WillOnce(InvokeWithoutArgs([&] { setup_run_loop.QuitWhenIdle(); }));
EXPECT_CALL(event_handler, OnMuted(_, false))
.WillOnce(InvokeWithoutArgs([&] { unmute_run_loop.Quit(); }));
« no previous file with comments | « media/audio/audio_input_controller.cc ('k') | media/audio/audio_input_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698