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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "media/audio/linux/alsa_output.h" | 7 #include "media/audio/linux/alsa_output.h" |
8 #include "media/audio/linux/alsa_wrapper.h" | 8 #include "media/audio/linux/alsa_wrapper.h" |
9 #include "media/audio/linux/audio_manager_linux.h" | 9 #include "media/audio/linux/audio_manager_linux.h" |
10 #include "media/base/data_buffer.h" | 10 #include "media/base/data_buffer.h" |
11 #include "media/base/seekable_buffer.h" | 11 #include "media/base/seekable_buffer.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using testing::_; | 15 using testing::_; |
16 using testing::AllOf; | 16 using testing::AllOf; |
17 using testing::AtLeast; | 17 using testing::AtLeast; |
18 using testing::DoAll; | 18 using testing::DoAll; |
19 using testing::Eq; | |
20 using testing::Field; | 19 using testing::Field; |
21 using testing::InSequence; | 20 using testing::InSequence; |
22 using testing::Invoke; | 21 using testing::Invoke; |
23 using testing::InvokeWithoutArgs; | 22 using testing::InvokeWithoutArgs; |
24 using testing::Mock; | 23 using testing::Mock; |
25 using testing::MockFunction; | 24 using testing::MockFunction; |
26 using testing::Return; | 25 using testing::Return; |
27 using testing::SetArgumentPointee; | 26 using testing::SetArgumentPointee; |
28 using testing::StrictMock; | 27 using testing::StrictMock; |
29 using testing::StrEq; | 28 using testing::StrEq; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Helper function to initialize |test_stream->buffer_|. Must be called | 141 // Helper function to initialize |test_stream->buffer_|. Must be called |
143 // in all tests that use buffer_ without opening the stream. | 142 // in all tests that use buffer_ without opening the stream. |
144 void InitBuffer(AlsaPcmOutputStream* test_stream) { | 143 void InitBuffer(AlsaPcmOutputStream* test_stream) { |
145 DCHECK(test_stream); | 144 DCHECK(test_stream); |
146 packet_ = new media::DataBuffer(kTestPacketSize); | 145 packet_ = new media::DataBuffer(kTestPacketSize); |
147 packet_->SetDataSize(kTestPacketSize); | 146 packet_->SetDataSize(kTestPacketSize); |
148 test_stream->buffer_.reset(new media::SeekableBuffer(0, kTestPacketSize)); | 147 test_stream->buffer_.reset(new media::SeekableBuffer(0, kTestPacketSize)); |
149 test_stream->buffer_->Append(packet_.get()); | 148 test_stream->buffer_->Append(packet_.get()); |
150 } | 149 } |
151 | 150 |
152 MockAudioManagerLinux& mock_manager() { | |
153 return *(mock_manager_.get()); | |
154 } | |
155 | |
156 static const ChannelLayout kTestChannelLayout; | 151 static const ChannelLayout kTestChannelLayout; |
157 static const int kTestSampleRate; | 152 static const int kTestSampleRate; |
158 static const int kTestBitsPerSample; | 153 static const int kTestBitsPerSample; |
159 static const int kTestBytesPerFrame; | 154 static const int kTestBytesPerFrame; |
160 static const AudioParameters::Format kTestFormat; | 155 static const AudioParameters::Format kTestFormat; |
161 static const char kTestDeviceName[]; | 156 static const char kTestDeviceName[]; |
162 static const char kDummyMessage[]; | 157 static const char kDummyMessage[]; |
163 static const uint32 kTestFramesPerPacket; | 158 static const uint32 kTestFramesPerPacket; |
164 static const int kTestPacketSize; | 159 static const int kTestPacketSize; |
165 static const int kTestFailedErrno; | 160 static const int kTestFailedErrno; |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 | 851 |
857 // TODO(ajwong): Find a way to test whether or not another task has been | 852 // TODO(ajwong): Find a way to test whether or not another task has been |
858 // posted so we can verify that the Alsa code will indeed break the task | 853 // posted so we can verify that the Alsa code will indeed break the task |
859 // posting loop. | 854 // posting loop. |
860 | 855 |
861 test_stream->TransitionTo(AlsaPcmOutputStream::kIsClosed); | 856 test_stream->TransitionTo(AlsaPcmOutputStream::kIsClosed); |
862 test_stream->Close(); | 857 test_stream->Close(); |
863 } | 858 } |
864 | 859 |
865 } // namespace media | 860 } // namespace media |
OLD | NEW |