# Copyright (c) 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.

#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/test.gni")
import("../../../device_usage_statistics.gni")

##############################fuzztest##########################################
module_output_path = "device_usage_statistics/device_usage_statistics"

config("module_private_config") {
  include_dirs = [
    "${usage_statistics_path}/interfaces/innerkits/include",
    "${usage_statistics_path}/services/common/include",
    "${usage_statistics_path}/services/packageusage/include",
    "${usage_statistics_path}/services/packagegroup/include",
    "${usage_statistics_path}/interfaces/kits/bundlestats/napi/include",
    "${usage_statistics_path}/utils/include",
    "../common",
  ]
}

ohos_fuzztest("BundleActiveObserverFuzzTest") {
  module_out_path = module_output_path
  fuzz_config_file =
      "${usage_statistics_path}/test/fuzztest/bundleactiveobserver_fuzzer"
  configs = [ ":module_private_config" ]
  cflags = [
    "-g",
    "-O0",
    "-Wno-unused-variable",
    "-fno-omit-frame-pointer",
    "-Dprivate=public",
    "-Dprotected=public",
  ]
  sources = [
    "../common/fuzztest_helper.cpp",
    "bundleactiveobserver_fuzzer.cpp",
  ]

  public_deps = [
    "${usage_statistics_path}:usagestatservice_static",
    "${usage_statistics_path}:usagestatsinner",
  ]
  external_deps = [
    "ability_base:want",
    "ability_runtime:app_manager",
    "ability_runtime:wantagent_innerkits",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
    "access_token:libtokenid_sdk",
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "c_utils:utils",
    "common_event_service:cesfwk_innerkits",
    "eventhandler:libeventhandler",
    "ffrt:libffrt",
    "hilog:libhilog",
    "init:libbegetutil",
    "ipc:ipc_single",
    "relational_store:native_rdb",
    "safwk:system_ability_fwk",
    "samgr:samgr_proxy",
    "time_service:time_client",
  ]

  defines = []

  if (bgtaskmgr_enable) {
    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
    defines += [ "BGTASKMGR_ENABLE" ]
  }
  if (os_account_part_enabled) {
    cflags_cc = [ "-DOS_ACCOUNT_PART_ENABLED" ]
    external_deps += [ "os_account:os_account_innerkits" ]
  }
  if (device_usage_statistics_with_powermgr_power_manager_enable) {
    defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ]
    external_deps += [ "power_manager:powermgr_client" ]
  }
}

###############################################################################
group("fuzztest") {
  testonly = true
  deps = []
  deps += [
    # deps file
    ":BundleActiveObserverFuzzTest",
  ]
}
###############################################################################