| 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/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "media/audio/audio_input_controller.h" | 10 #include "media/audio/audio_input_controller.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 MessageLoop::current()->Run(); | 43 MessageLoop::current()->Run(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 class MockAudioInputControllerEventHandler | 46 class MockAudioInputControllerEventHandler |
| 47 : public AudioInputController::EventHandler { | 47 : public AudioInputController::EventHandler { |
| 48 public: | 48 public: |
| 49 MockAudioInputControllerEventHandler() {} | 49 MockAudioInputControllerEventHandler() {} |
| 50 | 50 |
| 51 MOCK_METHOD1(OnCreated, void(AudioInputController* controller)); | 51 MOCK_METHOD1(OnCreated, void(AudioInputController* controller)); |
| 52 MOCK_METHOD1(OnRecording, void(AudioInputController* controller)); | 52 MOCK_METHOD1(OnRecording, void(AudioInputController* controller)); |
| 53 MOCK_METHOD2(OnError, void(AudioInputController* controller, int error_code)); | 53 MOCK_METHOD1(OnError, void(AudioInputController* controller)); |
| 54 MOCK_METHOD3(OnData, void(AudioInputController* controller, | 54 MOCK_METHOD3(OnData, void(AudioInputController* controller, |
| 55 const uint8* data, uint32 size)); | 55 const uint8* data, uint32 size)); |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 DISALLOW_COPY_AND_ASSIGN(MockAudioInputControllerEventHandler); | 58 DISALLOW_COPY_AND_ASSIGN(MockAudioInputControllerEventHandler); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // Test fixture. | 61 // Test fixture. |
| 62 class AudioInputControllerTest : public testing::Test { | 62 class AudioInputControllerTest : public testing::Test { |
| 63 public: | 63 public: |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 .Times(Exactly(1)); | 168 .Times(Exactly(1)); |
| 169 | 169 |
| 170 // OnData() shall be called ten times. | 170 // OnData() shall be called ten times. |
| 171 EXPECT_CALL(event_handler, OnData(NotNull(), NotNull(), _)) | 171 EXPECT_CALL(event_handler, OnData(NotNull(), NotNull(), _)) |
| 172 .Times(AtLeast(10)) | 172 .Times(AtLeast(10)) |
| 173 .WillRepeatedly(CheckCountAndPostQuitTask(&count, 10, | 173 .WillRepeatedly(CheckCountAndPostQuitTask(&count, 10, |
| 174 message_loop_.message_loop_proxy())); | 174 message_loop_.message_loop_proxy())); |
| 175 | 175 |
| 176 // OnError() will be called after the data stream stops while the | 176 // OnError() will be called after the data stream stops while the |
| 177 // controller is in a recording state. | 177 // controller is in a recording state. |
| 178 EXPECT_CALL(event_handler, OnError(NotNull(), 0)) | 178 EXPECT_CALL(event_handler, OnError(NotNull())) |
| 179 .Times(Exactly(1)) | 179 .Times(Exactly(1)) |
| 180 .WillOnce(QuitMessageLoop(&message_loop_)); | 180 .WillOnce(QuitMessageLoop(&message_loop_)); |
| 181 | 181 |
| 182 scoped_ptr<AudioManager> audio_manager(AudioManager::Create()); | 182 scoped_ptr<AudioManager> audio_manager(AudioManager::Create()); |
| 183 AudioParameters params(AudioParameters::AUDIO_FAKE, kChannelLayout, | 183 AudioParameters params(AudioParameters::AUDIO_FAKE, kChannelLayout, |
| 184 kSampleRate, kBitsPerSample, kSamplesPerPacket); | 184 kSampleRate, kBitsPerSample, kSamplesPerPacket); |
| 185 | 185 |
| 186 // Creating the AudioInputController should render an OnCreated() call. | 186 // Creating the AudioInputController should render an OnCreated() call. |
| 187 scoped_refptr<AudioInputController> controller = | 187 scoped_refptr<AudioInputController> controller = |
| 188 AudioInputController::Create(audio_manager.get(), &event_handler, params); | 188 AudioInputController::Create(audio_manager.get(), &event_handler, params); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 controller->Record(); | 246 controller->Record(); |
| 247 | 247 |
| 248 controller->Close(MessageLoop::QuitClosure()); | 248 controller->Close(MessageLoop::QuitClosure()); |
| 249 MessageLoop::current()->Run(); | 249 MessageLoop::current()->Run(); |
| 250 | 250 |
| 251 controller->Close(MessageLoop::QuitClosure()); | 251 controller->Close(MessageLoop::QuitClosure()); |
| 252 MessageLoop::current()->Run(); | 252 MessageLoop::current()->Run(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace media | 255 } // namespace media |
| OLD | NEW |