1 /* 2 * Copyright (C) 2023 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 <memory> 18 // #include <string> 19 // #include <vector> 20 21 #include <android-base/macros.h> 22 #include <gtest/gtest.h> 23 #define LOG_TAG "AudioPolicyConfigXmlConverterTest" 24 #include <log/log.h> 25 26 #include <core-impl/AudioPolicyConfigXmlConverter.h> 27 #include <media/AidlConversionCppNdk.h> 28 29 using aidl::android::hardware::audio::core::internal::AudioPolicyConfigXmlConverter; 30 using aidl::android::media::audio::common::AudioFormatDescription; 31 32 namespace { 33 ValidateAudioFormatDescription(const AudioFormatDescription & format)34void ValidateAudioFormatDescription(const AudioFormatDescription& format) { 35 auto conv = ::aidl::android::aidl2legacy_AudioFormatDescription_audio_format_t(format); 36 ASSERT_TRUE(conv.ok()) << format.toString(); 37 } 38 39 } // namespace 40 TEST(AudioPolicyConfigXmlConverterTest,DefaultSurroundSoundConfigIsValid)41TEST(AudioPolicyConfigXmlConverterTest, DefaultSurroundSoundConfigIsValid) { 42 auto config = AudioPolicyConfigXmlConverter::getDefaultSurroundSoundConfig(); 43 for (const auto& family : config.formatFamilies) { 44 EXPECT_NO_FATAL_FAILURE(ValidateAudioFormatDescription(family.primaryFormat)); 45 SCOPED_TRACE(family.primaryFormat.toString()); 46 for (const auto& sub : family.subFormats) { 47 EXPECT_NO_FATAL_FAILURE(ValidateAudioFormatDescription(sub)); 48 } 49 } 50 } 51