# 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("//build/test.gni")
SMS_MMS_SOURCE_DIR = "../../"
import("$SMS_MMS_SOURCE_DIR/smsmms.gni")

declare_args() {
unittest_deps = [
  "$SMS_MMS_SOURCE_DIR/test:tel_sms_mms_test_base"
]

unittest_external_deps = [
    "ability_base:want",
    "ability_base:zuri",
    "ability_runtime:ability_manager",
    "ability_runtime:data_ability_helper",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken_shared",
    "access_token:libtoken_setproc",
    "c_utils:utils",
    "common_event_service:cesfwk_innerkits",
    "core_service:libtel_common",
    "core_service:tel_core_service_api",
    "core_service:ffrt_mocked",
    "curl:curl_shared",
    "data_share:datashare_common",
    "data_share:datashare_consumer",
    "eventhandler:libeventhandler",
    "core_service:ffrt_mocked",
    "googletest:gmock_main",
    "hilog:libhilog",
    "hisysevent:libhisysevent",
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "init:libbegetutil",
    "ipc:ipc_single",
    "libphonenumber:phonenumber_standard",
    "netmanager_base:net_conn_manager_if",
    "netstack:http_client",
    "os_account:os_account_innerkits",
    "protobuf:protobuf",
    "safwk:system_ability_fwk",
    "samgr:samgr_proxy",
    "telephony_data:tel_telephony_data",
    "power_manager:powermgr_client"
]
  test_sources = []
  unittest_targets = []
}
config("unittest_config") {
  include_dirs = [
    "$SMS_MMS_SOURCE_DIR/services/include",
    "$SMS_MMS_SOURCE_DIR/interfaces/innerkits",
    "$SMS_MMS_SOURCE_DIR/interfaces/innerkits/satellite",
    "$SMS_MMS_SOURCE_DIR/interfaces/kits/native",
    "$SMS_MMS_SOURCE_DIR/frameworks/native/sms/include",
    "$SMS_MMS_SOURCE_DIR/utils",
    "$SMS_MMS_SOURCE_DIR/services/mms/include",
    "$SMS_MMS_SOURCE_DIR/services/sms/include",
    "$SMS_MMS_SOURCE_DIR/test/gtest",
  ]
}
test_sources += [
    "cb_gtest.cpp",
    "cdma_sms_gtest.cpp",
    "mms_gtest.cpp",
    "sms_ims_service_interaction_gtest.cpp",
    "sms_mms_common_test.cpp",
    "sms_mms_receive_gtest.cpp",
    "sms_service_proxy_gtest.cpp",
    "zero_branch_cb_test.cpp",
    "zero_branch_cdma_sms_test.cpp",
    "zero_branch_mms_test.cpp",
    "zero_branch_sms_part_test.cpp",
    "zero_branch_sms_part1_test.cpp",
    "zero_branch_sms_test.cpp",
    "zero_branch_utils_test.cpp",
    "mms_cdma_gtest.cpp",
    "mms_receiver_mgr_gtest.cpp",
    "sms_gsm_gtest.cpp",
    "sms_gtest.cpp",
    "sms_services_mms_gtest.cpp",
    "sms_utils_gtest.cpp"
]

if (sms_mms_satellite) {
  test_sources += [
    "sms_satellite_gtest.cpp",
  ]
}

template("unittest_suite") {
  ohos_unittest(target_name) {
    subsystem_name = "telephony"
    part_name = "sms_mms"
    test_module = "tel_sms_mms_gtest"
    module_out_path = part_name + "/" + part_name + "/" + test_module
    sources = invoker.sources
    deps = unittest_deps
    configs = [ ":unittest_config" ]
    external_deps = unittest_external_deps
    defines = global_defines
  }
}

foreach(source, test_sources) {
  name = get_path_info(source, "name")
  if (source == "zero_branch_sms_part_test.cpp") {
    target_name = "tel_sms_mms_gtest"
  } else {
    target_name = "unittest_${name}"
  }
  
  unittest_suite(target_name) {
    sources = [ source ]
  }
  unittest_targets += [ ":${target_name}" ]
}

group("unittest") {
  testonly = true
  deps = unittest_targets
}