Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: components/audio_modem/audio_recorder_unittest.cc

Issue 940123004: Convert audio samples in Whispernet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 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/audio_modem/audio_recorder.h" 5 #include "components/audio_modem/audio_recorder.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/aligned_memory.h" 10 #include "base/memory/aligned_memory.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 // Deleted by calling Finalize() on the object. 187 // Deleted by calling Finalize() on the object.
188 AudioRecorderImpl* recorder_; 188 AudioRecorderImpl* recorder_;
189 189
190 std::string received_samples_; 190 std::string received_samples_;
191 191
192 scoped_ptr<base::RunLoop> run_loop_; 192 scoped_ptr<base::RunLoop> run_loop_;
193 content::TestBrowserThreadBundle thread_bundle_; 193 content::TestBrowserThreadBundle thread_bundle_;
194 }; 194 };
195 195
196 // TODO(rkc): These tests are broken on all platforms. 196 TEST_F(AudioRecorderTest, BasicRecordAndStop) {
Charlie 2015/02/20 00:58:21 Cool! I had a bug open about this.
rkc 2015/02/20 18:53:07 I added a few more changes to make sure that these
197 // On Windows and Mac, we cannot use non-OS params. The tests need to be
198 // rewritten to use the params provided to us by the audio manager
199 // rather than setting our own params.
200 // On Linux, there is a memory leak in the audio code during initialization.
201 #define MAYBE_BasicRecordAndStop DISABLED_BasicRecordAndStop
202 #define MAYBE_OutOfOrderRecordAndStopMultiple \
203 DISABLED_OutOfOrderRecordAndStopMultiple
204 #define MAYBE_RecordingEndToEnd DISABLED_RecordingEndToEnd
205
206 TEST_F(AudioRecorderTest, MAYBE_BasicRecordAndStop) {
207 CreateSimpleRecorder(); 197 CreateSimpleRecorder();
208 198
209 recorder_->Record(); 199 recorder_->Record();
210 EXPECT_TRUE(IsRecording()); 200 EXPECT_TRUE(IsRecording());
211 recorder_->Stop(); 201 recorder_->Stop();
212 EXPECT_FALSE(IsRecording()); 202 EXPECT_FALSE(IsRecording());
213 recorder_->Record(); 203 recorder_->Record();
214 204
215 EXPECT_TRUE(IsRecording()); 205 EXPECT_TRUE(IsRecording());
216 recorder_->Stop(); 206 recorder_->Stop();
217 EXPECT_FALSE(IsRecording()); 207 EXPECT_FALSE(IsRecording());
218 recorder_->Record(); 208 recorder_->Record();
219 209
220 EXPECT_TRUE(IsRecording()); 210 EXPECT_TRUE(IsRecording());
221 recorder_->Stop(); 211 recorder_->Stop();
222 EXPECT_FALSE(IsRecording()); 212 EXPECT_FALSE(IsRecording());
223 213
224 DeleteRecorder(); 214 DeleteRecorder();
225 } 215 }
226 216
227 TEST_F(AudioRecorderTest, MAYBE_OutOfOrderRecordAndStopMultiple) { 217 TEST_F(AudioRecorderTest, OutOfOrderRecordAndStopMultiple) {
228 CreateSimpleRecorder(); 218 CreateSimpleRecorder();
229 219
230 recorder_->Stop(); 220 recorder_->Stop();
231 recorder_->Stop(); 221 recorder_->Stop();
232 recorder_->Stop(); 222 recorder_->Stop();
233 EXPECT_FALSE(IsRecording()); 223 EXPECT_FALSE(IsRecording());
234 224
235 recorder_->Record(); 225 recorder_->Record();
236 recorder_->Record(); 226 recorder_->Record();
237 EXPECT_TRUE(IsRecording()); 227 EXPECT_TRUE(IsRecording());
238 228
239 recorder_->Stop(); 229 recorder_->Stop();
240 recorder_->Stop(); 230 recorder_->Stop();
241 EXPECT_FALSE(IsRecording()); 231 EXPECT_FALSE(IsRecording());
242 232
243 DeleteRecorder(); 233 DeleteRecorder();
244 } 234 }
245 235
246 TEST_F(AudioRecorderTest, MAYBE_RecordingEndToEnd) { 236 TEST_F(AudioRecorderTest, RecordingEndToEnd) {
247 const int kNumSamples = 48000 * 3; 237 const int kNumSamples = 48000 * 3;
248 CreateRecorder( 238 CreateRecorder(
249 kDefaultChannels, kDefaultSampleRate, kDefaultBitsPerSample, kNumSamples); 239 kDefaultChannels, kDefaultSampleRate, kDefaultBitsPerSample, kNumSamples);
250 240
251 RecordAndVerifySamples(); 241 RecordAndVerifySamples();
252 242
253 DeleteRecorder(); 243 DeleteRecorder();
254 } 244 }
255 245
256 // TODO(rkc): Add tests with recording different sample rates. 246 // TODO(rkc): Add tests with recording different sample rates.
257 247
258 } // namespace audio_modem 248 } // namespace audio_modem
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698