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

Unified Diff: components/audio_modem/audio_player_unittest.cc

Issue 1901583005: Revert of Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « components/audio_modem/audio_player_impl.cc ('k') | components/audio_modem/audio_recorder_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2a96c0f9b23cda68b64c1de87cf439f93397e8c1..153e6c0b23d954e4ffbac0ec2606fc014e9906f2 100644
--- a/components/audio_modem/audio_player_unittest.cc
+++ b/components/audio_modem/audio_player_unittest.cc
@@ -8,12 +8,11 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/run_loop.h"
-#include "base/test/test_message_loop.h"
-#include "base/thread_task_runner_handle.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"
#include "components/audio_modem/test/random_samples.h"
+#include "media/audio/audio_manager.h"
#include "media/audio/audio_manager_base.h"
#include "media/base/audio_bus.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -78,9 +77,8 @@
public base::SupportsWeakPtr<AudioPlayerTest> {
public:
AudioPlayerTest() : buffer_index_(0), player_(nullptr) {
- audio_manager_ = media::AudioManager::CreateForTesting(
- base::ThreadTaskRunnerHandle::Get());
- base::RunLoop().RunUntilIdle();
+ if (!media::AudioManager::Get())
+ media::AudioManager::CreateForTesting();
}
~AudioPlayerTest() override { DeletePlayer(); }
@@ -93,7 +91,6 @@
kMaxFrameCount,
base::Bind(&AudioPlayerTest::GatherSamples, AsWeakPtr())));
player_->Initialize();
- base::RunLoop().RunUntilIdle();
}
void DeletePlayer() {
@@ -101,7 +98,6 @@
return;
player_->Finalize();
player_ = nullptr;
- base::RunLoop().RunUntilIdle();
}
void PlayAndVerifySamples(
@@ -111,8 +107,8 @@
buffer_ = media::AudioBus::Create(1, kMaxFrameCount);
buffer_index_ = 0;
player_->Play(samples);
+ player_->FlushAudioLoopForTesting();
player_->Stop();
- base::RunLoop().RunUntilIdle();
int differences = 0;
for (int i = 0; i < kMaxFrameCount; ++i) {
@@ -133,20 +129,19 @@
protected:
bool IsPlaying() {
- base::RunLoop().RunUntilIdle();
+ player_->FlushAudioLoopForTesting();
return player_->is_playing_;
}
static const int kDefaultFrameCount = 1024;
static const int kMaxFrameCount = 1024 * 100;
- base::TestMessageLoop 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) {
@@ -156,19 +151,16 @@
player_->Play(samples);
EXPECT_TRUE(IsPlaying());
-
- player_->Stop();
- EXPECT_FALSE(IsPlaying());
-
- player_->Play(samples);
- EXPECT_TRUE(IsPlaying());
-
- player_->Stop();
- EXPECT_FALSE(IsPlaying());
-
- player_->Play(samples);
- EXPECT_TRUE(IsPlaying());
-
+ player_->Stop();
+ EXPECT_FALSE(IsPlaying());
+ player_->Play(samples);
+
+ EXPECT_TRUE(IsPlaying());
+ player_->Stop();
+ EXPECT_FALSE(IsPlaying());
+ player_->Play(samples);
+
+ EXPECT_TRUE(IsPlaying());
player_->Stop();
EXPECT_FALSE(IsPlaying());
« no previous file with comments | « components/audio_modem/audio_player_impl.cc ('k') | components/audio_modem/audio_recorder_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698