| 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 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/environment.h" | 12 #include "base/environment.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/test/test_message_loop.h" | 17 #include "base/test/test_message_loop.h" |
| 18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
| 19 #include "media/audio/audio_manager_base.h" | 19 #include "media/audio/audio_device_description.h" |
| 20 #include "media/base/audio_bus.h" | 20 #include "media/base/audio_bus.h" |
| 21 #include "media/base/audio_parameters.h" | 21 #include "media/base/audio_parameters.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 24 |
| 25 using ::testing::_; | 25 using ::testing::_; |
| 26 using ::testing::AtLeast; | 26 using ::testing::AtLeast; |
| 27 using ::testing::DoAll; | 27 using ::testing::DoAll; |
| 28 using ::testing::Invoke; | 28 using ::testing::Invoke; |
| 29 using ::testing::NotNull; | 29 using ::testing::NotNull; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 } | 200 } |
| 201 | 201 |
| 202 void SwitchDevice(bool diverting) { | 202 void SwitchDevice(bool diverting) { |
| 203 if (!diverting) { | 203 if (!diverting) { |
| 204 // Expect the current stream to close and a new stream to start | 204 // Expect the current stream to close and a new stream to start |
| 205 // playing if not diverting. When diverting, nothing happens | 205 // playing if not diverting. When diverting, nothing happens |
| 206 // until diverting is stopped. | 206 // until diverting is stopped. |
| 207 EXPECT_CALL(mock_event_handler_, OnPlaying()); | 207 EXPECT_CALL(mock_event_handler_, OnPlaying()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 controller_->SwitchOutputDevice(AudioManager::GetDefaultDeviceName(), | 210 controller_->SwitchOutputDevice( |
| 211 base::Bind(&base::DoNothing)); | 211 AudioDeviceDescription::GetDefaultDeviceName(), |
| 212 base::Bind(&base::DoNothing)); |
| 212 base::RunLoop().RunUntilIdle(); | 213 base::RunLoop().RunUntilIdle(); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void Close() { | 216 void Close() { |
| 216 EXPECT_CALL(mock_sync_reader_, Close()); | 217 EXPECT_CALL(mock_sync_reader_, Close()); |
| 217 | 218 |
| 218 base::RunLoop run_loop; | 219 base::RunLoop run_loop; |
| 219 base::MessageLoop::current()->PostTask( | 220 base::MessageLoop::current()->PostTask( |
| 220 FROM_HERE, base::Bind(&AudioOutputController::Close, controller_, | 221 FROM_HERE, base::Bind(&AudioOutputController::Close, controller_, |
| 221 run_loop.QuitClosure())); | 222 run_loop.QuitClosure())); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 330 } |
| 330 | 331 |
| 331 TEST_F(AudioOutputControllerTest, DivertRevertClose) { | 332 TEST_F(AudioOutputControllerTest, DivertRevertClose) { |
| 332 Create(kSamplesPerPacket); | 333 Create(kSamplesPerPacket); |
| 333 DivertNeverPlaying(); | 334 DivertNeverPlaying(); |
| 334 RevertWasNotPlaying(); | 335 RevertWasNotPlaying(); |
| 335 Close(); | 336 Close(); |
| 336 } | 337 } |
| 337 | 338 |
| 338 } // namespace media | 339 } // namespace media |
| OLD | NEW |