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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 FakeAudioLogFactory fake_audio_log_factory_; | 56 FakeAudioLogFactory fake_audio_log_factory_; |
57 }; | 57 }; |
58 | 58 |
59 class CrasUnifiedStreamTest : public testing::Test { | 59 class CrasUnifiedStreamTest : public testing::Test { |
60 protected: | 60 protected: |
61 CrasUnifiedStreamTest() { | 61 CrasUnifiedStreamTest() { |
62 mock_manager_.reset(new StrictMock<MockAudioManagerCras>()); | 62 mock_manager_.reset(new StrictMock<MockAudioManagerCras>()); |
63 base::RunLoop().RunUntilIdle(); | 63 base::RunLoop().RunUntilIdle(); |
64 } | 64 } |
65 | 65 |
66 ~CrasUnifiedStreamTest() override {} | 66 ~CrasUnifiedStreamTest() override { |
| 67 mock_manager_->GetTaskRunner()->PostTask( |
| 68 FROM_HERE, base::Bind(&media::AudioManager::Shutdown, |
| 69 base::Unretained(mock_manager_.get()))); |
| 70 } |
67 | 71 |
68 CrasUnifiedStream* CreateStream(ChannelLayout layout) { | 72 CrasUnifiedStream* CreateStream(ChannelLayout layout) { |
69 return CreateStream(layout, kTestFramesPerPacket); | 73 return CreateStream(layout, kTestFramesPerPacket); |
70 } | 74 } |
71 | 75 |
72 CrasUnifiedStream* CreateStream(ChannelLayout layout, | 76 CrasUnifiedStream* CreateStream(ChannelLayout layout, |
73 int32_t samples_per_packet) { | 77 int32_t samples_per_packet) { |
74 AudioParameters params(kTestFormat, layout, kTestSampleRate, | 78 AudioParameters params(kTestFormat, layout, kTestSampleRate, |
75 kTestBitsPerSample, samples_per_packet); | 79 kTestBitsPerSample, samples_per_packet); |
76 return new CrasUnifiedStream(params, mock_manager_.get(), | 80 return new CrasUnifiedStream(params, mock_manager_.get(), |
77 AudioDeviceDescription::kDefaultDeviceId); | 81 AudioDeviceDescription::kDefaultDeviceId); |
78 } | 82 } |
79 | 83 |
80 MockAudioManagerCras& mock_manager() { | 84 MockAudioManagerCras& mock_manager() { |
81 return *(mock_manager_.get()); | 85 return *(mock_manager_.get()); |
82 } | 86 } |
83 | 87 |
84 static const ChannelLayout kTestChannelLayout; | 88 static const ChannelLayout kTestChannelLayout; |
85 static const int kTestSampleRate; | 89 static const int kTestSampleRate; |
86 static const int kTestBitsPerSample; | 90 static const int kTestBitsPerSample; |
87 static const AudioParameters::Format kTestFormat; | 91 static const AudioParameters::Format kTestFormat; |
88 static const uint32_t kTestFramesPerPacket; | 92 static const uint32_t kTestFramesPerPacket; |
89 | 93 |
90 base::TestMessageLoop message_loop_; | 94 base::TestMessageLoop message_loop_; |
91 std::unique_ptr<StrictMock<MockAudioManagerCras>, AudioManagerDeleter> | 95 std::unique_ptr<StrictMock<MockAudioManagerCras>> mock_manager_; |
92 mock_manager_; | |
93 | 96 |
94 private: | 97 private: |
95 DISALLOW_COPY_AND_ASSIGN(CrasUnifiedStreamTest); | 98 DISALLOW_COPY_AND_ASSIGN(CrasUnifiedStreamTest); |
96 }; | 99 }; |
97 | 100 |
98 const ChannelLayout CrasUnifiedStreamTest::kTestChannelLayout = | 101 const ChannelLayout CrasUnifiedStreamTest::kTestChannelLayout = |
99 CHANNEL_LAYOUT_STEREO; | 102 CHANNEL_LAYOUT_STEREO; |
100 const int CrasUnifiedStreamTest::kTestSampleRate = | 103 const int CrasUnifiedStreamTest::kTestSampleRate = |
101 AudioParameters::kAudioCDSampleRate; | 104 AudioParameters::kAudioCDSampleRate; |
102 const int CrasUnifiedStreamTest::kTestBitsPerSample = 16; | 105 const int CrasUnifiedStreamTest::kTestBitsPerSample = 16; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 158 |
156 // Wait for samples to be captured. | 159 // Wait for samples to be captured. |
157 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); | 160 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); |
158 | 161 |
159 test_stream->Stop(); | 162 test_stream->Stop(); |
160 | 163 |
161 test_stream->Close(); | 164 test_stream->Close(); |
162 } | 165 } |
163 | 166 |
164 } // namespace media | 167 } // namespace media |
OLD | NEW |