Chromium Code Reviews| Index: webrtc/modules/audio_mixer/audio_mixer_impl_unittest.cc |
| diff --git a/webrtc/modules/audio_mixer/audio_mixer_impl_unittest.cc b/webrtc/modules/audio_mixer/audio_mixer_impl_unittest.cc |
| index 3ac61892b3094614c9ab2219e913200c407cc590..ac7783b1e8e6d725017cc28338597e91bdd5b31a 100644 |
| --- a/webrtc/modules/audio_mixer/audio_mixer_impl_unittest.cc |
| +++ b/webrtc/modules/audio_mixer/audio_mixer_impl_unittest.cc |
| @@ -21,7 +21,8 @@ |
| #include "webrtc/modules/audio_mixer/default_output_rate_calculator.h" |
| #include "webrtc/rtc_base/bind.h" |
| #include "webrtc/rtc_base/checks.h" |
| -#include "webrtc/rtc_base/thread.h" |
| +#include "webrtc/rtc_base/event.h" |
| +#include "webrtc/rtc_base/task_queue.h" |
| #include "webrtc/test/gmock.h" |
| using testing::_; |
| @@ -373,23 +374,27 @@ TEST(AudioMixer, RampedOutSourcesShouldNotBeMarkedMixed) { |
| // This test checks that the initialization and participant addition |
| // can be done on a different thread. |
| TEST(AudioMixer, ConstructFromOtherThread) { |
| - std::unique_ptr<rtc::Thread> init_thread = rtc::Thread::Create(); |
| - std::unique_ptr<rtc::Thread> participant_thread = rtc::Thread::Create(); |
| - init_thread->Start(); |
| - const auto mixer = init_thread->Invoke<rtc::scoped_refptr<AudioMixer>>( |
| - RTC_FROM_HERE, |
| - // Since AudioMixerImpl::Create is overloaded, we have to |
| - // specify the type of which version we want. |
| - static_cast<rtc::scoped_refptr<AudioMixerImpl>(*)()>( |
| - &AudioMixerImpl::Create)); |
| + rtc::TaskQueue init_queue("init"); |
| + rtc::scoped_refptr<AudioMixer> mixer; |
| + rtc::Event event(false, false); |
| + init_queue.PostTask([&mixer, &event]() { |
| + mixer = AudioMixerImpl::Create(); |
| + event.Set(); |
| + }); |
| + event.Wait(rtc::Event::kForever); |
| + |
| MockMixerAudioSource participant; |
| + EXPECT_CALL(participant, PreferredSampleRate()) |
|
minyue-webrtc
2017/07/11 11:16:20
would you explain why this additional expected cal
tommi
2017/07/11 11:58:36
This call is and should always be made so I'm sett
minyue-webrtc
2017/07/11 13:03:22
Acknowledged.
I also advice using StrictMock<Mock
tommi
2017/07/11 13:13:29
Yes that would be an improvement. This CL is abou
|
| + .WillRepeatedly(Return(kDefaultSampleRateHz)); |
| ResetFrame(participant.fake_frame()); |
| - participant_thread->Start(); |
| - EXPECT_TRUE(participant_thread->Invoke<int>( |
| - RTC_FROM_HERE, |
| - rtc::Bind(&AudioMixer::AddSource, mixer.get(), &participant))); |
| + rtc::TaskQueue participant_queue("participant"); |
| + participant_queue.PostTask([&mixer, &event, &participant]() { |
| + mixer->AddSource(&participant); |
| + event.Set(); |
| + }); |
| + event.Wait(rtc::Event::kForever); |
| EXPECT_CALL(participant, GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) |
| .Times(Exactly(1)); |