OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/macros.h" | 5 #include "base/macros.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "media/audio/audio_io.h" | 10 #include "media/audio/audio_io.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 ACTION_P(SignalEvent, event) { | 30 ACTION_P(SignalEvent, event) { |
31 event->Signal(); | 31 event->Signal(); |
32 } | 32 } |
33 | 33 |
34 class AUHALStreamTest : public testing::Test { | 34 class AUHALStreamTest : public testing::Test { |
35 public: | 35 public: |
36 AUHALStreamTest() | 36 AUHALStreamTest() |
37 : message_loop_(base::MessageLoop::TYPE_UI), | 37 : message_loop_(base::MessageLoop::TYPE_UI), |
38 manager_(AudioManager::CreateForTesting()) { | 38 manager_(AudioManager::CreateForTesting(message_loop_.task_runner())) { |
39 // Wait for the AudioManager to finish any initialization on the audio loop. | 39 // Wait for the AudioManager to finish any initialization on the audio loop. |
40 base::RunLoop().RunUntilIdle(); | 40 base::RunLoop().RunUntilIdle(); |
41 } | 41 } |
42 | 42 |
43 ~AUHALStreamTest() override { base::RunLoop().RunUntilIdle(); } | 43 ~AUHALStreamTest() override { base::RunLoop().RunUntilIdle(); } |
44 | 44 |
45 AudioOutputStream* Create() { | 45 AudioOutputStream* Create() { |
46 return manager_->MakeAudioOutputStream( | 46 return manager_->MakeAudioOutputStream( |
47 manager_->GetDefaultOutputStreamParameters(), ""); | 47 manager_->GetDefaultOutputStreamParameters(), ""); |
48 } | 48 } |
49 | 49 |
50 bool OutputDevicesAvailable() { | 50 bool OutputDevicesAvailable() { |
51 return manager_->HasAudioOutputDevices(); | 51 return manager_->HasAudioOutputDevices(); |
52 } | 52 } |
53 | 53 |
54 protected: | 54 protected: |
55 base::MessageLoop message_loop_; | 55 base::MessageLoop message_loop_; |
56 scoped_ptr<AudioManager> manager_; | 56 ScopedAudioManagerPtr manager_; |
57 MockAudioSourceCallback source_; | 57 MockAudioSourceCallback source_; |
58 | 58 |
59 private: | 59 private: |
60 DISALLOW_COPY_AND_ASSIGN(AUHALStreamTest); | 60 DISALLOW_COPY_AND_ASSIGN(AUHALStreamTest); |
61 }; | 61 }; |
62 | 62 |
63 TEST_F(AUHALStreamTest, HardwareSampleRate) { | 63 TEST_F(AUHALStreamTest, HardwareSampleRate) { |
64 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); | 64 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); |
65 const AudioParameters preferred_params = | 65 const AudioParameters preferred_params = |
66 manager_->GetDefaultOutputStreamParameters(); | 66 manager_->GetDefaultOutputStreamParameters(); |
(...skipping 25 matching lines...) Expand all Loading... |
92 .WillOnce(DoAll(ZeroBuffer(), SignalEvent(&event), Return(0))); | 92 .WillOnce(DoAll(ZeroBuffer(), SignalEvent(&event), Return(0))); |
93 EXPECT_CALL(source_, OnError(_)).Times(0); | 93 EXPECT_CALL(source_, OnError(_)).Times(0); |
94 stream->Start(&source_); | 94 stream->Start(&source_); |
95 event.Wait(); | 95 event.Wait(); |
96 | 96 |
97 stream->Stop(); | 97 stream->Stop(); |
98 stream->Close(); | 98 stream->Close(); |
99 } | 99 } |
100 | 100 |
101 } // namespace media | 101 } // namespace media |
OLD | NEW |