OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/environment.h" | 6 #include "base/environment.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "media/audio/audio_io.h" | 10 #include "media/audio/audio_io.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // Verify at least 500ms worth of audio was recorded, after giving sufficient | 183 // Verify at least 500ms worth of audio was recorded, after giving sufficient |
184 // extra time. | 184 // extra time. |
185 message_loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), 590); | 185 message_loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), 590); |
186 message_loop.Run(); | 186 message_loop.Run(); |
187 EXPECT_GE(test_callback.callback_count(), 10); | 187 EXPECT_GE(test_callback.callback_count(), 10); |
188 EXPECT_FALSE(test_callback.had_error()); | 188 EXPECT_FALSE(test_callback.had_error()); |
189 | 189 |
190 ais->Stop(); | 190 ais->Stop(); |
191 ais->Close(); | 191 ais->Close(); |
192 } | 192 } |
193 | |
194 // Test a recording sequence with delays in the audio callback. | |
195 // TODO(joth): See bug 107546. This fails on slow bots. Once fixed, remove the | |
196 // CHROME_HEADLESS check below. | |
197 TEST(AudioInputTest, RecordWithSlowSink) { | |
198 scoped_refptr<AudioManager> audio_man(AudioManager::Create()); | |
199 if (!CanRunAudioTests(audio_man.get())) | |
200 return; | |
201 | |
202 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
203 if (env->HasVar("CHROME_HEADLESS")) | |
204 return; | |
205 | |
206 MessageLoop message_loop(MessageLoop::TYPE_DEFAULT); | |
207 AudioInputStream* ais = CreateTestAudioInputStream(audio_man.get()); | |
208 EXPECT_TRUE(ais->Open()); | |
209 | |
210 // We should normally get a callback every 50ms, and a 20ms delay inside each | |
211 // callback should not change this sequence. | |
212 TestInputCallbackBlocking test_callback(kSamplesPerPacket * 4, 0, 20); | |
213 ais->Start(&test_callback); | |
214 // Verify at least 500ms worth of audio was recorded, after giving sufficient | |
215 // extra time. | |
216 message_loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), 590); | |
217 message_loop.Run(); | |
218 EXPECT_GE(test_callback.callback_count(), 10); | |
219 EXPECT_FALSE(test_callback.had_error()); | |
220 | |
221 ais->Stop(); | |
222 ais->Close(); | |
223 } | |
OLD | NEW |