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" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
6 | 8 |
| 9 #include <memory> |
| 10 |
7 #include "base/bind.h" | 11 #include "base/bind.h" |
8 #include "base/environment.h" | 12 #include "base/environment.h" |
9 #include "base/logging.h" | 13 #include "base/logging.h" |
10 #include "base/macros.h" | 14 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
14 #include "base/test/test_message_loop.h" | 17 #include "base/test/test_message_loop.h" |
15 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
16 #include "media/audio/audio_manager_base.h" | 19 #include "media/audio/audio_manager_base.h" |
17 #include "media/audio/audio_output_controller.h" | |
18 #include "media/base/audio_bus.h" | 20 #include "media/base/audio_bus.h" |
19 #include "media/base/audio_parameters.h" | 21 #include "media/base/audio_parameters.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
22 | 24 |
23 using ::testing::_; | 25 using ::testing::_; |
24 using ::testing::AtLeast; | 26 using ::testing::AtLeast; |
25 using ::testing::DoAll; | 27 using ::testing::DoAll; |
26 using ::testing::Invoke; | 28 using ::testing::Invoke; |
27 using ::testing::NotNull; | 29 using ::testing::NotNull; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 Invoke(&mock_stream_, &MockAudioOutputStream::SetCallback)); | 171 Invoke(&mock_stream_, &MockAudioOutputStream::SetCallback)); |
170 EXPECT_CALL(mock_stream_, Stop()) | 172 EXPECT_CALL(mock_stream_, Stop()) |
171 .Times(num_times_to_be_started); | 173 .Times(num_times_to_be_started); |
172 } | 174 } |
173 | 175 |
174 controller_->StartDiverting(&mock_stream_); | 176 controller_->StartDiverting(&mock_stream_); |
175 base::RunLoop().RunUntilIdle(); | 177 base::RunLoop().RunUntilIdle(); |
176 } | 178 } |
177 | 179 |
178 void ReadDivertedAudioData() { | 180 void ReadDivertedAudioData() { |
179 scoped_ptr<AudioBus> dest = AudioBus::Create(params_); | 181 std::unique_ptr<AudioBus> dest = AudioBus::Create(params_); |
180 ASSERT_TRUE(mock_stream_.callback()); | 182 ASSERT_TRUE(mock_stream_.callback()); |
181 const int frames_read = | 183 const int frames_read = |
182 mock_stream_.callback()->OnMoreData(dest.get(), 0, 0); | 184 mock_stream_.callback()->OnMoreData(dest.get(), 0, 0); |
183 EXPECT_LT(0, frames_read); | 185 EXPECT_LT(0, frames_read); |
184 EXPECT_EQ(kBufferNonZeroData, dest->channel(0)[0]); | 186 EXPECT_EQ(kBufferNonZeroData, dest->channel(0)[0]); |
185 } | 187 } |
186 | 188 |
187 void Revert(bool was_playing) { | 189 void Revert(bool was_playing) { |
188 if (was_playing) { | 190 if (was_playing) { |
189 // Expect the handler to receive one OnPlaying() call as a result of the | 191 // Expect the handler to receive one OnPlaying() call as a result of the |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 } | 329 } |
328 | 330 |
329 TEST_F(AudioOutputControllerTest, DivertRevertClose) { | 331 TEST_F(AudioOutputControllerTest, DivertRevertClose) { |
330 Create(kSamplesPerPacket); | 332 Create(kSamplesPerPacket); |
331 DivertNeverPlaying(); | 333 DivertNeverPlaying(); |
332 RevertWasNotPlaying(); | 334 RevertWasNotPlaying(); |
333 Close(); | 335 Close(); |
334 } | 336 } |
335 | 337 |
336 } // namespace media | 338 } // namespace media |
OLD | NEW |