# 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.

import("//base/notification/distributed_notification_service/notification.gni")
import("//build/ohos.gni")
import("//build/test.gni")

module_output_path =
    "${component_name}/distributed_notification_service/moduletest"

config("public_ans_config") {
  include_dirs = [
    "${core_path}/common/include",
    "${services_path}/ans/include",
    "${core_path}/include",
  ]
}

ohos_moduletest("ans_innerkits_module_publish_test") {
  sanitize = {
    integer_overflow = true
    ubsan = true
    boundary_sanitize = true
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  module_out_path = module_output_path
  include_dirs = [
    "include",
    "${core_path}/include",
    "${inner_api_path}",
    "${core_path}/common/include",
    "${core_path}/include",
    "${component_path}/services/ans/include",
    "${inner_api_path}",
    "${core_path}/common/include",
    "${core_path}/include",
    "${inner_api_path}",
    "${frameworks_path}/test/moduletest/mock/include",
    "${component_path}/services/ans/include/utils",
    "${services_path}/infrastructure/interfaces",
    "${services_path}/domain/settings/rdb_mgr_repo/include",
    "${services_path}/infrastructure/external_adapter/rdb/include",
    "${services_path}/infrastructure/external_adapter/rdb/include/public",
    "${services_path}/infrastructure/external_adapter/rdb/include/rdb_store_wrapper",
  ]

  sources = [
    "${test_path}/mock/mock_tokenid_kit.cpp",
    "ans_innerkits_module_publish_test.cpp",
    "mock/mock_accesstoken_kit.cpp",
    "mock/mock_ans_rdb_mgr_builder.cpp",
    "mock/mock_bundle_manager.cpp",
    "mock/mock_bundle_manager_helper.cpp",
    "mock/mock_ipc.cpp",
    "mock/remote_native_token.cpp",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/ans:ans_service_sources",
  ]

  defines = []
  if (distributed_notification_service_feature_original_distributed) {
    defines += [ "ANS_FEATURE_ORIGINAL_DISTRIBUTED" ]
    deps += [ "${services_path}/distributed:libans_distributed" ]
  }

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_base:zuri",
    "ability_runtime:ability_context_native",
    "ability_runtime:abilitykit_native",
    "ability_runtime:app_context",
    "ability_runtime:appkit_native",
    "ability_runtime:wantagent_innerkits",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
    "bluetooth:btframework",
    "cJSON:cjson",
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "c_utils:utils",
    "common_event_service:cesfwk_innerkits",
    "eventhandler:libeventhandler",
    "ffrt:libffrt",
    "googletest:gtest_main",
    "hilog:libhilog",
    "image_framework:image_native",
    "ipc:ipc_core",
    "json:nlohmann_json_static",
    "kv_store:distributeddata_inner",
    "relational_store:native_rdb",
    "safwk:system_ability_fwk",
    "samgr:samgr_proxy",
    "selinux_adapter:librestorecon",
    "time_service:time_client",
  ]

  subsystem_name = "${subsystem_name}"
  part_name = "${component_name}"
}

