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

Side by Side 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: Moved MockAudioManager under media/, inherting from AudioManager, removing static field from AudioM… 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/test_audio_input_controller_factory.h" 5 #include "media/audio/test_audio_input_controller_factory.h"
6 #include "media/audio/audio_io.h" 6 #include "media/audio/audio_io.h"
7 7
8 namespace media { 8 namespace media {
9 9
10 TestAudioInputController::TestAudioInputController( 10 TestAudioInputController::TestAudioInputController(
11 TestAudioInputControllerFactory* factory, 11 TestAudioInputControllerFactory* factory,
12 AudioManager* audio_manager, 12 AudioManager* audio_manager,
13 AudioParameters audio_parameters,
13 EventHandler* event_handler, 14 EventHandler* event_handler,
14 SyncWriter* sync_writer) 15 SyncWriter* sync_writer)
15 : AudioInputController(event_handler, sync_writer), 16 : AudioInputController(event_handler, sync_writer),
17 audio_parameters_(audio_parameters),
16 factory_(factory), 18 factory_(factory),
17 event_handler_(event_handler) { 19 event_handler_(event_handler) {
18 message_loop_ = audio_manager->GetMessageLoop(); 20 message_loop_ = audio_manager->GetMessageLoop();
19 } 21 }
20 22
21 void TestAudioInputController::Close(const base::Closure& closed_task) {
22 message_loop_->PostTask(FROM_HERE, closed_task);
23 }
24
25 TestAudioInputController::~TestAudioInputController() { 23 TestAudioInputController::~TestAudioInputController() {
26 // Inform the factory so that it allows creating new instances in future. 24 // Inform the factory so that it allows creating new instances in future.
27 factory_->OnTestAudioInputControllerDestroyed(this); 25 factory_->OnTestAudioInputControllerDestroyed(this);
28 } 26 }
29 27
28 void TestAudioInputController::Record() {
29 if (factory_->delegate_)
30 factory_->delegate_->TestAudioControllerOpened(this);
31 }
32
33 void TestAudioInputController::Close(const base::Closure& closed_task) {
34 message_loop_->PostTask(FROM_HERE, closed_task);
35 if (factory_->delegate_)
36 factory_->delegate_->TestAudioControllerClosed(this);
37 }
38
30 TestAudioInputControllerFactory::TestAudioInputControllerFactory() 39 TestAudioInputControllerFactory::TestAudioInputControllerFactory()
31 : controller_(NULL) { 40 : controller_(NULL),
41 delegate_(NULL) {
42 }
43
44 TestAudioInputControllerFactory::~TestAudioInputControllerFactory() {
45 DCHECK(!controller_);
32 } 46 }
33 47
34 AudioInputController* TestAudioInputControllerFactory::Create( 48 AudioInputController* TestAudioInputControllerFactory::Create(
35 AudioManager* audio_manager, 49 AudioManager* audio_manager,
36 AudioInputController::EventHandler* event_handler, 50 AudioInputController::EventHandler* event_handler,
37 AudioParameters params) { 51 AudioParameters params) {
38 DCHECK(!controller_); // Only one test instance managed at a time. 52 DCHECK(!controller_); // Only one test instance managed at a time.
39 controller_ = new TestAudioInputController(this, audio_manager, 53 controller_ = new TestAudioInputController(this, audio_manager, params,
40 event_handler, NULL); 54 event_handler, NULL);
41 return controller_; 55 return controller_;
42 } 56 }
43 57
58 void TestAudioInputControllerFactory::SetDelegateForTests(
59 TestAudioInputControllerDelegate* delegate) {
60 delegate_ = delegate;
61 }
62
44 void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed( 63 void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed(
45 TestAudioInputController* controller) { 64 TestAudioInputController* controller) {
46 DCHECK_EQ(controller_, controller); 65 DCHECK_EQ(controller_, controller);
47 controller_ = NULL; 66 controller_ = NULL;
48 } 67 }
49 68
50 } // namespace media 69 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698