| Index: components/audio_modem/audio_player_unittest.cc
|
| diff --git a/components/audio_modem/audio_player_unittest.cc b/components/audio_modem/audio_player_unittest.cc
|
| index 153e6c0b23d954e4ffbac0ec2606fc014e9906f2..82335ede0e138d344caeb2fdab89e6f63b3bf93d 100644
|
| --- a/components/audio_modem/audio_player_unittest.cc
|
| +++ b/components/audio_modem/audio_player_unittest.cc
|
| @@ -8,6 +8,7 @@
|
| #include "base/location.h"
|
| #include "base/macros.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "base/run_loop.h"
|
| #include "base/single_thread_task_runner.h"
|
| #include "components/audio_modem/audio_player_impl.h"
|
| #include "components/audio_modem/public/audio_modem_types.h"
|
| @@ -77,8 +78,8 @@ class AudioPlayerTest : public testing::Test,
|
| public base::SupportsWeakPtr<AudioPlayerTest> {
|
| public:
|
| AudioPlayerTest() : buffer_index_(0), player_(nullptr) {
|
| - if (!media::AudioManager::Get())
|
| - media::AudioManager::CreateForTesting();
|
| + audio_manager_ =
|
| + media::AudioManager::CreateForTesting(message_loop_.task_runner());
|
| }
|
|
|
| ~AudioPlayerTest() override { DeletePlayer(); }
|
| @@ -98,6 +99,7 @@ class AudioPlayerTest : public testing::Test,
|
| return;
|
| player_->Finalize();
|
| player_ = nullptr;
|
| + base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| void PlayAndVerifySamples(
|
| @@ -107,7 +109,7 @@ class AudioPlayerTest : public testing::Test,
|
| buffer_ = media::AudioBus::Create(1, kMaxFrameCount);
|
| buffer_index_ = 0;
|
| player_->Play(samples);
|
| - player_->FlushAudioLoopForTesting();
|
| + base::RunLoop().RunUntilIdle();
|
| player_->Stop();
|
|
|
| int differences = 0;
|
| @@ -129,19 +131,20 @@ class AudioPlayerTest : public testing::Test,
|
|
|
| protected:
|
| bool IsPlaying() {
|
| - player_->FlushAudioLoopForTesting();
|
| + base::RunLoop().RunUntilIdle();
|
| return player_->is_playing_;
|
| }
|
|
|
| static const int kDefaultFrameCount = 1024;
|
| static const int kMaxFrameCount = 1024 * 100;
|
|
|
| + base::MessageLoop message_loop_;
|
| + media::ScopedAudioManagerPtr audio_manager_;
|
| scoped_ptr<media::AudioBus> buffer_;
|
| int buffer_index_;
|
|
|
| // Deleted by calling Finalize() on the object.
|
| AudioPlayerImpl* player_;
|
| - base::MessageLoop message_loop_;
|
| };
|
|
|
| TEST_F(AudioPlayerTest, BasicPlayAndStop) {
|
|
|