| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/renderer_host/media/audio_input_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 class MockAudioInputController : public AudioInputController { | 157 class MockAudioInputController : public AudioInputController { |
| 158 public: | 158 public: |
| 159 MockAudioInputController( | 159 MockAudioInputController( |
| 160 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 160 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 161 AudioInputController::SyncWriter* writer, | 161 AudioInputController::SyncWriter* writer, |
| 162 media::AudioManager* audio_manager, | 162 media::AudioManager* audio_manager, |
| 163 AudioInputController::EventHandler* event_handler, | 163 AudioInputController::EventHandler* event_handler, |
| 164 media::UserInputMonitor* user_input_monitor) | 164 media::UserInputMonitor* user_input_monitor) |
| 165 : AudioInputController(event_handler, | 165 : AudioInputController(std::move(task_runner), |
| 166 event_handler, |
| 166 writer, | 167 writer, |
| 167 /*debug_writer*/ nullptr, | 168 /*debug_writer*/ nullptr, |
| 168 user_input_monitor, | 169 user_input_monitor, |
| 169 /*agc*/ false) { | 170 /*agc*/ false) { |
| 170 task_runner_ = std::move(task_runner); | 171 GetTaskRunnerForTesting()->PostTask( |
| 171 task_runner_->PostTask( | |
| 172 FROM_HERE, | 172 FROM_HERE, |
| 173 base::Bind(&AudioInputController::EventHandler::OnCreated, | 173 base::Bind(&AudioInputController::EventHandler::OnCreated, |
| 174 base::Unretained(event_handler), base::Unretained(this))); | 174 base::Unretained(event_handler), base::Unretained(this))); |
| 175 ON_CALL(*this, Close(_)) | 175 ON_CALL(*this, Close(_)) |
| 176 .WillByDefault(Invoke(this, &MockAudioInputController::ExecuteClose)); | 176 .WillByDefault(Invoke(this, &MockAudioInputController::ExecuteClose)); |
| 177 ON_CALL(*this, EnableDebugRecording(_)) | 177 ON_CALL(*this, EnableDebugRecording(_)) |
| 178 .WillByDefault(SaveArg<0>(&file_name)); | 178 .WillByDefault(SaveArg<0>(&file_name)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 EventHandler* handler() { return handler_; } | 181 EventHandler* handler() { return GetHandlerForTesting(); } |
| 182 | 182 |
| 183 // File name that we pretend to do a debug recording to, if any. | 183 // File name that we pretend to do a debug recording to, if any. |
| 184 base::FilePath debug_file_name() { return file_name; } | 184 base::FilePath debug_file_name() { return file_name; } |
| 185 | 185 |
| 186 MOCK_METHOD0(Record, void()); | 186 MOCK_METHOD0(Record, void()); |
| 187 MOCK_METHOD1(Close, void(const base::Closure&)); | 187 MOCK_METHOD1(Close, void(const base::Closure&)); |
| 188 MOCK_METHOD1(SetVolume, void(double)); | 188 MOCK_METHOD1(SetVolume, void(double)); |
| 189 MOCK_METHOD1(EnableDebugRecording, void(const base::FilePath&)); | 189 MOCK_METHOD1(EnableDebugRecording, void(const base::FilePath&)); |
| 190 MOCK_METHOD0(DisableDebugRecording, void()); | 190 MOCK_METHOD0(DisableDebugRecording, void()); |
| 191 | 191 |
| 192 // AudioInputCallback impl, irrelevant to us. | 192 // AudioInputCallback impl, irrelevant to us. |
| 193 MOCK_METHOD4( | 193 MOCK_METHOD4( |
| 194 OnData, | 194 OnData, |
| 195 void(media::AudioInputStream*, const media::AudioBus*, uint32_t, double)); | 195 void(media::AudioInputStream*, const media::AudioBus*, uint32_t, double)); |
| 196 MOCK_METHOD1(OnError, void(media::AudioInputStream*)); | 196 MOCK_METHOD1(OnError, void(media::AudioInputStream*)); |
| 197 | 197 |
| 198 protected: | 198 protected: |
| 199 ~MockAudioInputController() override = default; | 199 ~MockAudioInputController() override = default; |
| 200 | 200 |
| 201 private: | 201 private: |
| 202 void ExecuteClose(const base::Closure& task) { | 202 void ExecuteClose(const base::Closure& task) { |
| 203 // Hop to audio manager thread before calling task, since this is the real | 203 // Hop to audio manager thread before calling task, since this is the real |
| 204 // behavior. | 204 // behavior. |
| 205 task_runner_->PostTaskAndReply(FROM_HERE, base::Bind([]() {}), task); | 205 GetTaskRunnerForTesting()->PostTaskAndReply(FROM_HERE, base::Bind([]() {}), |
| 206 task); |
| 206 } | 207 } |
| 207 | 208 |
| 208 base::FilePath file_name; | 209 base::FilePath file_name; |
| 209 }; | 210 }; |
| 210 | 211 |
| 211 class MockControllerFactory : public AudioInputController::Factory { | 212 class MockControllerFactory : public AudioInputController::Factory { |
| 212 public: | 213 public: |
| 213 using MockController = StrictMock<MockAudioInputController>; | 214 using MockController = StrictMock<MockAudioInputController>; |
| 214 | 215 |
| 215 MockControllerFactory() { | 216 MockControllerFactory() { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 EXPECT_CALL(controller_factory_, ControllerCreated()); | 549 EXPECT_CALL(controller_factory_, ControllerCreated()); |
| 549 | 550 |
| 550 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( | 551 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( |
| 551 kStreamId, kRenderFrameId, session_id, DefaultConfig())); | 552 kStreamId, kRenderFrameId, session_id, DefaultConfig())); |
| 552 base::RunLoop().RunUntilIdle(); | 553 base::RunLoop().RunUntilIdle(); |
| 553 | 554 |
| 554 EXPECT_CALL(*controller_factory_.controller(0), Close(_)); | 555 EXPECT_CALL(*controller_factory_.controller(0), Close(_)); |
| 555 } | 556 } |
| 556 | 557 |
| 557 } // namespace content | 558 } // namespace content |
| OLD | NEW |