1 /*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "wav_reader.h"
18
19 #include <gtest/gtest.h>
20
21 #include <memory>
22 #include <string>
23
24 #include "test_util.h"
25
26 namespace {
27 constexpr uint32_t kSampleRate = 44100;
28 constexpr char kWavFile[] = "test/a2dp/raw_data/pcm0844s.wav";
29 } // namespace
30
31 namespace bluetooth {
32 namespace testing {
33
34 class WavReaderTest : public ::testing::Test {
35 protected:
SetUp()36 void SetUp() override {}
37
TearDown()38 void TearDown() override {}
39 };
40
TEST_F(WavReaderTest,read_wav_header)41 TEST_F(WavReaderTest, read_wav_header) {
42 std::unique_ptr<WavReader> wav_file =
43 std::make_unique<WavReader>(GetWavFilePath(kWavFile).c_str());
44 ASSERT_EQ(wav_file->GetHeader().sample_rate, kSampleRate);
45 }
46
TEST_F(WavReaderTest,check_wav_sample_count)47 TEST_F(WavReaderTest, check_wav_sample_count) {
48 std::unique_ptr<WavReader> wav_file =
49 std::make_unique<WavReader>(GetWavFilePath(kWavFile).c_str());
50 ASSERT_EQ(wav_file->GetHeader().subchunk2_size, wav_file->GetSampleCount());
51 }
52 } // namespace testing
53 } // namespace bluetooth
54