| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "media/audio/linux/alsa_output.h" | 6 #include "media/audio/linux/alsa_output.h" |
| 7 #include "media/audio/linux/alsa_wrapper.h" | 7 #include "media/audio/linux/alsa_wrapper.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 AlsaPcmOutputStreamTest::kTestFramesPerPacket * | 101 AlsaPcmOutputStreamTest::kTestFramesPerPacket * |
| 102 AlsaPcmOutputStreamTest::kTestBytesPerFrame; | 102 AlsaPcmOutputStreamTest::kTestBytesPerFrame; |
| 103 const int AlsaPcmOutputStreamTest::kTestFailedErrno = -EACCES; | 103 const int AlsaPcmOutputStreamTest::kTestFailedErrno = -EACCES; |
| 104 snd_pcm_t* const AlsaPcmOutputStreamTest::kFakeHandle = | 104 snd_pcm_t* const AlsaPcmOutputStreamTest::kFakeHandle = |
| 105 reinterpret_cast<snd_pcm_t*>(1); | 105 reinterpret_cast<snd_pcm_t*>(1); |
| 106 | 106 |
| 107 TEST_F(AlsaPcmOutputStreamTest, ConstructedState) { | 107 TEST_F(AlsaPcmOutputStreamTest, ConstructedState) { |
| 108 EXPECT_EQ(AlsaPcmOutputStream::kCreated, | 108 EXPECT_EQ(AlsaPcmOutputStream::kCreated, |
| 109 test_stream_->shared_data_.state()); | 109 test_stream_->shared_data_.state()); |
| 110 | 110 |
| 111 // Only supports 2 channel. | 111 // Should support mono. |
| 112 test_stream_ = new AlsaPcmOutputStream(kTestDeviceName, | 112 test_stream_ = new AlsaPcmOutputStream(kTestDeviceName, |
| 113 kTestFormat, | 113 kTestFormat, |
| 114 kTestChannels + 1, | 114 1, // Channels. |
| 115 kTestSampleRate, | 115 kTestSampleRate, |
| 116 kTestBitsPerSample, | 116 kTestBitsPerSample, |
| 117 &mock_alsa_wrapper_, | 117 &mock_alsa_wrapper_, |
| 118 &message_loop_); |
| 119 EXPECT_EQ(AlsaPcmOutputStream::kCreated, |
| 120 test_stream_->shared_data_.state()); |
| 121 |
| 122 // Should not support multi-channel. |
| 123 test_stream_ = new AlsaPcmOutputStream(kTestDeviceName, |
| 124 kTestFormat, |
| 125 3, // Channels. |
| 126 kTestSampleRate, |
| 127 kTestBitsPerSample, |
| 128 &mock_alsa_wrapper_, |
| 118 &message_loop_); | 129 &message_loop_); |
| 119 EXPECT_EQ(AlsaPcmOutputStream::kInError, | 130 EXPECT_EQ(AlsaPcmOutputStream::kInError, |
| 120 test_stream_->shared_data_.state()); | 131 test_stream_->shared_data_.state()); |
| 121 | 132 |
| 122 // Bad bits per sample. | 133 // Bad bits per sample. |
| 123 test_stream_ = new AlsaPcmOutputStream(kTestDeviceName, | 134 test_stream_ = new AlsaPcmOutputStream(kTestDeviceName, |
| 124 kTestFormat, | 135 kTestFormat, |
| 125 kTestChannels, | 136 kTestChannels, |
| 126 kTestSampleRate, | 137 kTestSampleRate, |
| 127 kTestBitsPerSample - 1, | 138 kTestBitsPerSample - 1, |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 381 |
| 371 test_stream_->stop_stream_ = true; | 382 test_stream_->stop_stream_ = true; |
| 372 test_stream_->ScheduleNextWrite(&packet_); | 383 test_stream_->ScheduleNextWrite(&packet_); |
| 373 | 384 |
| 374 // TODO(ajwong): Find a way to test whether or not another task has been | 385 // TODO(ajwong): Find a way to test whether or not another task has been |
| 375 // posted so we can verify that the Alsa code will indeed break the task | 386 // posted so we can verify that the Alsa code will indeed break the task |
| 376 // posting loop. | 387 // posting loop. |
| 377 | 388 |
| 378 test_stream_->shared_data_.TransitionTo(AlsaPcmOutputStream::kIsClosed); | 389 test_stream_->shared_data_.TransitionTo(AlsaPcmOutputStream::kIsClosed); |
| 379 } | 390 } |
| OLD | NEW |