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

Unified Diff: webrtc/modules/audio_mixer/audio_mixer_impl_unittest.cc

Issue 2975883002: Remove dependency on rtc::Thread and rtc_base from audio_mixer_unittests. (Closed)
Patch Set: Created 3 years, 5 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 | « webrtc/modules/audio_mixer/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « webrtc/modules/audio_mixer/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698