//
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "hardware_interfaces_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["hardware_interfaces_license"],
}

cc_defaults {
    name: "VtsHalAudioTargetTest_defaults",
    defaults: ["VtsHalTargetTestDefaults"],
    static_libs: [
        "android.hardware.audio.common.test.utility",
        "audioclient-types-aidl-cpp",
        "libaudioclient_aidl_conversion",
        "libaudio_aidl_conversion_common_cpp",
        "libstagefright_foundation",
    ],
    shared_libs: [
        "libbinder",
        "libcutils",
        "libfmq",
        "libxml2",
    ],
    header_libs: [
        "android.hardware.audio.common.util@all-versions",
    ],
    test_suites: [
        "general-tests",
        "vts",
    ],
}

cc_test {
    name: "VtsHalAudioV2_0TargetTest",
    defaults: [
        "VtsHalAudioTargetTest_defaults",
        "latest_android_media_audio_common_types_cpp_static",
    ],
    tidy_timeout_srcs: [
        "2.0/AudioPrimaryHidlHalTest.cpp",
    ],
    srcs: [
        "2.0/AudioPrimaryHidlHalTest.cpp",
    ],
    static_libs: [
        "libaudiofoundation",
        "libaudiopolicycomponents",
        "libmedia_helper",
        "android.hardware.audio@2.0",
        "android.hardware.audio.common@2.0",
    ],
    cflags: [
        "-DMAJOR_VERSION=2",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ],
    data: [
        ":audio_policy_configuration_V2_0",
    ],
    // Use test_config for vts suite.
    // TODO(b/146104851): Add auto-gen rules and remove it.
    test_config: "VtsHalAudioV2_0TargetTest.xml",
}

cc_test {
    name: "VtsHalAudioV4_0TargetTest",
    defaults: [
        "VtsHalAudioTargetTest_defaults",
        "latest_android_media_audio_common_types_cpp_static",
    ],
    tidy_timeout_srcs: [
        "4.0/AudioPrimaryHidlHalTest.cpp",
    ],
    srcs: [
        "4.0/AudioPrimaryHidlHalTest.cpp",
    ],
    static_libs: [
        "libaudiofoundation",
        "libaudiopolicycomponents",
        "libmedia_helper",
        "android.hardware.audio@4.0",
        "android.hardware.audio.common@4.0",
    ],
    cflags: [
        "-DMAJOR_VERSION=4",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ],
    data: [
        ":audio_policy_configuration_V4_0",
    ],
    // Use test_config for vts suite.
    // TODO(b/146104851): Add auto-gen rules and remove it.
    test_config: "VtsHalAudioV4_0TargetTest.xml",
}

cc_test {
    name: "VtsHalAudioV5_0TargetTest",
    defaults: [
        "VtsHalAudioTargetTest_defaults",
        "latest_android_media_audio_common_types_cpp_static",
    ],
    srcs: [
        "5.0/AudioPrimaryHidlHalTest.cpp",
    ],
    static_libs: [
        "libaudiofoundation",
        "libaudiopolicycomponents",
        "libmedia_helper",
        "android.hardware.audio@5.0",
        "android.hardware.audio.common@5.0",
    ],
    cflags: [
        "-DMAJOR_VERSION=5",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ],
    data: [
        ":audio_policy_configuration_V5_0",
    ],
    // Use test_config for vts suite.
    // TODO(b/146104851): Add auto-gen rules and remove it.
    test_config: "VtsHalAudioV5_0TargetTest.xml",
}

cc_test {
    name: "VtsHalAudioV6_0TargetTest",
    defaults: [
        "VtsHalAudioTargetTest_defaults",
        "latest_android_media_audio_common_types_cpp_static",
    ],
    tidy_timeout_srcs: [
        "6.0/AudioPrimaryHidlHalTest.cpp",
    ],
    srcs: [
        "6.0/AudioPrimaryHidlHalTest.cpp",
        "6.0/Generators.cpp",
    ],
    static_libs: [
        "libaudiofoundation",
        "libaudiopolicycomponents",
        "libmedia_helper",
        "android.hardware.audio@6.0",
        "android.hardware.audio.common@6.0",
    ],
    cflags: [
        "-DMAJOR_VERSION=6",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ],
    data: [
        ":audio_policy_configuration_V6_0",
    ],
    // Use test_config for vts suite.
    // TODO(b/146104851): Add auto-gen rules and remove it.
    test_config: "VtsHalAudioV6_0TargetTest.xml",
}

