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

Unified Diff: components/audio_modem/audio_player_unittest.cc

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: speculative hack to fix test timeouts Created 4 years, 8 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
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) {

Powered by Google App Engine
This is Rietveld 408576698