# Copyright (c) 2021 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.

import("//base/update/sys_installer/sys_installer_default_cfg.gni")
import("//build/test.gni")

sys_installer_path = rebase_path("${sys_installer_absolutely_path}", ".")
module_output_path = "sys_installer/sys_installer_test"

config("utest_config") {
  visibility = [ ":*" ]

  cflags = [
    "-fprofile-arcs",
    "-Wno-implicit-fallthrough",
    "-Wno-unused-function",
  ]
  cflags_cc = [ "-Wno-implicit-fallthrough" ]

  ldflags = [ "--coverage" ]
}

ohos_unittest("sys_installer_unittest") {
  testonly = true
  module_out_path = module_output_path
  sources = [
    "${sys_installer_path}/interfaces/innerkits/ipc_client/src/sys_installer_kits_impl.cpp",
    "ipc_test/sys_installer_ipc_test.cpp",
  ]

  include_dirs = [
    "${sys_installer_path}/interfaces/inner_api/include",
    "${sys_installer_path}/interfaces/innerkits/ipc_client/include",
    "${sys_installer_path}/test/unitest",
  ]
  deps = [
    "${sys_installer_path}/interfaces/innerkits/ipc_client:libsysinstallerkits",
  ]

  deps += [ "${sys_installer_path}/test/unittest:sys_installer_client_test" ]
  external_deps = [
    "bounds_checking_function:libsec_static",
    "googletest:gmock_main",
    "googletest:gtest_main",
    "updater:libupdaterlog",
  ]

  cflags_cc = [ "-fexceptions" ]

  defines = [
    "UPDATER_UT",
    "BUILD_OHOS",
    "HDC_DEBUG",
    "HARMONY_PROJECT",
  ]

  public_configs = [ ":utest_config" ]
  install_enable = true
  part_name = "sys_installer"
}

ohos_executable("sys_installer_client_test") {
  sources = [ "${sys_installer_path}/interfaces/innerkits/ipc_client/src/sys_installer_client.cpp" ]

  include_dirs = [
    "${sys_installer_path}/interfaces/innerkits/ipc_client/include",
    "${sys_installer_path}/interfaces/inner_api/include",
  ]

  deps = [
    "${sys_installer_path}/interfaces/innerkits/ipc_client:libsysinstallerkits",
  ]

  external_deps = [
    "bounds_checking_function:libsec_static",
    "c_utils:utils",
    "init:libbegetutil",
    "ipc:ipc_core",
    "safwk:system_ability_fwk",
    "samgr:samgr_proxy",
  ]
  install_enable = true
  part_name = "sys_installer"
}