// Copyright 2021 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 {
    default_applicable_licenses: [
        "frameworks_av_services_camera_libcameraservice_license",
    ],
}

cc_defaults {
    name: "cameraservice_test_hostsupported",

    // All test sources that can run on both host and device
    // should be listed here
    srcs: [
        "ClientManagerTest.cpp",
        "DepthProcessorTest.cpp",
        "DistortionMapperTest.cpp",
        "ExifUtilsTest.cpp",
        "NV12Compressor.cpp",
        "RotateAndCropMapperTest.cpp",
        "SessionStatsBuilderTest.cpp",
        "ZoomRatioTest.cpp",
    ],

    // All shared libs available on both host and device
    // should be listed here
    shared_libs: [
        "libbase",
        "libbinder",
        "libcamera_metadata",
        "libexif",
        "libjpeg",
        "liblog",
        "libutils",
    ],

    static_libs: [
        "libgmock",
    ],

    target: {
        android: {
            shared_libs: [
                "camera_platform_flags_c_lib",
            ],
        },
        host: {
            shared_libs: [
                "camera_platform_flags_c_lib_for_test",
            ],
        },
    },

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

    test_suites: ["device-tests"],

}

cc_test {
    name: "cameraservice_test",

    include_dirs: [
        "system/media/private/camera/include",
        "external/dynamic_depth/includes",
        "external/dynamic_depth/internal",
    ],

    header_libs: [
        "libmedia_headers",
    ],

    defaults: [
        "libcameraservice_deps",
        "cameraservice_test_hostsupported",
    ],

    // Only include libs that can't be run host-side here
    shared_libs: [
        "libcutils",
        "libhidlbase",
        "libcamera_client",
        "libgui",
        "libui",
        "android.companion.virtualdevice.flags-aconfig-cc",
        "android.hardware.camera.common@1.0",
        "android.hardware.camera.device@1.0",
        "android.hardware.camera.device@3.2",
        "android.hardware.camera.device@3.4",
        "android.hardware.camera.device@3.7",
        "android.hidl.token@1.0-utils",
        "camera_platform_flags_c_lib",
    ],

    // Only include libs that can't be run host-side here
    static_libs: [
        "android.hardware.camera.provider@2.4",
        "android.hardware.camera.provider@2.5",
        "android.hardware.camera.provider@2.6",
        "android.hardware.camera.provider@2.7",
        "android.hardware.camera.provider-V3-ndk",
        "libcameraservice",
        "libflagtest",
    ],

    // Only include sources that can't be run host-side here
    srcs: [
        "Camera3StreamSplitterTest.cpp",
        "CameraPermissionsTest.cpp",
        "CameraProviderManagerTest.cpp",
    ],

}

cc_test_host {
    name: "cameraservice_test_host",

    defaults: [
        "cameraservice_test_hostsupported",
    ],

    include_dirs: [
        "frameworks/av/camera/include",
        "frameworks/av/camera/include/camera",
        "frameworks/native/libs/binder/include_activitymanager",
    ],

    // Only include libs that can't be run device-side here
    shared_libs: [
        "libactivity_manager_procstate_aidl-cpp",
        "libdynamic_depth",
    ],

    // Only include libs that can't be run device-side here
    static_libs: [
        "libcamera_client_host",
        "libcameraservice_device_independent",
    ],

}
