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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "media/audio/cras/audio_manager_cras.h" | 10 #include "media/audio/cras/audio_manager_cras.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 SCOPED_TRACE(testing::Message() << "Stereo " << rates[i] << "Hz"); | 205 SCOPED_TRACE(testing::Message() << "Stereo " << rates[i] << "Hz"); |
206 AudioParameters params_stereo(kTestFormat, | 206 AudioParameters params_stereo(kTestFormat, |
207 CHANNEL_LAYOUT_STEREO, | 207 CHANNEL_LAYOUT_STEREO, |
208 rates[i], | 208 rates[i], |
209 kTestBitsPerSample, | 209 kTestBitsPerSample, |
210 kTestFramesPerPacket); | 210 kTestFramesPerPacket); |
211 CaptureSomeFrames(params_stereo, kTestCaptureDurationMs); | 211 CaptureSomeFrames(params_stereo, kTestCaptureDurationMs); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
| 215 TEST_F(CrasInputStreamTest, HotwordSampleReady) { |
| 216 AudioParameters params(kTestFormat, |
| 217 CHANNEL_LAYOUT_MONO, |
| 218 kTestSampleRate, |
| 219 kTestBitsPerSample, |
| 220 kTestFramesPerPacket, |
| 221 HARDWARE_INPUT); |
| 222 CrasInputStream* test_stream = |
| 223 new CrasInputStream(params, mock_manager_.get(), |
| 224 AudioManagerBase::kDefaultDeviceId); |
| 225 ASSERT_TRUE(test_stream->Open()); |
| 226 |
| 227 MockAudioInputCallback mock_callback; |
| 228 base::WaitableEvent event(false, false); |
| 229 EXPECT_CALL(mock_callback, OnData(test_stream, _, _, _)) |
| 230 .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal)); |
| 231 test_stream->Start(&mock_callback); |
| 232 |
| 233 // Wait for samples to be captured. |
| 234 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); |
| 235 |
| 236 test_stream->Stop(); |
| 237 test_stream->Close(); |
| 238 } |
| 239 |
215 } // namespace media | 240 } // namespace media |
OLD | NEW |