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_METHOD1(OnPowerMeasured, void(float power_in_dbfs)); |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 audio_manager_.get(), &mock_event_handler_, params_, | 125 audio_manager_.get(), &mock_event_handler_, params_, |
126 &mock_sync_reader_); | 126 &mock_sync_reader_); |
127 if (controller_) | 127 if (controller_) |
128 controller_->SetVolume(kTestVolume); | 128 controller_->SetVolume(kTestVolume); |
129 | 129 |
130 EXPECT_EQ(params_.IsValid(), controller_ != NULL); | 130 EXPECT_EQ(params_.IsValid(), controller_ != NULL); |
131 } | 131 } |
132 | 132 |
133 void Play() { | 133 void Play() { |
134 // Expect the event handler to receive one OnPlaying() call and one or more | 134 // Expect the event handler to receive one OnPlaying() call and one or more |
135 // OnAudible() calls. | 135 // OnPowerMeasured() calls. |
136 EXPECT_CALL(mock_event_handler_, OnPlaying()) | 136 EXPECT_CALL(mock_event_handler_, OnPlaying()) |
137 .WillOnce(SignalEvent(&play_event_)); | 137 .WillOnce(SignalEvent(&play_event_)); |
138 EXPECT_CALL(mock_event_handler_, OnAudible(_)) | 138 EXPECT_CALL(mock_event_handler_, OnPowerMeasured(_)) |
139 .Times(AtLeast(1)); | 139 .Times(AtLeast(1)); |
140 | 140 |
141 // During playback, the mock pretends to provide audio data rendered and | 141 // During playback, the mock pretends to provide audio data rendered and |
142 // sent from the render process. | 142 // sent from the render process. |
143 EXPECT_CALL(mock_sync_reader_, UpdatePendingBytes(_)) | 143 EXPECT_CALL(mock_sync_reader_, UpdatePendingBytes(_)) |
144 .Times(AtLeast(1)); | 144 .Times(AtLeast(1)); |
145 EXPECT_CALL(mock_sync_reader_, Read(_, _)) | 145 EXPECT_CALL(mock_sync_reader_, Read(_, _)) |
146 .WillRepeatedly(DoAll(PopulateBuffer(), | 146 .WillRepeatedly(DoAll(PopulateBuffer(), |
147 SignalEvent(&read_event_), | 147 SignalEvent(&read_event_), |
148 Return(params_.frames_per_buffer()))); | 148 Return(params_.frames_per_buffer()))); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 TEST_F(AudioOutputControllerTest, DivertRevertClose) { | 375 TEST_F(AudioOutputControllerTest, DivertRevertClose) { |
376 Create(kSamplesPerPacket); | 376 Create(kSamplesPerPacket); |
377 WaitForCreate(); | 377 WaitForCreate(); |
378 DivertNeverPlaying(); | 378 DivertNeverPlaying(); |
379 RevertWasNotPlaying(); | 379 RevertWasNotPlaying(); |
380 Close(); | 380 Close(); |
381 } | 381 } |
382 | 382 |
383 } // namespace media | 383 } // namespace media |
OLD | NEW |