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

Unified Diff: media/audio/test_audio_input_controller_factory.cc

Issue 10704154: Small refactor to media architecture in order to allow end-to-end tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed mock_audio_manager from /content/browser/speech Created 8 years, 5 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/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
index c2f5ef8caf82ac02796ddad75af9fa1f9e67d43f..90b960293da687deb3fda1d8d05d67e5c26f294b 100644
--- a/media/audio/test_audio_input_controller_factory.cc
+++ b/media/audio/test_audio_input_controller_factory.cc
@@ -10,25 +10,39 @@ namespace media {
TestAudioInputController::TestAudioInputController(
TestAudioInputControllerFactory* factory,
AudioManager* audio_manager,
+ AudioParameters audio_parameters,
EventHandler* event_handler,
SyncWriter* sync_writer)
: AudioInputController(event_handler, sync_writer),
+ audio_parameters_(audio_parameters),
factory_(factory),
event_handler_(event_handler) {
message_loop_ = audio_manager->GetMessageLoop();
}
-void TestAudioInputController::Close(const base::Closure& closed_task) {
- message_loop_->PostTask(FROM_HERE, closed_task);
-}
-
TestAudioInputController::~TestAudioInputController() {
// Inform the factory so that it allows creating new instances in future.
factory_->OnTestAudioInputControllerDestroyed(this);
}
+void TestAudioInputController::Record() {
+ if (factory_->delegate_)
+ factory_->delegate_->TestAudioControllerOpened(this);
+}
+
+void TestAudioInputController::Close(const base::Closure& closed_task) {
+ message_loop_->PostTask(FROM_HERE, closed_task);
+ if (factory_->delegate_)
+ factory_->delegate_->TestAudioControllerClosed(this);
+}
+
TestAudioInputControllerFactory::TestAudioInputControllerFactory()
- : controller_(NULL) {
+ : controller_(NULL),
+ delegate_(NULL) {
+}
+
+TestAudioInputControllerFactory::~TestAudioInputControllerFactory() {
+ DCHECK(!controller_);
}
AudioInputController* TestAudioInputControllerFactory::Create(
@@ -36,11 +50,16 @@ AudioInputController* TestAudioInputControllerFactory::Create(
AudioInputController::EventHandler* event_handler,
AudioParameters params) {
DCHECK(!controller_); // Only one test instance managed at a time.
- controller_ = new TestAudioInputController(this, audio_manager,
+ controller_ = new TestAudioInputController(this, audio_manager, params,
event_handler, NULL);
return controller_;
}
+void TestAudioInputControllerFactory::SetDelegateForTests(
+ TestAudioInputControllerDelegate* delegate) {
+ delegate_ = delegate;
+}
+
void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed(
TestAudioInputController* controller) {
DCHECK_EQ(controller_, controller);

Powered by Google App Engine
This is Rietveld 408576698