| 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 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerEventHandler); | 55 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerEventHandler); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class MockAudioOutputControllerSyncReader | 58 class MockAudioOutputControllerSyncReader |
| 59 : public AudioOutputController::SyncReader { | 59 : public AudioOutputController::SyncReader { |
| 60 public: | 60 public: |
| 61 MockAudioOutputControllerSyncReader() {} | 61 MockAudioOutputControllerSyncReader() {} |
| 62 | 62 |
| 63 MOCK_METHOD2(UpdatePendingBytes, | 63 MOCK_METHOD3(UpdatePendingBytes, |
| 64 void(uint32_t bytes, uint32_t frames_skipped)); | 64 void(uint32_t bytes, |
| 65 uint32_t frames_skipped, |
| 66 const media::AudioTimestamp& timestamp)); |
| 65 MOCK_METHOD1(Read, void(AudioBus* dest)); | 67 MOCK_METHOD1(Read, void(AudioBus* dest)); |
| 66 MOCK_METHOD0(Close, void()); | 68 MOCK_METHOD0(Close, void()); |
| 67 | 69 |
| 68 private: | 70 private: |
| 69 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerSyncReader); | 71 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerSyncReader); |
| 70 }; | 72 }; |
| 71 | 73 |
| 72 class MockAudioOutputStream : public AudioOutputStream { | 74 class MockAudioOutputStream : public AudioOutputStream { |
| 73 public: | 75 public: |
| 74 MOCK_METHOD0(Open, bool()); | 76 MOCK_METHOD0(Open, bool()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 EXPECT_EQ(params_.IsValid(), controller_.get() != NULL); | 135 EXPECT_EQ(params_.IsValid(), controller_.get() != NULL); |
| 134 base::RunLoop().RunUntilIdle(); | 136 base::RunLoop().RunUntilIdle(); |
| 135 } | 137 } |
| 136 | 138 |
| 137 void Play() { | 139 void Play() { |
| 138 // Expect the event handler to receive one OnPlaying() call. | 140 // Expect the event handler to receive one OnPlaying() call. |
| 139 EXPECT_CALL(mock_event_handler_, OnPlaying()); | 141 EXPECT_CALL(mock_event_handler_, OnPlaying()); |
| 140 | 142 |
| 141 // During playback, the mock pretends to provide audio data rendered and | 143 // During playback, the mock pretends to provide audio data rendered and |
| 142 // sent from the render process. | 144 // sent from the render process. |
| 143 EXPECT_CALL(mock_sync_reader_, UpdatePendingBytes(_, _)).Times(AtLeast(1)); | 145 EXPECT_CALL(mock_sync_reader_, UpdatePendingBytes(_, _, AudioTimestamp())) |
| 146 .Times(AtLeast(1)); |
| 144 EXPECT_CALL(mock_sync_reader_, Read(_)).WillRepeatedly(PopulateBuffer()); | 147 EXPECT_CALL(mock_sync_reader_, Read(_)).WillRepeatedly(PopulateBuffer()); |
| 145 controller_->Play(); | 148 controller_->Play(); |
| 146 base::RunLoop().RunUntilIdle(); | 149 base::RunLoop().RunUntilIdle(); |
| 147 } | 150 } |
| 148 | 151 |
| 149 void Pause() { | 152 void Pause() { |
| 150 // Expect the event handler to receive one OnPaused() call. | 153 // Expect the event handler to receive one OnPaused() call. |
| 151 EXPECT_CALL(mock_event_handler_, OnPaused()); | 154 EXPECT_CALL(mock_event_handler_, OnPaused()); |
| 152 | 155 |
| 153 controller_->Pause(); | 156 controller_->Pause(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 209 } |
| 207 | 210 |
| 208 void ReadDuplicatedAudioData(const std::vector<MockAudioPushSink*>& sinks) { | 211 void ReadDuplicatedAudioData(const std::vector<MockAudioPushSink*>& sinks) { |
| 209 for (size_t i = 0; i < sinks.size(); i++) { | 212 for (size_t i = 0; i < sinks.size(); i++) { |
| 210 EXPECT_CALL(*sinks[i], OnDataCheck(kBufferNonZeroData)); | 213 EXPECT_CALL(*sinks[i], OnDataCheck(kBufferNonZeroData)); |
| 211 } | 214 } |
| 212 | 215 |
| 213 std::unique_ptr<AudioBus> dest = AudioBus::Create(params_); | 216 std::unique_ptr<AudioBus> dest = AudioBus::Create(params_); |
| 214 | 217 |
| 215 // It is this OnMoreData() call that triggers |sink|'s OnData(). | 218 // It is this OnMoreData() call that triggers |sink|'s OnData(). |
| 216 const int frames_read = controller_->OnMoreData(dest.get(), 0, 0); | 219 const int frames_read = |
| 220 controller_->OnMoreData(dest.get(), 0, 0, AudioTimestamp()); |
| 217 | 221 |
| 218 EXPECT_LT(0, frames_read); | 222 EXPECT_LT(0, frames_read); |
| 219 EXPECT_EQ(kBufferNonZeroData, dest->channel(0)[0]); | 223 EXPECT_EQ(kBufferNonZeroData, dest->channel(0)[0]); |
| 220 | 224 |
| 221 base::RunLoop().RunUntilIdle(); | 225 base::RunLoop().RunUntilIdle(); |
| 222 } | 226 } |
| 223 | 227 |
| 224 void Revert(bool was_playing) { | 228 void Revert(bool was_playing) { |
| 225 if (was_playing) { | 229 if (was_playing) { |
| 226 // Expect the handler to receive one OnPlaying() call as a result of the | 230 // Expect the handler to receive one OnPlaying() call as a result of the |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // Switching device would trigger a read, and in turn it would trigger a push | 430 // Switching device would trigger a read, and in turn it would trigger a push |
| 427 // to sink. | 431 // to sink. |
| 428 EXPECT_CALL(mock_sink, OnDataCheck(kBufferNonZeroData)); | 432 EXPECT_CALL(mock_sink, OnDataCheck(kBufferNonZeroData)); |
| 429 SwitchDevice(false); | 433 SwitchDevice(false); |
| 430 | 434 |
| 431 StopDuplicating(&mock_sink); | 435 StopDuplicating(&mock_sink); |
| 432 Close(); | 436 Close(); |
| 433 } | 437 } |
| 434 | 438 |
| 435 } // namespace media | 439 } // namespace media |
| OLD | NEW |