# Copyright (c) 2023-2024 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("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")

module_output_path = "ability_runtime/ability_runtime/child_process_manager"

ohos_unittest("child_process_manager_test") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  module_out_path = module_output_path

  configs = [ "${ability_runtime_services_path}/common:common_config" ]

  if (target_cpu == "arm") {
    cflags = [ "-DBINDER_IPC_32BIT" ]
  }

  include_dirs = [
    "include",
    "${ability_runtime_test_path}/mock/services_appmgr_test/include",
    "${ability_runtime_test_path}/mock/common/include",
  ]

  sources = [
    "${ability_runtime_test_path}/mock/services_appmgr_test/src/sys_mgr_client_mock.cpp",
    "child_process_manager_test.cpp",
    "child_process_test.cpp",
    "js_child_process_test.cpp",
    "mock_bundle_manager.cpp",
    "native_args_child_process_test.cpp",
  ]

  deps = [
    "${ability_runtime_innerkits_path}/app_manager:app_manager",
    "${ability_runtime_innerkits_path}/runtime:runtime",
    "${ability_runtime_native_path}/ability/native:ability_business_error",
    "${ability_runtime_native_path}/ability/native:ability_observer_ipc",
    "${ability_runtime_path}/interfaces/inner_api/child_process_manager:child_process_manager",
    "${ability_runtime_services_path}/common:app_util_static",
  ]

  external_deps = [
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "c_utils:utils",
    "googletest:gmock_main",
    "googletest:gtest_main",
    "hilog:libhilog",
    "init:libbegetutil",
    "ipc:ipc_capi",
    "ipc:ipc_core",
    "napi:ace_napi",
    "samgr:samgr_proxy",
  ]
}

group("unittest") {
  testonly = true
  deps = [ ":child_process_manager_test" ]
}