# 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")

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

  if (distributed_notification_supported) {
    deps += [
      ":ans_distributed_unit_test",
      ":distributed_database_branch_test",
      ":distributed_database_callback_test",
      ":distributed_device_callback_test",
      ":distributed_flow_control_test",
      ":distributed_preferences_branch_test",
      ":distributed_preferences_database_test",
      ":distributed_screen_status_manager_branch_test",
    ]
  }
}

ohos_unittest("ans_distributed_unit_test") {
  module_out_path = "${component_name}/unittest"
  include_dirs = [
    "/${services_path}/distributed/include",
    "${ffrt_path}/interfaces/kits",
  ]

  sources = [
    "${services_path}/distributed/src/distributed_database.cpp",
    "${services_path}/distributed/src/distributed_database_callback.cpp",
    "${services_path}/distributed/src/distributed_device_callback.cpp",
    "${services_path}/distributed/src/distributed_flow_control.cpp",
    "${services_path}/distributed/src/distributed_notification_manager.cpp",
    "${services_path}/distributed/src/distributed_preferences.cpp",
    "${services_path}/distributed/src/distributed_preferences_database.cpp",
    "${services_path}/distributed/src/distributed_preferences_info.cpp",
    "${services_path}/distributed/src/distributed_screen_status_manager.cpp",
    "${services_path}/distributed/test/unittest/distributed_database_test.cpp",
    "${services_path}/distributed/test/unittest/distributed_notification_manager_test.cpp",
    "${services_path}/distributed/test/unittest/distributed_preferences_test.cpp",
    "${services_path}/distributed/test/unittest/distributed_screen_status_manager_test.cpp",
    "${services_path}/distributed/test/unittest/mock/mock_blob.cpp",
    "${services_path}/distributed/test/unittest/mock/mock_change_notification.cpp",
    "${services_path}/distributed/test/unittest/mock/mock_device_manager_impl.cpp",
    "${services_path}/distributed/test/unittest/mock/mock_event_handler.cpp",
    "${services_path}/distributed/test/unittest/mock/mock_single_kv_store.cpp",
  ]

  configs = [
    "${services_path}/distributed/:ans_distributed_config",
    "${frameworks_module_ans_path}:ans_innerkits_public_config",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "//third_party/googletest:gtest_main",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_base:zuri",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "device_manager:devicemanagersdk",
    "eventhandler:libeventhandler",
    "ffrt:libffrt",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "hitrace:libhitracechain",
    "image_framework:image_native",
    "ipc:ipc_core",
    "kv_store:distributeddata_inner",
  ]

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

ohos_unittest("distributed_preferences_database_test") {
  module_out_path = "${component_name}/unittest"
  include_dirs = [
    "/${services_path}/distributed/include",
    "${services_path}/distributed/test/unittest/mock",
  ]

  sources = [
    "distributed_preferences_database_test/distributed_preferences_database_test.cpp",
    "distributed_preferences_database_test/mock_distributed_flow_control.cpp",
    "distributed_preferences_database_test/mock_distributed_kv_data_manager.cpp",
    "distributed_preferences_database_test/mock_single_kv_store.cpp",
  ]

  configs = [
    "${services_path}/distributed/:ans_distributed_config",
    "${frameworks_module_ans_path}:ans_innerkits_public_config",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/distributed:libans_distributed",
    "//third_party/googletest:gtest_main",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_base:zuri",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "device_manager:devicemanagersdk",
    "eventhandler:libeventhandler",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "hitrace:libhitracechain",
    "image_framework:image_native",
    "ipc:ipc_core",
    "kv_store:distributeddata_inner",
  ]

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

ohos_unittest("distributed_screen_status_manager_branch_test") {
  module_out_path = "${component_name}/unittest"
  include_dirs = [
    "/${services_path}/distributed/include",
    "${services_path}/distributed/test/unittest/mock",
  ]

  sources = [
    "distributed_database_branch_test/mock_device_manager_impl.cpp",
    "distributed_screen_status_manager_branch_test/distributed_screen_status_manager_branch_test.cpp",
    "distributed_screen_status_manager_branch_test/mock_distributed_flow_control.cpp",
    "distributed_screen_status_manager_branch_test/mock_distributed_kv_data_manager.cpp",
    "distributed_screen_status_manager_branch_test/mock_single_kv_store.cpp",
  ]

  configs = [
    "${services_path}/distributed/:ans_distributed_config",
    "${frameworks_module_ans_path}:ans_innerkits_public_config",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/distributed:libans_distributed",
    "//third_party/googletest:gtest_main",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_base:zuri",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "device_manager:devicemanagersdk",
    "eventhandler:libeventhandler",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "hitrace:libhitracechain",
    "image_framework:image_native",
    "ipc:ipc_core",
    "kv_store:distributeddata_inner",
  ]

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

ohos_unittest("distributed_database_branch_test") {
  module_out_path = "${component_name}/unittest"
  include_dirs = [
    "/${services_path}/distributed/include",
    "${services_path}/distributed/test/unittest/mock",
  ]

  sources = [
    "distributed_database_branch_test/distributed_database_branch_test.cpp",
    "distributed_database_branch_test/mock_device_manager_impl.cpp",
    "distributed_database_branch_test/mock_distributed_flow_control.cpp",
    "distributed_database_branch_test/mock_distributed_kv_data_manager.cpp",
    "distributed_database_branch_test/mock_single_kv_store.cpp",
  ]

  configs = [
    "${services_path}/distributed/:ans_distributed_config",
    "${frameworks_module_ans_path}:ans_innerkits_public_config",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/distributed:libans_distributed",
    "//third_party/googletest:gtest_main",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_base:zuri",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "device_manager:devicemanagersdk",
    "eventhandler:libeventhandler",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "hitrace:libhitracechain",
    "image_framework:image_native",
    "ipc:ipc_core",
    "kv_store:distributeddata_inner",
  ]

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

ohos_unittest("distributed_preferences_branch_test") {
  module_out_path = "${component_name}/unittest"
  include_dirs = [ "/${services_path}/distributed/include" ]

  sources = [
    "distributed_preferences_branch_test/distributed_preferences_branch_test.cpp",
    "distributed_preferences_branch_test/mock_distributed_preferences_database.cpp",
  ]

  configs = [
    "${services_path}/distributed/:ans_distributed_config",
    "${frameworks_module_ans_path}:ans_innerkits_public_config",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/distributed:libans_distributed",
    "//third_party/googletest:gtest_main",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_base:zuri",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "device_manager:devicemanagersdk",
    "eventhandler:libeventhandler",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "hitrace:libhitracechain",
    "image_framework:image_native",
    "ipc:ipc_core",
    "kv_store:distributeddata_inner",
  ]

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

ohos_unittest("distributed_device_callback_test") {
  module_out_path = "${component_name}/unittest"
  include_dirs = [ "/${services_path}/distributed/include" ]

  sources = [ "distributed_device_callback_test.cpp" ]

  configs = [
    "${services_path}/distributed/:ans_distributed_config",
    "${frameworks_module_ans_path}:ans_innerkits_public_config",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/distributed:libans_distributed",
    "//third_party/googletest:gtest_main",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_base:zuri",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "device_manager:devicemanagersdk",
    "eventhandler:libeventhandler",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "hitrace:libhitracechain",
    "image_framework:image_native",
    "ipc:ipc_core",
    "kv_store:distributeddata_inner",
  ]

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

ohos_unittest("distributed_database_callback_test") {
  module_out_path = "${component_name}/unittest"
  include_dirs = [ "/${services_path}/distributed/include" ]

  sources = [ "distributed_database_callback_test.cpp" ]

  configs = [
    "${services_path}/distributed/:ans_distributed_config",
    "${frameworks_module_ans_path}:ans_innerkits_public_config",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/distributed:libans_distributed",
    "//third_party/googletest:gtest_main",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_base:zuri",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "eventhandler:libeventhandler",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "hitrace:libhitracechain",
    "image_framework:image_native",
    "ipc:ipc_core",
    "kv_store:distributeddata_inner",
  ]

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

ohos_unittest("distributed_flow_control_test") {
  module_out_path = "${component_name}/unittest"
  include_dirs = [ "/${services_path}/distributed/include" ]

  sources = [ "distributed_flow_control_test.cpp" ]

  configs = [
    "${services_path}/distributed/:ans_distributed_config",
    "${frameworks_module_ans_path}:ans_innerkits_public_config",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/distributed:libans_distributed",
    "//third_party/googletest:gtest_main",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_base:zuri",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "eventhandler:libeventhandler",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "hitrace:libhitracechain",
    "image_framework:image_native",
    "ipc:ipc_core",
    "kv_store:distributeddata_inner",
  ]

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

ohos_unittest("distributed_notification_manager_branch_test") {
  module_out_path = "${component_name}/unittest"
  include_dirs = [
    "/${services_path}/distributed/include",
    "${ffrt_path}/interfaces/kits",
  ]

  sources = [
    "distributed_notification_manager_branch_test/distributed_notification_manager_branch_test.cpp",
    "distributed_notification_manager_branch_test/mock_distributed_database.cpp",
  ]

  configs = [
    "${services_path}/distributed/:ans_distributed_config",
    "${frameworks_module_ans_path}:ans_innerkits_public_config",
  ]

  deps = [
    "${frameworks_module_ans_path}:ans_innerkits",
    "${services_path}/distributed:libans_distributed",
    "//third_party/googletest:gtest_main",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_base:zuri",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "device_manager:devicemanagersdk",
    "eventhandler:libeventhandler",
    "ffrt:libffrt",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "hitrace:libhitracechain",
    "image_framework:image_native",
    "ipc:ipc_core",
    "kv_store:distributeddata_inner",
  ]

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