| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 9 #include "media/audio/sounds/test_data.h" | 9 #include "media/audio/sounds/test_data.h" |
| 10 #include "media/audio/sounds/wav_audio_handler.h" | 10 #include "media/audio/sounds/wav_audio_handler.h" |
| 11 #include "media/base/audio_bus.h" | 11 #include "media/base/audio_bus.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 TEST(WavAudioHandlerTest, SampleDataTest) { | 16 TEST(WavAudioHandlerTest, SampleDataTest) { |
| 17 WavAudioHandler handler(base::StringPiece(kTestAudioData, | 17 WavAudioHandler handler(base::StringPiece(kTestAudioData, |
| 18 arraysize(kTestAudioData))); | 18 arraysize(kTestAudioData))); |
| 19 ASSERT_EQ(static_cast<uint16>(2), handler.num_channels()); | 19 const AudioParameters& params = handler.params(); |
| 20 ASSERT_EQ(static_cast<uint16>(16), handler.bits_per_sample()); | 20 ASSERT_EQ(2, params.channels()); |
| 21 ASSERT_EQ(static_cast<uint32>(48000), handler.sample_rate()); | 21 ASSERT_EQ(16, params.bits_per_sample()); |
| 22 ASSERT_EQ(static_cast<uint32>(96000), handler.byte_rate()); | 22 ASSERT_EQ(48000, params.sample_rate()); |
| 23 ASSERT_EQ(192000, params.GetBytesPerSecond()); |
| 23 | 24 |
| 24 ASSERT_EQ(4, handler.size()); | 25 ASSERT_EQ(4U, handler.data().size()); |
| 26 const char kData[] = "\x01\x00\x01\x00"; |
| 27 ASSERT_EQ(base::StringPiece(kData, arraysize(kData) - 1), handler.data()); |
| 28 |
| 25 scoped_ptr<AudioBus> bus = AudioBus::Create( | 29 scoped_ptr<AudioBus> bus = AudioBus::Create( |
| 26 handler.num_channels(), | 30 params.channels(), handler.data().size() / params.channels()); |
| 27 handler.size() / handler.num_channels()); | 31 |
| 28 size_t bytes_written; | 32 size_t bytes_written; |
| 29 ASSERT_TRUE(handler.CopyTo(bus.get(), 0, &bytes_written)); | 33 ASSERT_TRUE(handler.CopyTo(bus.get(), 0, &bytes_written)); |
| 30 ASSERT_EQ(static_cast<size_t>(handler.size()), bytes_written); | 34 ASSERT_EQ(static_cast<size_t>(handler.data().size()), bytes_written); |
| 31 } | 35 } |
| 32 | 36 |
| 33 } // namespace media | 37 } // namespace media |
| OLD | NEW |