# Copyright (c) 2021-2023 Huawei Device Co., Ltd.
# 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.

if (defined(ohos_lite)) {
  import("//build/lite/config/test.gni")
} else {
  import("//build/config/sanitizers/sanitizers.gni")
  import("//build/test.gni")
}
import("./../../../../hdf_core/adapter/uhdf2/uhdf.gni")

if (defined(ohos_lite)) {
  output_path = "$root_out_dir/test/moduletest/hdf/usb"
  moduletest("usb_host_serial_func_test") {
    output_extension = "bin"
    output_dir = output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "./../../sample/host/include",
      "./../../../../hdf_core/adapter/khdf/liteos/model/usb/host/include",
      "//third_party/bounds_checking_function/include",
      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
      "./../../serial/include",
      "./../../ddk/common/include",
      "./../../ddk/device/include",
      "./../../ddk/host/include",
      "./../../interfaces/ddk/common",
      "./../../interfaces/ddk/host",
      "./../../gadget/function/include",
      "common",
    ]
    sources = [
      "./../../sample/host/src/usbhost_ddk_test.c",
      "./common/liteos/usb_host_serial_func_test.cpp",
    ]
    public_deps = [
      "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
      "./../../../../hdf_core/adapter/uhdf/manager:hdf_core",
      "./../../../../hdf_core/adapter/uhdf/posix:hdf_posix_osal",
      "//commonlibrary/utils_lite:utils",
    ]
    defines = [ "__LITEOS_USB_HOST_DDK_TEST__" ]
  }

  moduletest("usb_host_raw_api_func_test") {
    output_extension = "bin"
    output_dir = output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "./../../sample/host/include",
      "./../../../../hdf_core/adapter/khdf/liteos/model/usb/host/include",
      "//third_party/bounds_checking_function/include",
      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
      "./../../serial/include",
      "./../../ddk/common/include",
      "./../../ddk/device/include",
      "./../../ddk/host/include",
      "./../../interfaces/ddk/common",
      "./../../interfaces/ddk/host",
      "./../../gadget/function/include",
      "common",
    ]
    sources = [
      "./../../sample/host/src/usbhost_ddk_test.c",
      "./common/liteos/usb_host_raw_api_func_test.cpp",
    ]
    public_deps = [
      "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
      "./../../../../hdf_core/adapter/uhdf/manager:hdf_core",
      "./../../../../hdf_core/adapter/uhdf/posix:hdf_posix_osal",
      "//commonlibrary/utils_lite:utils",
    ]
    defines = [ "__LITEOS_USB_HOST_DDK_TEST__" ]
  }

  moduletest("usb_host_serial_loopback") {
    output_extension = "bin"
    output_dir = output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "./../../sample/host/include",
      "./../../../../hdf_core/adapter/khdf/liteos/model/usb/host/include",
      "//third_party/bounds_checking_function/include",
      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
      "./../../serial/include",
      "./../../ddk/common/include",
      "./../../ddk/device/include",
      "./../../ddk/host/include",
      "./../../interfaces/ddk/common",
      "./../../interfaces/ddk/host",
      "./../../gadget/function/include",
      "common",
    ]
    sources = [
      "./../../sample/host/src/usbhost_ddk_test.c",
      "./common/liteos/usb_host_serial_loopback.cpp",
    ]
    public_deps = [
      "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
      "./../../../../hdf_core/adapter/uhdf/manager:hdf_core",
      "./../../../../hdf_core/adapter/uhdf/posix:hdf_posix_osal",
      "//commonlibrary/utils_lite:utils",
    ]
    defines = [ "__LITEOS_USB_HOST_DDK_TEST__" ]
  }

  moduletest("usb_device_serial_loopback") {
    output_extension = "bin"
    output_dir = output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "./../../sample/device/liteos/lib/include",
      "//third_party/bounds_checking_function/include",
      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
      "common",
    ]
    sources = [
      "./../../sample/device/liteos/lib/src/lib_acm_test.c",
      "./common/liteos/usb_device_serial_loopback.cpp",
    ]
    public_deps = [
      "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
      "./../../../../hdf_core/adapter/uhdf/manager:hdf_core",
      "./../../../../hdf_core/adapter/uhdf/posix:hdf_posix_osal",
      "//commonlibrary/utils_lite:utils",
    ]
  }

  moduletest("usb_device_serial_func_test") {
    output_extension = "bin"
    output_dir = output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "./../../sample/device/liteos/lib/include",
      "//third_party/bounds_checking_function/include",
      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
      "common",
    ]
    sources = [
      "./../../sample/device/liteos/lib/src/lib_acm_test.c",
      "./common/liteos/usb_device_serial_func_test.cpp",
    ]
    public_deps = [
      "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
      "./../../../../hdf_core/adapter/uhdf/manager:hdf_core",
      "./../../../../hdf_core/adapter/uhdf/posix:hdf_posix_osal",
      "//commonlibrary/utils_lite:utils",
    ]
  }

  group("hdf_peripheral_usb_test_module") {
    deps = [
      ":usb_device_serial_func_test",
      ":usb_device_serial_loopback",
      ":usb_host_raw_api_func_test",
      ":usb_host_serial_func_test",
      ":usb_host_serial_loopback",
    ]
  }
} else {
  module_output_path = "hdf/usb"
  ohos_moduletest("usb_device_serial_func_test") {
    module_out_path = module_output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "common",
    ]
    sources = [
      "./common/usb_device_serial_func_test.cpp",
      "./common/usb_utils.cpp",
    ]
    external_deps = [
      "c_utils:utils",
      "hdf_core:libhdf_utils",
    ]
  }

  ohos_moduletest("usb_device_net_func_test") {
    module_out_path = module_output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "common",
    ]

    sources = [
      "./common/usb_device_net_func_test.cpp",
      "./common/usb_utils.cpp",
    ]
    deps = []
  }

  ohos_moduletest("usb_device_compose_func_test") {
    module_out_path = module_output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "common",
    ]

    sources = [
      "./common/usb_device_compose_func_test.cpp",
      "./common/usb_utils.cpp",
    ]
    deps = []
  }

  ohos_moduletest("usb_device_performance_test") {
    module_out_path = module_output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "common",
    ]
    sources = [
      "./common/usb_device_performance_test.cpp",
      "./common/usb_utils.cpp",
    ]
    deps = []
    external_deps = [ "hdf_core:libhdf_utils" ]
  }

  ohos_moduletest("usb_host_serial_func_test") {
    module_out_path = module_output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "common",
    ]
    sources = [
      "./common/usb_host_serial_func_test.cpp",
      "./common/usb_utils.cpp",
    ]
    external_deps = [
      "c_utils:utils",
      "hdf_core:libhdf_utils",
    ]
  }

  ohos_moduletest("usb_host_raw_api_func_test") {
    module_out_path = module_output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "common",
    ]
    sources = [
      "./common/usb_host_raw_api_func_test.cpp",
      "./common/usb_utils.cpp",
    ]
    external_deps = [
      "c_utils:utils",
      "hdf_core:libhdf_utils",
    ]
  }

  ohos_moduletest("usb_host_net_func_test") {
    module_out_path = module_output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "common",
    ]

    sources = [
      "./common/usb_host_net_func_test.cpp",
      "./common/usb_utils.cpp",
    ]
    deps = []
  }

  ohos_moduletest("usb_host_compose_func_test") {
    module_out_path = module_output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "common",
    ]

    sources = [
      "./common/usb_host_compose_func_test.cpp",
      "./common/usb_utils.cpp",
    ]
    deps = []
  }

  ohos_moduletest("usb_host_performance_test") {
    module_out_path = module_output_path
    include_dirs = [
      "//third_party/googletest/googletest/include",
      "common",
    ]

    sources = [
      "./common/usb_host_performance_test.cpp",
      "./common/usb_utils.cpp",
    ]
    deps = []
    external_deps = [ "hdf_core:libhdf_utils" ]
  }

  group("hdf_moduletest_usb") {
    testonly = true
    deps = [
      ":usb_device_performance_test",
      ":usb_device_serial_func_test",
      ":usb_host_performance_test",
      ":usb_host_raw_api_func_test",
      ":usb_host_serial_func_test",
    ]
  }
}