| OLD | NEW |
| 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 #ifndef MEDIA_AUDIO_TEST_AUDIO_INPUT_CONTROLLER_FACTORY_H_ | 5 #ifndef MEDIA_AUDIO_TEST_AUDIO_INPUT_CONTROLLER_FACTORY_H_ |
| 6 #define MEDIA_AUDIO_TEST_AUDIO_INPUT_CONTROLLER_FACTORY_H_ | 6 #define MEDIA_AUDIO_TEST_AUDIO_INPUT_CONTROLLER_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "media/audio/audio_input_controller.h" | 9 #include "media/audio/audio_input_controller.h" |
| 10 | 10 |
| 11 namespace media { | 11 namespace media { |
| 12 | 12 |
| 13 class UserInputMonitor; | |
| 14 class TestAudioInputControllerFactory; | 13 class TestAudioInputControllerFactory; |
| 15 | 14 |
| 16 // TestAudioInputController and TestAudioInputControllerFactory are used for | 15 // TestAudioInputController and TestAudioInputControllerFactory are used for |
| 17 // testing consumers of AudioInputController. TestAudioInputControllerFactory | 16 // testing consumers of AudioInputController. TestAudioInputControllerFactory |
| 18 // is a AudioInputController::Factory that creates TestAudioInputControllers. | 17 // is a AudioInputController::Factory that creates TestAudioInputControllers. |
| 19 // | 18 // |
| 20 // TestAudioInputController::Record and Close are overriden to do nothing. It is | 19 // TestAudioInputController::Record and Close are overriden to do nothing. It is |
| 21 // expected that you'll grab the EventHandler from the TestAudioInputController | 20 // expected that you'll grab the EventHandler from the TestAudioInputController |
| 22 // and invoke the callback methods when appropriate. In this way it's easy to | 21 // and invoke the callback methods when appropriate. In this way it's easy to |
| 23 // mock a AudioInputController. | 22 // mock a AudioInputController. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 50 virtual void TestAudioControllerOpened( | 49 virtual void TestAudioControllerOpened( |
| 51 TestAudioInputController* controller) = 0; | 50 TestAudioInputController* controller) = 0; |
| 52 virtual void TestAudioControllerClosed( | 51 virtual void TestAudioControllerClosed( |
| 53 TestAudioInputController* controller) = 0; | 52 TestAudioInputController* controller) = 0; |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 TestAudioInputController(TestAudioInputControllerFactory* factory, | 55 TestAudioInputController(TestAudioInputControllerFactory* factory, |
| 57 AudioManager* audio_manager, | 56 AudioManager* audio_manager, |
| 58 const AudioParameters& audio_parameters, | 57 const AudioParameters& audio_parameters, |
| 59 EventHandler* event_handler, | 58 EventHandler* event_handler, |
| 60 SyncWriter* sync_writer, | 59 SyncWriter* sync_writer); |
| 61 UserInputMonitor* user_input_monitor); | |
| 62 | 60 |
| 63 // Returns the event handler installed on the AudioInputController. | 61 // Returns the event handler installed on the AudioInputController. |
| 64 EventHandler* event_handler() const { return event_handler_; } | 62 EventHandler* event_handler() const { return event_handler_; } |
| 65 | 63 |
| 66 // Notifies the TestAudioControllerOpened() event to the delegate (if any). | 64 // Notifies the TestAudioControllerOpened() event to the delegate (if any). |
| 67 virtual void Record() OVERRIDE; | 65 virtual void Record() OVERRIDE; |
| 68 | 66 |
| 69 // Ensure that the closure is run on the audio-manager thread. | 67 // Ensure that the closure is run on the audio-manager thread. |
| 70 virtual void Close(const base::Closure& closed_task) OVERRIDE; | 68 virtual void Close(const base::Closure& closed_task) OVERRIDE; |
| 71 | 69 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 89 // TestAudioInputControllers. | 87 // TestAudioInputControllers. |
| 90 class TestAudioInputControllerFactory : public AudioInputController::Factory { | 88 class TestAudioInputControllerFactory : public AudioInputController::Factory { |
| 91 public: | 89 public: |
| 92 TestAudioInputControllerFactory(); | 90 TestAudioInputControllerFactory(); |
| 93 virtual ~TestAudioInputControllerFactory(); | 91 virtual ~TestAudioInputControllerFactory(); |
| 94 | 92 |
| 95 // AudioInputController::Factory methods. | 93 // AudioInputController::Factory methods. |
| 96 virtual AudioInputController* Create( | 94 virtual AudioInputController* Create( |
| 97 AudioManager* audio_manager, | 95 AudioManager* audio_manager, |
| 98 AudioInputController::EventHandler* event_handler, | 96 AudioInputController::EventHandler* event_handler, |
| 99 AudioParameters params, | 97 AudioParameters params) OVERRIDE; |
| 100 UserInputMonitor* user_input_monitor) OVERRIDE; | |
| 101 | 98 |
| 102 void SetDelegateForTests(TestAudioInputControllerDelegate* delegate); | 99 void SetDelegateForTests(TestAudioInputControllerDelegate* delegate); |
| 103 | 100 |
| 104 TestAudioInputController* controller() const { return controller_; } | 101 TestAudioInputController* controller() const { return controller_; } |
| 105 | 102 |
| 106 private: | 103 private: |
| 107 friend class TestAudioInputController; | 104 friend class TestAudioInputController; |
| 108 | 105 |
| 109 // Invoked by a TestAudioInputController when it gets destroyed. | 106 // Invoked by a TestAudioInputController when it gets destroyed. |
| 110 void OnTestAudioInputControllerDestroyed( | 107 void OnTestAudioInputControllerDestroyed( |
| 111 TestAudioInputController* controller); | 108 TestAudioInputController* controller); |
| 112 | 109 |
| 113 // The caller of Create owns this object. | 110 // The caller of Create owns this object. |
| 114 TestAudioInputController* controller_; | 111 TestAudioInputController* controller_; |
| 115 | 112 |
| 116 // The delegate for tests for receiving audio controller events. | 113 // The delegate for tests for receiving audio controller events. |
| 117 TestAudioInputControllerDelegate* delegate_; | 114 TestAudioInputControllerDelegate* delegate_; |
| 118 | 115 |
| 119 DISALLOW_COPY_AND_ASSIGN(TestAudioInputControllerFactory); | 116 DISALLOW_COPY_AND_ASSIGN(TestAudioInputControllerFactory); |
| 120 }; | 117 }; |
| 121 | 118 |
| 122 } // namespace media | 119 } // namespace media |
| 123 | 120 |
| 124 #endif // MEDIA_AUDIO_TEST_AUDIO_INPUT_CONTROLLER_FACTORY_H_ | 121 #endif // MEDIA_AUDIO_TEST_AUDIO_INPUT_CONTROLLER_FACTORY_H_ |
| OLD | NEW |