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

// general test config
cc_defaults {
    name: "libmediautils_tests_config",

    cflags: [
        "-Wall",
        "-Werror",
        "-Wextra",
    ],

    sanitize: {
        undefined: true,
        misc_undefined: [
            "float-divide-by-zero",
            "local-bounds",
        ],
        integer_overflow: true,
        cfi: true,
        memtag_heap: true,
        diag: {
            undefined: true,
            misc_undefined: [
                "float-divide-by-zero",
                "local-bounds",
            ],
            integer_overflow: true,
            cfi: true,
            memtag_heap: true,
        },
    },
    target: {
        host: {
            sanitize: {
                cfi: false,
                diag: {
                    cfi: false,
                },
            },
        },
    },
}

cc_defaults {
    name: "libmediautils_tests_defaults",

    defaults: ["libmediautils_tests_config"],

    host_supported: true,

    shared_libs: [
        "libbinder",
        "liblog",
        "libmediautils",
        "libutils",
    ],
}

aidl_interface {
    name: "ServiceSingletonTestInterface",
    unstable: true,
    srcs: [
        "IServiceSingletonTest.aidl",
    ],
    backend: {
        cpp: {
            enabled: true,
        },
        ndk: {
            enabled: true,
        },
    },
}

cc_test_library {
    name: "libsharedtest",

    defaults: ["libmediautils_tests_defaults"],

    srcs: [
        "sharedtest.cpp",
    ],
}

cc_test {
    name: "library_tests",

    defaults: ["libmediautils_tests_defaults"],

    data_libs: [
        "libsharedtest",
    ],

    shared_libs: [
        "libbase",
    ],

    srcs: [
        "library_tests.cpp",
    ],
}

cc_test {
    name: "libmediautils_test",

    defaults: ["libmediautils_tests_defaults"],

    srcs: [
        "memory-test.cpp",
    ],
}

cc_test {
    name: "media_process_tests",

    defaults: ["libmediautils_tests_defaults"],

    srcs: [
        "media_process_tests.cpp",
    ],
}

cc_test {
    name: "media_synchronization_tests",

    defaults: ["libmediautils_tests_defaults"],

    srcs: [
        "media_synchronization_tests.cpp",
    ],
}

cc_test {
    name: "media_threadsnapshot_tests",

    defaults: ["libmediautils_tests_defaults"],

    srcs: [
        "media_threadsnapshot_tests.cpp",
    ],
}

cc_test {
    name: "mediautils_fixedstring_tests",

    defaults: ["libmediautils_tests_defaults"],

    shared_libs: [
        "libaudioutils",
    ],

    srcs: [
        "mediautils_fixedstring_tests.cpp",
    ],
}

cc_test {
    name: "mediautils_scopedstatistics_tests",

    defaults: ["libmediautils_tests_defaults"],

    shared_libs: [
        "libaudioutils",
    ],

    srcs: [
        "mediautils_scopedstatistics_tests.cpp",
    ],
}

cc_test {
    name: "methodstatistics_tests",

    defaults: ["libmediautils_tests_defaults"],

    shared_libs: [
        "libaudioutils",
    ],

    srcs: [
        "methodstatistics_tests.cpp",
    ],
}

cc_test {
    name: "service_singleton_tests",

    defaults: ["libmediautils_tests_config"],

    // to add and get services, we need to be root.
    require_root: true,
    host_supported: false,

    srcs: [
        "service_singleton_tests.cpp",
    ],

    shared_libs: [
        "libaudioutils",
        "libbinder",
        "libbinder_ndk",
        "liblog",
        "libmediautils",
        "libutils",
    ],

    static_libs: [
        "ServiceSingletonTestInterface-cpp",
        "ServiceSingletonTestInterface-ndk",
    ],
}

cc_test {
    name: "static_string_tests",

    defaults: ["libmediautils_tests_defaults"],

    srcs: [
        "static_string_view_tests.cpp",
    ],
}

cc_test {
    name: "timecheck_tests",

    defaults: ["libmediautils_tests_defaults"],

    srcs: [
        "timecheck_tests.cpp",
    ],
}

cc_test {
    name: "timerthread_tests",

    defaults: ["libmediautils_tests_defaults"],
    // TODO(b/270180838)
    test_options: {
        unit_test: false,
    },
    srcs: [
        "TimerThread-test.cpp",
    ],
}

cc_test {
    name: "extended_accumulator_tests",

    defaults: ["libmediautils_tests_defaults"],

    srcs: [
        "extended_accumulator_tests.cpp",
    ],
}

cc_test {
    name: "inplace_function_tests",

    defaults: ["libmediautils_tests_defaults"],

    srcs: [
        "inplace_function_tests.cpp",
    ],
}

cc_test {
    name: "shared_memory_allocator_tests",
    defaults: ["libmediautils_tests_defaults"],
    srcs: [
        "shared_memory_allocator_tests.cpp",
    ],
}

cc_test {
    name: "jthread_tests",
    defaults: ["libmediautils_tests_defaults"],
    srcs: [
        "jthread_tests.cpp",
    ],
}
