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
3 // found in the LICENSE file.
5 #include "base/basictypes.h"
6 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_piece.h"
9 #include "media/audio/sounds/test_data.h"
10 #include "media/audio/sounds/wav_audio_handler.h"
11 #include "media/base/audio_bus.h"
12 #include "testing/gtest/include/gtest/gtest.h"
16 TEST(WavAudioHandlerTest
, SampleDataTest
) {
17 WavAudioHandler
handler(base::StringPiece(kTestAudioData
,
18 arraysize(kTestAudioData
)));
19 const AudioParameters
& params
= handler
.params();
20 ASSERT_EQ(2, params
.channels());
21 ASSERT_EQ(16, params
.bits_per_sample());
22 ASSERT_EQ(48000, params
.sample_rate());
23 ASSERT_EQ(192000, params
.GetBytesPerSecond());
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());
29 scoped_ptr
<AudioBus
> bus
= AudioBus::Create(
30 params
.channels(), handler
.data().size() / params
.channels());
33 ASSERT_TRUE(handler
.CopyTo(bus
.get(), 0, &bytes_written
));
34 ASSERT_EQ(static_cast<size_t>(handler
.data().size()), bytes_written
);