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.h" | 8 #include "base/message_loop.h" |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "media/audio/audio_io.h" | 10 #include "media/audio/audio_io.h" |
11 #include "media/audio/audio_manager_base.h" | 11 #include "media/audio/audio_manager_base.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace media { | |
15 | |
16 static const int kSamplingRate = 8000; | 14 static const int kSamplingRate = 8000; |
17 static const int kSamplesPerPacket = kSamplingRate / 20; | 15 static const int kSamplesPerPacket = kSamplingRate / 20; |
18 | 16 |
19 // This class allows to find out if the callbacks are occurring as | 17 // This class allows to find out if the callbacks are occurring as |
20 // expected and if any error has been reported. | 18 // expected and if any error has been reported. |
21 class TestInputCallback : public AudioInputStream::AudioInputCallback { | 19 class TestInputCallback : public AudioInputStream::AudioInputCallback { |
22 public: | 20 public: |
23 explicit TestInputCallback(int max_data_bytes) | 21 explicit TestInputCallback(int max_data_bytes) |
24 : callback_count_(0), | 22 : callback_count_(0), |
25 had_error_(0), | 23 had_error_(0), |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 FROM_HERE, | 163 FROM_HERE, |
166 MessageLoop::QuitClosure(), | 164 MessageLoop::QuitClosure(), |
167 base::TimeDelta::FromMilliseconds(590)); | 165 base::TimeDelta::FromMilliseconds(590)); |
168 message_loop.Run(); | 166 message_loop.Run(); |
169 EXPECT_GE(test_callback.callback_count(), 10); | 167 EXPECT_GE(test_callback.callback_count(), 10); |
170 EXPECT_FALSE(test_callback.had_error()); | 168 EXPECT_FALSE(test_callback.had_error()); |
171 | 169 |
172 ais->Stop(); | 170 ais->Stop(); |
173 ais->Close(); | 171 ais->Close(); |
174 } | 172 } |
175 | |
176 } // namespace media | |
OLD | NEW |