cc_test {
    name: "VtsHalAudioV7_0TargetTest",
    defaults: ["VtsHalAudioTargetTest_defaults"],
    tidy_timeout_srcs: [
        "7.0/AudioPrimaryHidlHalTest.cpp",
    ],
    srcs: [
        "7.0/AudioPrimaryHidlHalTest.cpp",
        "7.0/Generators.cpp",
        "7.0/PolicyConfig.cpp",
    ],
    generated_headers: ["audio_policy_configuration_V7_0_parser"],
    generated_sources: ["audio_policy_configuration_V7_0_parser"],
    static_libs: [
        "android.hardware.audio@7.0",
        "android.hardware.audio.common@7.0",
        "android.hardware.audio.common@7.0-enums",
        "android.hardware.audio.common@7.0-util",
    ],
    cflags: [
        "-DMAJOR_VERSION=7",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ],
    data: [
        ":audio_policy_configuration_V7_0",
        "data/sine882hz3s.mp3",
    ],
    // Use test_config for vts suite.
    // TODO(b/146104851): Add auto-gen rules and remove it.
    test_config: "VtsHalAudioV7_0TargetTest.xml",
}

cc_test {
    name: "VtsHalAudioV7_1TargetTest",
    defaults: ["VtsHalAudioTargetTest_defaults"],
    srcs: [
        "7.1/AudioPrimaryHidlHalTest.cpp",
        "7.0/Generators.cpp",
        "7.0/PolicyConfig.cpp",
    ],
    generated_headers: ["audio_policy_configuration_V7_1_parser"],
    generated_sources: ["audio_policy_configuration_V7_1_parser"],
    static_libs: [
        "android.hardware.audio@7.0",
        "android.hardware.audio@7.1",
        "android.hardware.audio.common@7.0",
        "android.hardware.audio.common@7.0-enums",
        "android.hardware.audio.common@7.1-enums",
        "android.hardware.audio.common@7.1-util",
    ],
    cflags: [
        "-DMAJOR_VERSION=7",
        "-DMINOR_VERSION=1",
        "-DCOMMON_TYPES_MINOR_VERSION=0",
        "-DCORE_TYPES_MINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ],
    data: [
        ":audio_policy_configuration_V7_1",
        "data/sine882hz3s.mp3",
    ],
    // Use test_config for vts suite.
    // TODO(b/146104851): Add auto-gen rules and remove it.
    test_config: "VtsHalAudioV7_1TargetTest.xml",
}

// Note: the following aren't VTS tests, but rather unit tests
// to verify correctness of test utilities.
cc_test {
    name: "HalAudioStreamWorkerTest",
    host_supported: true,
    srcs: [
        "tests/streamworker_tests.cpp",
    ],
}

cc_test {
    name: "HalAudioV6_0GeneratorTest",
    defaults: [
        "VtsHalAudioTargetTest_defaults",
        "latest_android_media_audio_common_types_cpp_static",
    ],
    srcs: [
        "6.0/Generators.cpp",
        "tests/generators_tests.cpp",
    ],
    static_libs: [
        "android.hardware.audio@6.0",
        "android.hardware.audio.common@6.0",
        "libaudiofoundation",
        "libaudiopolicycomponents",
        "libmedia_helper",
    ],
    cflags: [
        "-DMAJOR_VERSION=6",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ],
    data: [
        "tests/apm_config_no_vx.xml",
        "tests/apm_config_with_vx.xml",
        "tests/apm_config_b_205808571_6_0.xml",
    ],
    test_config: "tests/HalAudioV6_0GeneratorTest.xml",
}

cc_test {
    name: "HalAudioV7_0GeneratorTest",
    defaults: ["VtsHalAudioTargetTest_defaults"],
    srcs: [
        "7.0/Generators.cpp",
        "7.0/PolicyConfig.cpp",
        "tests/generators_tests.cpp",
    ],
    generated_headers: ["audio_policy_configuration_V7_0_parser"],
    generated_sources: ["audio_policy_configuration_V7_0_parser"],
    static_libs: [
        "android.hardware.audio@7.0",
        "android.hardware.audio.common@7.0",
        "android.hardware.audio.common@7.0-enums",
        "android.hardware.audio.common@7.0-util",
    ],
    cflags: [
        "-DMAJOR_VERSION=7",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ],
    data: [
        "tests/apm_config_no_vx_7_0.xml",
        "tests/apm_config_with_vx_7_0.xml",
        "tests/apm_config_b_204314749_7_0.xml",
        "tests/apm_config_b_205808571_7_0.xml",
    ],
    test_config: "tests/HalAudioV7_0GeneratorTest.xml",
}
