| 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 11 matching lines...) Expand all Loading... |
| 22 using ::testing::Invoke; | 22 using ::testing::Invoke; |
| 23 using ::testing::NotNull; | 23 using ::testing::NotNull; |
| 24 using ::testing::Return; | 24 using ::testing::Return; |
| 25 | 25 |
| 26 namespace media { | 26 namespace media { |
| 27 | 27 |
| 28 static const int kSampleRate = AudioParameters::kAudioCDSampleRate; | 28 static const int kSampleRate = AudioParameters::kAudioCDSampleRate; |
| 29 static const int kBitsPerSample = 16; | 29 static const int kBitsPerSample = 16; |
| 30 static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_STEREO; | 30 static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_STEREO; |
| 31 static const int kSamplesPerPacket = kSampleRate / 100; | 31 static const int kSamplesPerPacket = kSampleRate / 100; |
| 32 static const int kHardwareBufferSize = kSamplesPerPacket * | |
| 33 ChannelLayoutToChannelCount(kChannelLayout) * kBitsPerSample / 8; | |
| 34 static const double kTestVolume = 0.25; | 32 static const double kTestVolume = 0.25; |
| 35 | 33 |
| 36 class MockAudioOutputControllerEventHandler | 34 class MockAudioOutputControllerEventHandler |
| 37 : public AudioOutputController::EventHandler { | 35 : public AudioOutputController::EventHandler { |
| 38 public: | 36 public: |
| 39 MockAudioOutputControllerEventHandler() {} | 37 MockAudioOutputControllerEventHandler() {} |
| 40 | 38 |
| 41 MOCK_METHOD0(OnCreated, void()); | 39 MOCK_METHOD0(OnCreated, void()); |
| 42 MOCK_METHOD0(OnPlaying, void()); | 40 MOCK_METHOD0(OnPlaying, void()); |
| 43 MOCK_METHOD2(OnPowerMeasured, void(float power_dbfs, bool clipped)); | 41 MOCK_METHOD2(OnPowerMeasured, void(float power_dbfs, bool clipped)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 AudioParameters::AUDIO_FAKE, kChannelLayout, | 113 AudioParameters::AUDIO_FAKE, kChannelLayout, |
| 116 kSampleRate, kBitsPerSample, samples_per_packet); | 114 kSampleRate, kBitsPerSample, samples_per_packet); |
| 117 | 115 |
| 118 if (params_.IsValid()) { | 116 if (params_.IsValid()) { |
| 119 EXPECT_CALL(mock_event_handler_, OnCreated()) | 117 EXPECT_CALL(mock_event_handler_, OnCreated()) |
| 120 .WillOnce(SignalEvent(&create_event_)); | 118 .WillOnce(SignalEvent(&create_event_)); |
| 121 } | 119 } |
| 122 | 120 |
| 123 controller_ = AudioOutputController::Create( | 121 controller_ = AudioOutputController::Create( |
| 124 audio_manager_.get(), &mock_event_handler_, params_, std::string(), | 122 audio_manager_.get(), &mock_event_handler_, params_, std::string(), |
| 125 &mock_sync_reader_); | 123 std::string(), &mock_sync_reader_); |
| 126 if (controller_.get()) | 124 if (controller_.get()) |
| 127 controller_->SetVolume(kTestVolume); | 125 controller_->SetVolume(kTestVolume); |
| 128 | 126 |
| 129 EXPECT_EQ(params_.IsValid(), controller_.get() != NULL); | 127 EXPECT_EQ(params_.IsValid(), controller_.get() != NULL); |
| 130 } | 128 } |
| 131 | 129 |
| 132 void Play() { | 130 void Play() { |
| 133 // Expect the event handler to receive one OnPlaying() call and one or more | 131 // Expect the event handler to receive one OnPlaying() call and one or more |
| 134 // OnPowerMeasured() calls. | 132 // OnPowerMeasured() calls. |
| 135 EXPECT_CALL(mock_event_handler_, OnPlaying()) | 133 EXPECT_CALL(mock_event_handler_, OnPlaying()) |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 368 |
| 371 TEST_F(AudioOutputControllerTest, DivertRevertClose) { | 369 TEST_F(AudioOutputControllerTest, DivertRevertClose) { |
| 372 Create(kSamplesPerPacket); | 370 Create(kSamplesPerPacket); |
| 373 WaitForCreate(); | 371 WaitForCreate(); |
| 374 DivertNeverPlaying(); | 372 DivertNeverPlaying(); |
| 375 RevertWasNotPlaying(); | 373 RevertWasNotPlaying(); |
| 376 Close(); | 374 Close(); |
| 377 } | 375 } |
| 378 | 376 |
| 379 } // namespace media | 377 } // namespace media |
| OLD | NEW |