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

Unified Diff: media/audio/audio_manager_factory_unittest.cc

Issue 1908423006: Allow content embedders to create AudioManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ScopedAudioManagerPtr instead of raw pointer 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 | « media/audio/audio_manager_factory.h ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
deleted file mode 100644
index b4ceb363059da722ef9a11274e819fb1d497f586..0000000000000000000000000000000000000000
--- a/media/audio/audio_manager_factory_unittest.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/test/test_message_loop.h"
-#include "base/thread_task_runner_handle.h"
-#include "media/audio/audio_manager.h"
-#include "media/audio/audio_manager_factory.h"
-#include "media/audio/fake_audio_manager.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace media {
-namespace {
-
-class FakeAudioManagerFactory : public AudioManagerFactory {
- public:
- FakeAudioManagerFactory() {}
- ~FakeAudioManagerFactory() 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_ = instance.get();
- return instance;
- }
-
- AudioManager* created_instance() { return created_instance_; }
-
- private:
- AudioManager* created_instance_;
-};
-
-} // namespace
-
-// Verifies that SetFactory has the intended effect.
-TEST(AudioManagerFactoryTest, CreateInstance) {
- {
- base::TestMessageLoop message_loop;
- // Create an audio manager and verify that it is not null.
- ScopedAudioManagerPtr manager =
- AudioManager::CreateForTesting(base::ThreadTaskRunnerHandle::Get());
- ASSERT_NE(nullptr, manager.get());
- }
-
- // Set the factory. Note that ownership of |factory| is transferred to
- // AudioManager.
- FakeAudioManagerFactory* factory = new FakeAudioManagerFactory();
- AudioManager::SetFactory(factory);
- {
- base::TestMessageLoop message_loop;
- // Create the AudioManager instance. Verify that it matches the instance
- // provided by the factory.
- ScopedAudioManagerPtr manager =
- AudioManager::CreateForTesting(base::ThreadTaskRunnerHandle::Get());
- 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.
- AudioManager::ResetFactoryForTesting();
-}
-
-} // namespace media
« no previous file with comments | « media/audio/audio_manager_factory.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698