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

Side by Side Diff: media/audio/audio_output_controller_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698