| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/environment.h" | 7 #include "base/environment.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 ChannelLayoutToChannelCount(kChannelLayout) * kBitsPerSample / 8; | 33 ChannelLayoutToChannelCount(kChannelLayout) * kBitsPerSample / 8; |
| 34 static const double kTestVolume = 0.25; | 34 static const double kTestVolume = 0.25; |
| 35 | 35 |
| 36 class MockAudioOutputControllerEventHandler | 36 class MockAudioOutputControllerEventHandler |
| 37 : public AudioOutputController::EventHandler { | 37 : public AudioOutputController::EventHandler { |
| 38 public: | 38 public: |
| 39 MockAudioOutputControllerEventHandler() {} | 39 MockAudioOutputControllerEventHandler() {} |
| 40 | 40 |
| 41 MOCK_METHOD0(OnCreated, void()); | 41 MOCK_METHOD0(OnCreated, void()); |
| 42 MOCK_METHOD0(OnPlaying, void()); | 42 MOCK_METHOD0(OnPlaying, void()); |
| 43 MOCK_METHOD1(OnAudible, void(bool is_audible)); | 43 MOCK_METHOD2(OnPowerMeasured, void(float power_dBFS, bool clipped)); |
| 44 MOCK_METHOD0(OnPaused, void()); | 44 MOCK_METHOD0(OnPaused, void()); |
| 45 MOCK_METHOD0(OnError, void()); | 45 MOCK_METHOD0(OnError, void()); |
| 46 MOCK_METHOD2(OnDeviceChange, void(int new_buffer_size, int new_sample_rate)); | 46 MOCK_METHOD2(OnDeviceChange, void(int new_buffer_size, int new_sample_rate)); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerEventHandler); | 49 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerEventHandler); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class MockAudioOutputControllerSyncReader | 52 class MockAudioOutputControllerSyncReader |
| 53 : public AudioOutputController::SyncReader { | 53 : public AudioOutputController::SyncReader { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 audio_manager_.get(), &mock_event_handler_, params_, std::string(), | 124 audio_manager_.get(), &mock_event_handler_, params_, std::string(), |
| 125 &mock_sync_reader_); | 125 &mock_sync_reader_); |
| 126 if (controller_.get()) | 126 if (controller_.get()) |
| 127 controller_->SetVolume(kTestVolume); | 127 controller_->SetVolume(kTestVolume); |
| 128 | 128 |
| 129 EXPECT_EQ(params_.IsValid(), controller_.get() != NULL); | 129 EXPECT_EQ(params_.IsValid(), controller_.get() != NULL); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void Play() { | 132 void Play() { |
| 133 // Expect the event handler to receive one OnPlaying() call and one or more | 133 // Expect the event handler to receive one OnPlaying() call and one or more |
| 134 // OnAudible() calls. | 134 // OnPowerMeasured() calls. |
| 135 EXPECT_CALL(mock_event_handler_, OnPlaying()) | 135 EXPECT_CALL(mock_event_handler_, OnPlaying()) |
| 136 .WillOnce(SignalEvent(&play_event_)); | 136 .WillOnce(SignalEvent(&play_event_)); |
| 137 EXPECT_CALL(mock_event_handler_, OnAudible(_)) | 137 EXPECT_CALL(mock_event_handler_, OnPowerMeasured(_, false)) |
| 138 .Times(AtLeast(1)); | 138 .Times(AtLeast(1)); |
| 139 | 139 |
| 140 // During playback, the mock pretends to provide audio data rendered and | 140 // During playback, the mock pretends to provide audio data rendered and |
| 141 // sent from the render process. | 141 // sent from the render process. |
| 142 EXPECT_CALL(mock_sync_reader_, UpdatePendingBytes(_)) | 142 EXPECT_CALL(mock_sync_reader_, UpdatePendingBytes(_)) |
| 143 .Times(AtLeast(1)); | 143 .Times(AtLeast(1)); |
| 144 EXPECT_CALL(mock_sync_reader_, Read(_, _, _)) | 144 EXPECT_CALL(mock_sync_reader_, Read(_, _, _)) |
| 145 .WillRepeatedly(DoAll(PopulateBuffer(), | 145 .WillRepeatedly(DoAll(PopulateBuffer(), |
| 146 SignalEvent(&read_event_), | 146 SignalEvent(&read_event_), |
| 147 Return(params_.frames_per_buffer()))); | 147 Return(params_.frames_per_buffer()))); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 370 |
| 371 TEST_F(AudioOutputControllerTest, DivertRevertClose) { | 371 TEST_F(AudioOutputControllerTest, DivertRevertClose) { |
| 372 Create(kSamplesPerPacket); | 372 Create(kSamplesPerPacket); |
| 373 WaitForCreate(); | 373 WaitForCreate(); |
| 374 DivertNeverPlaying(); | 374 DivertNeverPlaying(); |
| 375 RevertWasNotPlaying(); | 375 RevertWasNotPlaying(); |
| 376 Close(); | 376 Close(); |
| 377 } | 377 } |
| 378 | 378 |
| 379 } // namespace media | 379 } // namespace media |
| OLD | NEW |