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

Unified Diff: media/audio/audio_manager_factory_unittest.cc

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed AudioManagerBase::Shutdown 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: media/audio/audio_manager_factory_unittest.cc
diff --git a/media/audio/audio_manager_factory_unittest.cc b/media/audio/audio_manager_factory_unittest.cc
index 1d13c2e0269751ce48c34b9ad754823f0145a42f..3ac6810242533e99798aa3c6215c8a60b78c6871 100644
--- a/media/audio/audio_manager_factory_unittest.cc
+++ b/media/audio/audio_manager_factory_unittest.cc
@@ -3,9 +3,9 @@
// found in the LICENSE file.
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "media/audio/audio_manager.h"
#include "media/audio/audio_manager_factory.h"
-#include "media/audio/fake_audio_log_factory.h"
#include "media/audio/fake_audio_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -17,11 +17,17 @@ class FakeAudioManagerFactory : public AudioManagerFactory {
FakeAudioManagerFactory() {}
~FakeAudioManagerFactory() override {}
- AudioManager* CreateInstance(AudioLogFactory* audio_log_factory) override {
+ ScopedAudioManagerPtr CreateInstance(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
+ AudioLogFactory* audio_log_factory) override {
+ ScopedAudioManagerPtr instance(
+ new FakeAudioManager(std::move(task_runner),
+ std::move(worker_task_runner), audio_log_factory));
// |created_instance_| is used for verifying. Ownership is transferred to
// caller.
- created_instance_ = new FakeAudioManager(audio_log_factory);
- return created_instance_;
+ created_instance_ = instance.get();
+ return instance;
}
AudioManager* created_instance() { return created_instance_; }
@@ -34,8 +40,11 @@ class FakeAudioManagerFactory : public AudioManagerFactory {
// Verifies that SetFactory has the intended effect.
TEST(AudioManagerFactoryTest, CreateInstance) {
+ base::MessageLoop message_loop;
// Create an audio manager and verify that it is not null.
- scoped_ptr<AudioManager> manager(AudioManager::CreateForTesting());
+ ScopedAudioManagerPtr manager =
+ AudioManager::CreateForTesting(message_loop.task_runner());
+ message_loop.RunUntilIdle();
ASSERT_NE(nullptr, manager.get());
manager.reset();
@@ -46,12 +55,13 @@ TEST(AudioManagerFactoryTest, CreateInstance) {
// Create the AudioManager instance. Verify that it matches the instance
// provided by the factory.
- manager.reset(AudioManager::CreateForTesting());
+ manager = AudioManager::CreateForTesting(message_loop.task_runner());
+ message_loop.RunUntilIdle();
ASSERT_NE(nullptr, manager.get());
ASSERT_EQ(factory->created_instance(), manager.get());
// Reset AudioManagerFactory to prevent factory from persisting to other
- // tests on the same process. |manager| will reset when scope exits.
+ // tests on the same process.
AudioManager::ResetFactoryForTesting();
}

Powered by Google App Engine
This is Rietveld 408576698