Remove dependency on rtc::Thread and rtc_base from audio_mixer_unittests.

Instead, use a TaskQueue in the only test that required it.

BUG=none

Review-Url: https://codereview.webrtc.org/2975883002
Cr-Commit-Position: refs/heads/master@{#18969}
This commit is contained in:
tommi 2017-07-11 06:17:10 -07:00 committed by Commit Bot
parent 14c11a4712
commit c45d6d9c85
2 changed files with 20 additions and 15 deletions

View File

@ -90,8 +90,8 @@ if (rtc_include_tests) {
"..:module_api",
"../../api:audio_mixer_api",
"../../audio/utility:audio_frame_operations",
"../../base:rtc_base",
"../../base:rtc_base_approved",
"../../base:rtc_task_queue",
"../../test:test_support",
"//testing/gmock",
]

View File

@ -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())
.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));