# Copyright (C) 2022 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/location/location/config.gni")
import("//build/test.gni")

module_output_path = "location/location"
if (location_feature_with_geocode) {
  ohos_unittest("GeocodeServiceAbilityTest") {
    module_out_path = module_output_path
    sources = [ "$LOCATION_ROOT_DIR/test/location_geocode/source/geo_convert_service_test.cpp" ]

    include_dirs = [
      "$LOCATION_ROOT_DIR/interfaces/inner_api/include",
      "$LOCATION_ROOT_DIR/test/location_geocode/include",
      "$LOCATION_ROOT_DIR/test/location_geocode/mock/include",
      "$LOCATION_GEOCONVERT_ROOT/include",
      "$LOCATION_LOCATOR_ROOT/include",
      "$LOCATION_ROOT_DIR/test/mock/include",
    ]

    deps = [
      "$LOCATION_GEOCONVERT_ROOT:lbsservice_geocode_static",
      "$LOCATION_LOCATOR_ROOT:lbsservice_locator_static",
      "$LOCATION_ROOT_DIR/frameworks/js/napi:geolocation_static",
      "$LOCATION_ROOT_DIR/frameworks/location_common/common:lbsservice_common_static",
    ]

    sanitize = {
      cfi = true
      cfi_cross_dso = true
      debug = false
      blocklist = "./../../cfi_blocklist.txt"
    }
    branch_protector_ret = "pac_ret"

    external_deps = [
      "ability_runtime:ability_connect_callback_stub",
      "access_token:libaccesstoken_sdk",
      "access_token:libnativetoken",
      "access_token:libtoken_setproc",
      "c_utils:utils",
      "common_event_service:cesfwk_innerkits",
      "ffrt:libffrt",
      "googletest:gmock_main",
      "googletest:gtest_main",
      "hilog:libhilog",
      "hisysevent:libhisysevent",
      "init:libbegetutil",
      "ipc:ipc_core",
      "napi:ace_napi",
      "safwk:system_ability_fwk",
      "samgr:samgr_proxy",
      "selinux_adapter:librestorecon",
    ]

    defines = []
    if (location_feature_with_geocode) {
      defines += [ "FEATURE_GEOCODE_SUPPORT" ]
    }

    module_out_path = module_output_path
  }
} else {
  ohos_unittest("GeocodeServiceAbilityTest") {
    module_out_path = module_output_path
  }
}

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