OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/copresence/mediums/audio/audio_recorder.h" | 5 #include "components/audio_modem/audio_recorder.h" |
| 6 |
| 7 #include <vector> |
6 | 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/memory/aligned_memory.h" | 10 #include "base/memory/aligned_memory.h" |
9 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
10 #include "components/copresence/mediums/audio/audio_recorder_impl.h" | 12 #include "components/audio_modem/audio_recorder_impl.h" |
11 #include "components/copresence/public/copresence_constants.h" | 13 #include "components/audio_modem/public/audio_modem_types.h" |
12 #include "components/copresence/test/audio_test_support.h" | 14 #include "components/audio_modem/test/random_samples.h" |
13 #include "content/public/test/test_browser_thread_bundle.h" | 15 #include "content/public/test/test_browser_thread_bundle.h" |
14 #include "media/audio/audio_manager.h" | 16 #include "media/audio/audio_manager.h" |
15 #include "media/audio/audio_manager_base.h" | 17 #include "media/audio/audio_manager_base.h" |
16 #include "media/base/audio_bus.h" | 18 #include "media/base/audio_bus.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 class TestAudioInputStream : public media::AudioInputStream { | 23 class TestAudioInputStream : public media::AudioInputStream { |
22 public: | 24 public: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 64 |
63 AudioInputCallback* callback_; | 65 AudioInputCallback* callback_; |
64 media::AudioParameters params_; | 66 media::AudioParameters params_; |
65 scoped_ptr<media::AudioBus> buffer_; | 67 scoped_ptr<media::AudioBus> buffer_; |
66 | 68 |
67 DISALLOW_COPY_AND_ASSIGN(TestAudioInputStream); | 69 DISALLOW_COPY_AND_ASSIGN(TestAudioInputStream); |
68 }; | 70 }; |
69 | 71 |
70 } // namespace | 72 } // namespace |
71 | 73 |
72 namespace copresence { | 74 namespace audio_modem { |
73 | 75 |
74 class AudioRecorderTest : public testing::Test { | 76 class AudioRecorderTest : public testing::Test { |
75 public: | 77 public: |
76 AudioRecorderTest() : total_samples_(0), recorder_(nullptr) { | 78 AudioRecorderTest() : total_samples_(0), recorder_(nullptr) { |
77 if (!media::AudioManager::Get()) | 79 if (!media::AudioManager::Get()) |
78 media::AudioManager::CreateForTesting(); | 80 media::AudioManager::CreateForTesting(); |
79 } | 81 } |
80 | 82 |
81 ~AudioRecorderTest() override { | 83 ~AudioRecorderTest() override { |
82 DeleteRecorder(); | 84 DeleteRecorder(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 scoped_ptr<base::RunLoop> run_loop_; | 192 scoped_ptr<base::RunLoop> run_loop_; |
191 content::TestBrowserThreadBundle thread_bundle_; | 193 content::TestBrowserThreadBundle thread_bundle_; |
192 }; | 194 }; |
193 | 195 |
194 // TODO(rkc): These tests are broken on all platforms. | 196 // TODO(rkc): These tests are broken on all platforms. |
195 // On Windows and Mac, we cannot use non-OS params. The tests need to be | 197 // On Windows and Mac, we cannot use non-OS params. The tests need to be |
196 // rewritten to use the params provided to us by the audio manager | 198 // rewritten to use the params provided to us by the audio manager |
197 // rather than setting our own params. | 199 // rather than setting our own params. |
198 // On Linux, there is a memory leak in the audio code during initialization. | 200 // On Linux, there is a memory leak in the audio code during initialization. |
199 #define MAYBE_BasicRecordAndStop DISABLED_BasicRecordAndStop | 201 #define MAYBE_BasicRecordAndStop DISABLED_BasicRecordAndStop |
200 #define MAYBE_OutOfOrderRecordAndStopMultiple DISABLED_OutOfOrderRecordAndStopMu
ltiple | 202 #define MAYBE_OutOfOrderRecordAndStopMultiple \ |
| 203 DISABLED_OutOfOrderRecordAndStopMultiple |
201 #define MAYBE_RecordingEndToEnd DISABLED_RecordingEndToEnd | 204 #define MAYBE_RecordingEndToEnd DISABLED_RecordingEndToEnd |
202 | 205 |
203 TEST_F(AudioRecorderTest, MAYBE_BasicRecordAndStop) { | 206 TEST_F(AudioRecorderTest, MAYBE_BasicRecordAndStop) { |
204 CreateSimpleRecorder(); | 207 CreateSimpleRecorder(); |
205 | 208 |
206 recorder_->Record(); | 209 recorder_->Record(); |
207 EXPECT_TRUE(IsRecording()); | 210 EXPECT_TRUE(IsRecording()); |
208 recorder_->Stop(); | 211 recorder_->Stop(); |
209 EXPECT_FALSE(IsRecording()); | 212 EXPECT_FALSE(IsRecording()); |
210 recorder_->Record(); | 213 recorder_->Record(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 CreateRecorder( | 248 CreateRecorder( |
246 kDefaultChannels, kDefaultSampleRate, kDefaultBitsPerSample, kNumSamples); | 249 kDefaultChannels, kDefaultSampleRate, kDefaultBitsPerSample, kNumSamples); |
247 | 250 |
248 RecordAndVerifySamples(); | 251 RecordAndVerifySamples(); |
249 | 252 |
250 DeleteRecorder(); | 253 DeleteRecorder(); |
251 } | 254 } |
252 | 255 |
253 // TODO(rkc): Add tests with recording different sample rates. | 256 // TODO(rkc): Add tests with recording different sample rates. |
254 | 257 |
255 } // namespace copresence | 258 } // namespace audio_modem |
OLD | NEW |