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

Unified Diff: media/audio/test_audio_input_controller_factory.cc

Issue 3148003: Allow unit tests to use a mock audio input controller. (Closed)
Patch Set: Address review comments from Jeremy and Alpha Created 10 years, 4 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/test_audio_input_controller_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/test_audio_input_controller_factory.cc
diff --git a/media/audio/test_audio_input_controller_factory.cc b/media/audio/test_audio_input_controller_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c56afd8fe20f7530f5e87074048d370b522d74f0
--- /dev/null
+++ b/media/audio/test_audio_input_controller_factory.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2009 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 "media/audio/test_audio_input_controller_factory.h"
+#include "media/audio/audio_io.h"
+
+namespace media {
+
+TestAudioInputController::TestAudioInputController(
+ TestAudioInputControllerFactory* factory, EventHandler* event_handler)
+ : AudioInputController(event_handler),
+ factory_(factory),
+ event_handler_(event_handler) {
+}
+
+TestAudioInputController::~TestAudioInputController() {
+ // Inform the factory so that it allows creating new instances in future.
+ factory_->OnTestAudioInputControllerDestroyed(this);
+}
+
+TestAudioInputControllerFactory::TestAudioInputControllerFactory()
+ : controller_(NULL) {
+}
+
+AudioInputController* TestAudioInputControllerFactory::Create(
+ AudioInputController::EventHandler* event_handler,
+ AudioManager::Format format,
+ int channels,
+ int sample_rate,
+ int bits_per_sample,
+ int samples_per_packet) {
+ DCHECK(!controller_); // Only one test instance managed at a time.
+ controller_ = new TestAudioInputController(this, event_handler);
+ return controller_;
+}
+
+void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed(
+ TestAudioInputController* controller) {
+ DCHECK(controller_ == controller);
+ controller_ = NULL;
+}
+
+} // namespace media
« no previous file with comments | « media/audio/test_audio_input_controller_factory.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698