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

Side by Side Diff: media/audio/audio_input_unittest.cc

Issue 2689483006: Switch browser side audio capture path to use base time primitives. (Closed)
Patch Set: Bloop Created 3 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 (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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/test/test_message_loop.h" 11 #include "base/test/test_message_loop.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "media/audio/audio_device_description.h" 15 #include "media/audio/audio_device_description.h"
16 #include "media/audio/audio_io.h" 16 #include "media/audio/audio_io.h"
17 #include "media/audio/audio_manager.h" 17 #include "media/audio/audio_manager.h"
18 #include "media/audio/audio_unittest_util.h" 18 #include "media/audio/audio_unittest_util.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace media { 21 namespace media {
22 22
23 // This class allows to find out if the callbacks are occurring as 23 // This class allows to find out if the callbacks are occurring as
24 // expected and if any error has been reported. 24 // expected and if any error has been reported.
25 class TestInputCallback : public AudioInputStream::AudioInputCallback { 25 class TestInputCallback : public AudioInputStream::AudioInputCallback {
26 public: 26 public:
27 explicit TestInputCallback() 27 explicit TestInputCallback() : callback_count_(0), had_error_(0) {}
28 : callback_count_(0),
29 had_error_(0) {
30 }
31 void OnData(AudioInputStream* stream, 28 void OnData(AudioInputStream* stream,
32 const AudioBus* source, 29 const AudioBus* source,
33 uint32_t hardware_delay_bytes, 30 base::TimeDelta delay,
31 base::TimeTicks delay_timestamp,
34 double volume) override { 32 double volume) override {
35 ++callback_count_; 33 ++callback_count_;
36 } 34 }
37 void OnError(AudioInputStream* stream) override { ++had_error_; } 35 void OnError(AudioInputStream* stream) override { ++had_error_; }
38 // Returns how many times OnData() has been called. 36 // Returns how many times OnData() has been called.
39 int callback_count() const { 37 int callback_count() const {
40 return callback_count_; 38 return callback_count_;
41 } 39 }
42 // Returns how many times the OnError callback was called. 40 // Returns how many times the OnError callback was called.
43 int had_error() const { 41 int had_error() const {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 FROM_HERE, run_loop.QuitClosure(), 211 FROM_HERE, run_loop.QuitClosure(),
214 base::TimeDelta::FromMilliseconds(500)); 212 base::TimeDelta::FromMilliseconds(500));
215 run_loop.Run(); 213 run_loop.Run();
216 EXPECT_GE(test_callback.callback_count(), 2); 214 EXPECT_GE(test_callback.callback_count(), 2);
217 EXPECT_FALSE(test_callback.had_error()); 215 EXPECT_FALSE(test_callback.had_error());
218 216
219 StopAndCloseAudioInputStreamOnAudioThread(); 217 StopAndCloseAudioInputStreamOnAudioThread();
220 } 218 }
221 219
222 } // namespace media 220 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698