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 #include "media/audio/audio_output_controller.h" | 5 #include "media/audio/audio_output_controller.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 void ChangeDevice() { | 162 void ChangeDevice() { |
163 // Expect the event handler to receive one OnControllerPaying() call and no | 163 // Expect the event handler to receive one OnControllerPaying() call and no |
164 // OnControllerPaused() call. | 164 // OnControllerPaused() call. |
165 EXPECT_CALL(mock_event_handler_, OnControllerPlaying()); | 165 EXPECT_CALL(mock_event_handler_, OnControllerPlaying()); |
166 EXPECT_CALL(mock_event_handler_, OnControllerPaused()).Times(0); | 166 EXPECT_CALL(mock_event_handler_, OnControllerPaused()).Times(0); |
167 | 167 |
168 // Simulate a device change event to AudioOutputController from the | 168 // Simulate a device change event to AudioOutputController from the |
169 // AudioManager. | 169 // AudioManager. |
170 audio_manager_->GetTaskRunner()->PostTask( | 170 audio_manager_->GetTaskRunner()->PostTask( |
171 FROM_HERE, | 171 FROM_HERE, |
172 base::Bind(&AudioOutputController::OnDeviceChange, controller_)); | 172 base::BindOnce(&AudioOutputController::OnDeviceChange, controller_)); |
173 } | 173 } |
174 | 174 |
175 void Divert(bool was_playing, int num_times_to_be_started) { | 175 void Divert(bool was_playing, int num_times_to_be_started) { |
176 if (was_playing) { | 176 if (was_playing) { |
177 // Expect the handler to receive one OnControllerPlaying() call as a | 177 // Expect the handler to receive one OnControllerPlaying() call as a |
178 // result of the stream switching. | 178 // result of the stream switching. |
179 EXPECT_CALL(mock_event_handler_, OnControllerPlaying()); | 179 EXPECT_CALL(mock_event_handler_, OnControllerPlaying()); |
180 } | 180 } |
181 | 181 |
182 EXPECT_CALL(mock_stream_, Open()) | 182 EXPECT_CALL(mock_stream_, Open()) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 EXPECT_CALL(*sink, Close()); | 243 EXPECT_CALL(*sink, Close()); |
244 controller_->StopDuplicating(sink); | 244 controller_->StopDuplicating(sink); |
245 base::RunLoop().RunUntilIdle(); | 245 base::RunLoop().RunUntilIdle(); |
246 } | 246 } |
247 | 247 |
248 void Close() { | 248 void Close() { |
249 EXPECT_CALL(mock_sync_reader_, Close()); | 249 EXPECT_CALL(mock_sync_reader_, Close()); |
250 | 250 |
251 base::RunLoop run_loop; | 251 base::RunLoop run_loop; |
252 base::ThreadTaskRunnerHandle::Get()->PostTask( | 252 base::ThreadTaskRunnerHandle::Get()->PostTask( |
253 FROM_HERE, base::Bind(&AudioOutputController::Close, controller_, | 253 FROM_HERE, base::BindOnce(&AudioOutputController::Close, controller_, |
254 run_loop.QuitClosure())); | 254 run_loop.QuitClosure())); |
255 run_loop.Run(); | 255 run_loop.Run(); |
256 } | 256 } |
257 | 257 |
258 // These help make test sequences more readable. | 258 // These help make test sequences more readable. |
259 void DivertNeverPlaying() { Divert(false, 0); } | 259 void DivertNeverPlaying() { Divert(false, 0); } |
260 void DivertWillEventuallyBeTwicePlayed() { Divert(false, 2); } | 260 void DivertWillEventuallyBeTwicePlayed() { Divert(false, 2); } |
261 void DivertWhilePlaying() { Divert(true, 1); } | 261 void DivertWhilePlaying() { Divert(true, 1); } |
262 void RevertWasNotPlaying() { Revert(false); } | 262 void RevertWasNotPlaying() { Revert(false); } |
263 void RevertWhilePlaying() { Revert(true); } | 263 void RevertWhilePlaying() { Revert(true); } |
264 | 264 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 // When diverted stream pulls data, it would trigger a push to sink. | 384 // When diverted stream pulls data, it would trigger a push to sink. |
385 EXPECT_CALL(mock_sink, OnDataCheck(kBufferNonZeroData)); | 385 EXPECT_CALL(mock_sink, OnDataCheck(kBufferNonZeroData)); |
386 ReadDivertedAudioData(); | 386 ReadDivertedAudioData(); |
387 | 387 |
388 StopDuplicating(&mock_sink); | 388 StopDuplicating(&mock_sink); |
389 RevertWhilePlaying(); | 389 RevertWhilePlaying(); |
390 Close(); | 390 Close(); |
391 } | 391 } |
392 | 392 |
393 } // namespace media | 393 } // namespace media |
OLD | NEW |