diff options
author | Tommi <tommi@webrtc.org> | 2018-02-13 19:47:50 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2018-02-14 15:32:49 +0000 |
commit | 685615678a7dbf5b3a215784fef1c16b573ce8af (patch) | |
tree | fdb9b3909b87d0bb7458b031bf23071ac6a04010 /modules/audio_mixer | |
parent | db6145f055f197de70d0c4793025eef0a3b1eee9 (diff) | |
download | webrtc-685615678a7dbf5b3a215784fef1c16b573ce8af.tar.gz |
Introduce TaskQueueForTest.
This class adds a convenience method that allows *sending* a task
to the queue (as opposed to posting). Sending is essentially
Post+Wait, a pattern that we don't want to encourage use of
in production code, but is convenient to have from a testing
perspective and there are already several places in the
source code where we use it.
Change-Id: I6efd1b2257e6c641294bb6e4eb53b0021d9553ca
Bug: webrtc:8848
Reviewed-on: https://webrtc-review.googlesource.com/50441
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22022}
Diffstat (limited to 'modules/audio_mixer')
-rw-r--r-- | modules/audio_mixer/BUILD.gn | 2 | ||||
-rw-r--r-- | modules/audio_mixer/audio_mixer_impl_unittest.cc | 21 |
2 files changed, 7 insertions, 16 deletions
diff --git a/modules/audio_mixer/BUILD.gn b/modules/audio_mixer/BUILD.gn index e3443f30a3..ce46e76169 100644 --- a/modules/audio_mixer/BUILD.gn +++ b/modules/audio_mixer/BUILD.gn @@ -88,7 +88,7 @@ if (rtc_include_tests) { "../../audio/utility:audio_frame_operations", "../../rtc_base:checks", "../../rtc_base:rtc_base_approved", - "../../rtc_base:rtc_task_queue", + "../../rtc_base:rtc_task_queue_for_test", "../../test:test_support", ] } diff --git a/modules/audio_mixer/audio_mixer_impl_unittest.cc b/modules/audio_mixer/audio_mixer_impl_unittest.cc index 4461e6e038..bda470f654 100644 --- a/modules/audio_mixer/audio_mixer_impl_unittest.cc +++ b/modules/audio_mixer/audio_mixer_impl_unittest.cc @@ -21,8 +21,7 @@ #include "modules/audio_mixer/default_output_rate_calculator.h" #include "rtc_base/bind.h" #include "rtc_base/checks.h" -#include "rtc_base/event.h" -#include "rtc_base/task_queue.h" +#include "rtc_base/task_queue_for_test.h" #include "test/gmock.h" using testing::_; @@ -372,14 +371,9 @@ TEST(AudioMixer, RampedOutSourcesShouldNotBeMarkedMixed) { // This test checks that the initialization and participant addition // can be done on a different thread. TEST(AudioMixer, ConstructFromOtherThread) { - rtc::TaskQueue init_queue("init"); + rtc::test::TaskQueueForTest 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); + init_queue.SendTask([&mixer]() { mixer = AudioMixerImpl::Create(); }); MockMixerAudioSource participant; EXPECT_CALL(participant, PreferredSampleRate()) @@ -387,12 +381,9 @@ TEST(AudioMixer, ConstructFromOtherThread) { ResetFrame(participant.fake_frame()); - rtc::TaskQueue participant_queue("participant"); - participant_queue.PostTask([&mixer, &event, &participant]() { - mixer->AddSource(&participant); - event.Set(); - }); - event.Wait(rtc::Event::kForever); + rtc::test::TaskQueueForTest participant_queue("participant"); + participant_queue.SendTask( + [&mixer, &participant]() { mixer->AddSource(&participant); }); EXPECT_CALL(participant, GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) .Times(Exactly(1)); |