| 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 <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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 FakeAudioLogFactory fake_audio_log_factory_; | 61 FakeAudioLogFactory fake_audio_log_factory_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 class CrasInputStreamTest : public testing::Test { | 64 class CrasInputStreamTest : public testing::Test { |
| 65 protected: | 65 protected: |
| 66 CrasInputStreamTest() { | 66 CrasInputStreamTest() { |
| 67 mock_manager_.reset(new StrictMock<MockAudioManagerCrasInput>()); | 67 mock_manager_.reset(new StrictMock<MockAudioManagerCrasInput>()); |
| 68 base::RunLoop().RunUntilIdle(); | 68 base::RunLoop().RunUntilIdle(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 ~CrasInputStreamTest() override {} | 71 ~CrasInputStreamTest() override { |
| 72 mock_manager_->GetTaskRunner()->PostTask( |
| 73 FROM_HERE, base::Bind(&media::AudioManager::Shutdown, |
| 74 base::Unretained(mock_manager_.get()))); |
| 75 } |
| 72 | 76 |
| 73 CrasInputStream* CreateStream(ChannelLayout layout) { | 77 CrasInputStream* CreateStream(ChannelLayout layout) { |
| 74 return CreateStream(layout, kTestFramesPerPacket); | 78 return CreateStream(layout, kTestFramesPerPacket); |
| 75 } | 79 } |
| 76 | 80 |
| 77 CrasInputStream* CreateStream(ChannelLayout layout, | 81 CrasInputStream* CreateStream(ChannelLayout layout, |
| 78 int32_t samples_per_packet) { | 82 int32_t samples_per_packet) { |
| 79 return CreateStream(layout, samples_per_packet, | 83 return CreateStream(layout, samples_per_packet, |
| 80 AudioDeviceDescription::kDefaultDeviceId); | 84 AudioDeviceDescription::kDefaultDeviceId); |
| 81 } | 85 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 122 } |
| 119 | 123 |
| 120 static const unsigned int kTestBitsPerSample; | 124 static const unsigned int kTestBitsPerSample; |
| 121 static const unsigned int kTestCaptureDurationMs; | 125 static const unsigned int kTestCaptureDurationMs; |
| 122 static const ChannelLayout kTestChannelLayout; | 126 static const ChannelLayout kTestChannelLayout; |
| 123 static const AudioParameters::Format kTestFormat; | 127 static const AudioParameters::Format kTestFormat; |
| 124 static const uint32_t kTestFramesPerPacket; | 128 static const uint32_t kTestFramesPerPacket; |
| 125 static const int kTestSampleRate; | 129 static const int kTestSampleRate; |
| 126 | 130 |
| 127 base::TestMessageLoop message_loop_; | 131 base::TestMessageLoop message_loop_; |
| 128 std::unique_ptr<StrictMock<MockAudioManagerCrasInput>, AudioManagerDeleter> | 132 std::unique_ptr<StrictMock<MockAudioManagerCrasInput>> mock_manager_; |
| 129 mock_manager_; | |
| 130 | 133 |
| 131 private: | 134 private: |
| 132 DISALLOW_COPY_AND_ASSIGN(CrasInputStreamTest); | 135 DISALLOW_COPY_AND_ASSIGN(CrasInputStreamTest); |
| 133 }; | 136 }; |
| 134 | 137 |
| 135 const unsigned int CrasInputStreamTest::kTestBitsPerSample = 16; | 138 const unsigned int CrasInputStreamTest::kTestBitsPerSample = 16; |
| 136 const unsigned int CrasInputStreamTest::kTestCaptureDurationMs = 250; | 139 const unsigned int CrasInputStreamTest::kTestCaptureDurationMs = 250; |
| 137 const ChannelLayout CrasInputStreamTest::kTestChannelLayout = | 140 const ChannelLayout CrasInputStreamTest::kTestChannelLayout = |
| 138 CHANNEL_LAYOUT_STEREO; | 141 CHANNEL_LAYOUT_STEREO; |
| 139 const AudioParameters::Format CrasInputStreamTest::kTestFormat = | 142 const AudioParameters::Format CrasInputStreamTest::kTestFormat = |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 226 |
| 224 TEST_F(CrasInputStreamTest, CaptureLoopback) { | 227 TEST_F(CrasInputStreamTest, CaptureLoopback) { |
| 225 CrasInputStream* test_stream = | 228 CrasInputStream* test_stream = |
| 226 CreateStream(CHANNEL_LAYOUT_STEREO, kTestFramesPerPacket, | 229 CreateStream(CHANNEL_LAYOUT_STEREO, kTestFramesPerPacket, |
| 227 AudioDeviceDescription::kLoopbackInputDeviceId); | 230 AudioDeviceDescription::kLoopbackInputDeviceId); |
| 228 EXPECT_TRUE(test_stream->Open()); | 231 EXPECT_TRUE(test_stream->Open()); |
| 229 test_stream->Close(); | 232 test_stream->Close(); |
| 230 } | 233 } |
| 231 | 234 |
| 232 } // namespace media | 235 } // namespace media |
| OLD | NEW |