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

Side by Side Diff: components/copresence/mediums/audio/audio_recorder_unittest.cc

Issue 666133002: Standardize usage of virtual/override/final in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/copresence/mediums/audio/audio_recorder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/aligned_memory.h" 8 #include "base/memory/aligned_memory.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "components/copresence/public/copresence_constants.h" 10 #include "components/copresence/public/copresence_constants.h"
(...skipping 11 matching lines...) Expand all
22 TestAudioInputStream(const media::AudioParameters& params, 22 TestAudioInputStream(const media::AudioParameters& params,
23 const std::vector<float*> channel_data, 23 const std::vector<float*> channel_data,
24 size_t samples) 24 size_t samples)
25 : callback_(NULL), params_(params) { 25 : callback_(NULL), params_(params) {
26 buffer_ = media::AudioBus::CreateWrapper(2); 26 buffer_ = media::AudioBus::CreateWrapper(2);
27 for (size_t i = 0; i < channel_data.size(); ++i) 27 for (size_t i = 0; i < channel_data.size(); ++i)
28 buffer_->SetChannelData(i, channel_data[i]); 28 buffer_->SetChannelData(i, channel_data[i]);
29 buffer_->set_frames(samples); 29 buffer_->set_frames(samples);
30 } 30 }
31 31
32 virtual ~TestAudioInputStream() {} 32 ~TestAudioInputStream() override {}
33 33
34 virtual bool Open() override { return true; } 34 bool Open() override { return true; }
35 virtual void Start(AudioInputCallback* callback) override { 35 void Start(AudioInputCallback* callback) override {
36 DCHECK(callback); 36 DCHECK(callback);
37 callback_ = callback; 37 callback_ = callback;
38 media::AudioManager::Get()->GetTaskRunner()->PostTask( 38 media::AudioManager::Get()->GetTaskRunner()->PostTask(
39 FROM_HERE, 39 FROM_HERE,
40 base::Bind(&TestAudioInputStream::SimulateRecording, 40 base::Bind(&TestAudioInputStream::SimulateRecording,
41 base::Unretained(this))); 41 base::Unretained(this)));
42 } 42 }
43 virtual void Stop() override {} 43 void Stop() override {}
44 virtual void Close() override {} 44 void Close() override {}
45 virtual double GetMaxVolume() override { return 1.0; } 45 double GetMaxVolume() override { return 1.0; }
46 virtual void SetVolume(double volume) override {} 46 void SetVolume(double volume) override {}
47 virtual double GetVolume() override { return 1.0; } 47 double GetVolume() override { return 1.0; }
48 virtual void SetAutomaticGainControl(bool enabled) override {} 48 void SetAutomaticGainControl(bool enabled) override {}
49 virtual bool GetAutomaticGainControl() override { return true; } 49 bool GetAutomaticGainControl() override { return true; }
50 virtual bool IsMuted() override { return false; } 50 bool IsMuted() override { return false; }
51 51
52 private: 52 private:
53 void SimulateRecording() { 53 void SimulateRecording() {
54 const int fpb = params_.frames_per_buffer(); 54 const int fpb = params_.frames_per_buffer();
55 for (int i = 0; i < buffer_->frames() / fpb; ++i) { 55 for (int i = 0; i < buffer_->frames() / fpb; ++i) {
56 scoped_ptr<media::AudioBus> source = media::AudioBus::Create(2, fpb); 56 scoped_ptr<media::AudioBus> source = media::AudioBus::Create(2, fpb);
57 buffer_->CopyPartialFramesTo(i * fpb, fpb, 0, source.get()); 57 buffer_->CopyPartialFramesTo(i * fpb, fpb, 0, source.get());
58 callback_->OnData(this, source.get(), fpb, 1.0); 58 callback_->OnData(this, source.get(), fpb, 1.0);
59 } 59 }
60 } 60 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 kDefaultChannels, kDefaultSampleRate, kDefaultBitsPerSample, kNumSamples); 244 kDefaultChannels, kDefaultSampleRate, kDefaultBitsPerSample, kNumSamples);
245 245
246 RecordAndVerifySamples(); 246 RecordAndVerifySamples();
247 247
248 DeleteRecorder(); 248 DeleteRecorder();
249 } 249 }
250 250
251 // TODO(rkc): Add tests with recording different sample rates. 251 // TODO(rkc): Add tests with recording different sample rates.
252 252
253 } // namespace copresence 253 } // namespace copresence
OLDNEW
« no previous file with comments | « components/copresence/mediums/audio/audio_recorder.h ('k') | components/copresence/rpc/http_post.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698