ohos_moduletest("ans_innerkits_module_slot_test") {
  module_out_path = module_output_path
  include_dirs = [
    "include",
    "${core_path}/include",
    "${inner_api_path}",
    "${frameworks_path}/ans/core/common/include",
    "${frameworks_path}/ans/core/include",
    "${component_path}/services/ans/include",
    "${inner_api_path}",
    "${core_path}/common/include",
    "${core_path}/include",
    "${inner_api_path}",
    "${frameworks_path}/test/moduletest/mock/include",
    "${component_path}/services/ans/include/utils",
    "${services_path}/infrastructure/interfaces",
    "${services_path}/domain/settings/rdb_mgr_repo/include",
    "${services_path}/infrastructure/external_adapter/rdb/include",
    "${services_path}/infrastructure/external_adapter/rdb/include/public",
    "${services_path}/infrastructure/external_adapter/rdb/include/rdb_store_wrapper",
  ]

  sources = [
    "${test_path}/mock/mock_tokenid_kit.cpp",
    "ans_innerkits_module_slot_test.cpp",
    "mock/distributed_kv_data_manager.cpp",
    "mock/mock_accesstoken_kit.cpp",
    "mock/mock_ans_rdb_mgr_builder.cpp",
    "mock/mock_bundle_manager.cpp",
    "mock/mock_bundle_manager_helper.cpp",
    "mock/mock_ipc.cpp",
    "mock/mock_single_kv_store.cpp",
    "mock/remote_native_token.cpp",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/ans:ans_service_sources",
  ]

  defines = []
  if (distributed_notification_service_feature_original_distributed) {
    defines += [ "ANS_FEATURE_ORIGINAL_DISTRIBUTED" ]
    deps += [ "${services_path}/distributed:libans_distributed" ]
  }

  external_deps = [
    "ability_base:configuration",
    "ability_base:want",
    "ability_base:zuri",
    "ability_runtime:wantagent_innerkits",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
    "bluetooth:btframework",
    "cJSON:cjson",
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "c_utils:utils",
    "common_event_service:cesfwk_innerkits",
    "eventhandler:libeventhandler",
    "ffrt:libffrt",
    "googletest:gtest_main",
    "hilog:libhilog",
    "image_framework:image_native",
    "ipc:ipc_core",
    "json:nlohmann_json_static",
    "kv_store:distributeddata_inner",
    "relational_store:native_rdb",
    "safwk:system_ability_fwk",
    "samgr:samgr_proxy",
    "selinux_adapter:librestorecon",
    "time_service:time_client",
  ]

  subsystem_name = "${subsystem_name}"
  part_name = "${component_name}"
}

ohos_moduletest("ans_innerkits_module_setting_test") {
  sanitize = {
    integer_overflow = true
    ubsan = true
    boundary_sanitize = true
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  module_out_path = module_output_path
  include_dirs = [
    "include",
    "${core_path}/include",
    "${inner_api_path}",
    "${frameworks_path}/ans/core/common/include",
    "${frameworks_path}/ans/core/include",
    "${component_path}/services/ans/include",
    "${inner_api_path}",
    "${core_path}/common/include",
    "${core_path}/include",
    "${inner_api_path}",
    "${frameworks_path}/test/moduletest/mock/include",
    "${component_path}/services/ans/include/utils",
    "${services_path}/infrastructure/interfaces",
    "${services_path}/domain/settings/rdb_mgr_repo/include",
    "${services_path}/infrastructure/external_adapter/rdb/include",
    "${services_path}/infrastructure/external_adapter/rdb/include/public",
    "${services_path}/infrastructure/external_adapter/rdb/include/rdb_store_wrapper",
  ]

  sources = [
    "ans_innerkits_module_setting_test.cpp",
    "mock/distributed_kv_data_manager.cpp",
    "mock/mock_bundle_manager_helper.cpp",
    "mock/mock_ipc.cpp",
    "mock/mock_single_kv_store.cpp",
    "mock/remote_native_token.cpp",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/ans:ans_service_sources",
  ]

  defines = []
  if (distributed_notification_service_feature_original_distributed) {
    defines += [ "ANS_FEATURE_ORIGINAL_DISTRIBUTED" ]
    deps += [ "${services_path}/distributed:libans_distributed" ]
  }

  external_deps = [
    "ability_base:configuration",
    "ability_base:want",
    "ability_base:zuri",
    "ability_runtime:wantagent_innerkits",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
    "bluetooth:btframework",
    "cJSON:cjson",
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "c_utils:utils",
    "common_event_service:cesfwk_innerkits",
    "eventhandler:libeventhandler",
    "ffrt:libffrt",
    "googletest:gtest_main",
    "hilog:libhilog",
    "image_framework:image_native",
    "ipc:ipc_core",
    "json:nlohmann_json_static",
    "kv_store:distributeddata_inner",
    "relational_store:native_rdb",
    "safwk:system_ability_fwk",
    "samgr:samgr_proxy",
    "selinux_adapter:librestorecon",
    "time_service:time_client",
  ]

  subsystem_name = "${subsystem_name}"
  part_name = "${component_name}"
}

group("moduletest") {
  testonly = true
  deps = []

  deps += [
    ":ans_innerkits_module_publish_test",
    ":ans_innerkits_module_setting_test",
    ":ans_innerkits_module_slot_test",
  ]
}