| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/environment.h" | 6 #include "base/environment.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
| 12 #include "media/audio/audio_io.h" | 12 #include "media/audio/audio_io.h" |
| 13 #include "media/audio/audio_manager_base.h" | 13 #include "media/audio/audio_manager_base.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 | 17 |
| 18 // This class allows to find out if the callbacks are occurring as | 18 // This class allows to find out if the callbacks are occurring as |
| 19 // expected and if any error has been reported. | 19 // expected and if any error has been reported. |
| 20 class TestInputCallback : public AudioInputStream::AudioInputCallback { | 20 class TestInputCallback : public AudioInputStream::AudioInputCallback { |
| 21 public: | 21 public: |
| 22 explicit TestInputCallback() | 22 explicit TestInputCallback() |
| 23 : callback_count_(0), | 23 : callback_count_(0), |
| 24 had_error_(0) { | 24 had_error_(0) { |
| 25 } | 25 } |
| 26 virtual void OnData(AudioInputStream* stream, | 26 virtual void OnData(AudioInputStream* stream, |
| 27 const AudioBus* source, | 27 const AudioBus* source, |
| 28 uint32 hardware_delay_bytes, | 28 uint32 hardware_delay_bytes, |
| 29 double volume) OVERRIDE { | 29 double volume) override { |
| 30 ++callback_count_; | 30 ++callback_count_; |
| 31 } | 31 } |
| 32 virtual void OnError(AudioInputStream* stream) OVERRIDE { | 32 virtual void OnError(AudioInputStream* stream) override { |
| 33 ++had_error_; | 33 ++had_error_; |
| 34 } | 34 } |
| 35 // Returns how many times OnData() has been called. | 35 // Returns how many times OnData() has been called. |
| 36 int callback_count() const { | 36 int callback_count() const { |
| 37 return callback_count_; | 37 return callback_count_; |
| 38 } | 38 } |
| 39 // Returns how many times the OnError callback was called. | 39 // Returns how many times the OnError callback was called. |
| 40 int had_error() const { | 40 int had_error() const { |
| 41 return had_error_; | 41 return had_error_; |
| 42 } | 42 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 base::MessageLoop::QuitClosure(), | 234 base::MessageLoop::QuitClosure(), |
| 235 base::TimeDelta::FromMilliseconds(500)); | 235 base::TimeDelta::FromMilliseconds(500)); |
| 236 message_loop_.Run(); | 236 message_loop_.Run(); |
| 237 EXPECT_GE(test_callback.callback_count(), 2); | 237 EXPECT_GE(test_callback.callback_count(), 2); |
| 238 EXPECT_FALSE(test_callback.had_error()); | 238 EXPECT_FALSE(test_callback.had_error()); |
| 239 | 239 |
| 240 StopAndCloseAudioInputStreamOnAudioThread(); | 240 StopAndCloseAudioInputStreamOnAudioThread(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace media | 243 } // namespace media |
| OLD | NEW |