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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "media/audio/cras/audio_manager_cras.h" | 10 #include "media/audio/cras/audio_manager_cras.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 virtual ~CrasUnifiedStreamTest() { | 67 virtual ~CrasUnifiedStreamTest() { |
68 } | 68 } |
69 | 69 |
70 CrasUnifiedStream* CreateStream(ChannelLayout layout) { | 70 CrasUnifiedStream* CreateStream(ChannelLayout layout) { |
71 return CreateStream(layout, kTestFramesPerPacket); | 71 return CreateStream(layout, kTestFramesPerPacket); |
72 } | 72 } |
73 | 73 |
74 CrasUnifiedStream* CreateStream(ChannelLayout layout, | 74 CrasUnifiedStream* CreateStream(ChannelLayout layout, |
75 int32 samples_per_packet) { | 75 int32_t samples_per_packet) { |
76 AudioParameters params(kTestFormat, layout, kTestSampleRate, | 76 AudioParameters params(kTestFormat, layout, kTestSampleRate, |
77 kTestBitsPerSample, samples_per_packet); | 77 kTestBitsPerSample, samples_per_packet); |
78 return new CrasUnifiedStream(params, mock_manager_.get()); | 78 return new CrasUnifiedStream(params, mock_manager_.get()); |
79 } | 79 } |
80 | 80 |
81 MockAudioManagerCras& mock_manager() { | 81 MockAudioManagerCras& mock_manager() { |
82 return *(mock_manager_.get()); | 82 return *(mock_manager_.get()); |
83 } | 83 } |
84 | 84 |
85 static const ChannelLayout kTestChannelLayout; | 85 static const ChannelLayout kTestChannelLayout; |
86 static const int kTestSampleRate; | 86 static const int kTestSampleRate; |
87 static const int kTestBitsPerSample; | 87 static const int kTestBitsPerSample; |
88 static const AudioParameters::Format kTestFormat; | 88 static const AudioParameters::Format kTestFormat; |
89 static const uint32 kTestFramesPerPacket; | 89 static const uint32_t kTestFramesPerPacket; |
90 | 90 |
91 scoped_ptr<StrictMock<MockAudioManagerCras> > mock_manager_; | 91 scoped_ptr<StrictMock<MockAudioManagerCras> > mock_manager_; |
92 | 92 |
93 private: | 93 private: |
94 DISALLOW_COPY_AND_ASSIGN(CrasUnifiedStreamTest); | 94 DISALLOW_COPY_AND_ASSIGN(CrasUnifiedStreamTest); |
95 }; | 95 }; |
96 | 96 |
97 const ChannelLayout CrasUnifiedStreamTest::kTestChannelLayout = | 97 const ChannelLayout CrasUnifiedStreamTest::kTestChannelLayout = |
98 CHANNEL_LAYOUT_STEREO; | 98 CHANNEL_LAYOUT_STEREO; |
99 const int CrasUnifiedStreamTest::kTestSampleRate = | 99 const int CrasUnifiedStreamTest::kTestSampleRate = |
100 AudioParameters::kAudioCDSampleRate; | 100 AudioParameters::kAudioCDSampleRate; |
101 const int CrasUnifiedStreamTest::kTestBitsPerSample = 16; | 101 const int CrasUnifiedStreamTest::kTestBitsPerSample = 16; |
102 const AudioParameters::Format CrasUnifiedStreamTest::kTestFormat = | 102 const AudioParameters::Format CrasUnifiedStreamTest::kTestFormat = |
103 AudioParameters::AUDIO_PCM_LINEAR; | 103 AudioParameters::AUDIO_PCM_LINEAR; |
104 const uint32 CrasUnifiedStreamTest::kTestFramesPerPacket = 1000; | 104 const uint32_t CrasUnifiedStreamTest::kTestFramesPerPacket = 1000; |
105 | 105 |
106 TEST_F(CrasUnifiedStreamTest, ConstructedState) { | 106 TEST_F(CrasUnifiedStreamTest, ConstructedState) { |
107 CrasUnifiedStream* test_stream = CreateStream(kTestChannelLayout); | 107 CrasUnifiedStream* test_stream = CreateStream(kTestChannelLayout); |
108 EXPECT_TRUE(test_stream->Open()); | 108 EXPECT_TRUE(test_stream->Open()); |
109 test_stream->Close(); | 109 test_stream->Close(); |
110 | 110 |
111 // Should support mono. | 111 // Should support mono. |
112 test_stream = CreateStream(CHANNEL_LAYOUT_MONO); | 112 test_stream = CreateStream(CHANNEL_LAYOUT_MONO); |
113 EXPECT_TRUE(test_stream->Open()); | 113 EXPECT_TRUE(test_stream->Open()); |
114 test_stream->Close(); | 114 test_stream->Close(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 // Wait for samples to be captured. | 152 // Wait for samples to be captured. |
153 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); | 153 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_timeout())); |
154 | 154 |
155 test_stream->Stop(); | 155 test_stream->Stop(); |
156 | 156 |
157 test_stream->Close(); | 157 test_stream->Close(); |
158 } | 158 } |
159 | 159 |
160 } // namespace media | 160 } // namespace media |
OLD | NEW |