# Copyright (c) 2025 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/config/features.gni")
import("//build/test.gni")
import("../../../config.gni")

ohos_fuzztest("RendererInServerFuzzTest") {
  module_out_path = "audio_framework/audio_framework_route"
  fuzz_config_file = "../rendererinserver_fuzzer"

  include_dirs = [
    "../../../services/audio_service/common/include",
    "../../../services/audio_service/server/include",
    "../../../services/audio_service/client/include",
    "../../../services/audio_policy/client/include",
    "../../../frameworks/native/audioutils/include",
    "../../../interfaces/kits/c/audio_suite",
    "../../../interfaces/kits/c/common",
    "../../../services/audio_engine/manager/include",
    "../../../services/audio_engine/buffer",
  ]

  cflags = [
    "-g",
    "-O0",
    "-Wno-unused-variable",
    "-fno-omit-frame-pointer",
    "-fno-access-control",
  ]

  sources = [
    "renderer_in_server_fuzzer.cpp",
    ]

  configs = [ "../../../services/audio_service:audio_service_config" ]

  deps = [
    "../../../frameworks/native/audioutils:audio_utils",
    "../../../services/audio_service:audio_common",
    "../../../services/audio_service:audio_service",
    "../../../services/audio_service:audio_process_service_static",
  ]

  if (audio_framework_feature_offline_effect) {
    deps += [
      "../../../frameworks/native/offlineaudioeffect:offline_audio_effect_service",
    ]
  }

  external_deps = [
    "ability_base:want",
    "access_token:libaccesstoken_sdk",
    "bounds_checking_function:libsec_shared",
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "c_utils:utils",
    "eventhandler:libeventhandler",
    "hdf_core:libhdi",
    "hdf_core:libpub_utils",
    "hilog:libhilog",
    "hisysevent:libhisysevent",
    "init:libbegetutil",
    "ipc:ipc_single",
    "media_foundation:media_monitor_client",
    "media_foundation:media_monitor_common",
    "safwk:system_ability_fwk",
    "samgr:samgr_proxy",
  ]

  defines = []
  if (use_libfuzzer || use_clang_coverage) {
    defines += [ "TEST_COVERAGE" ]
  }
}

group("fuzztest") {
  testonly = true
  deps = [ ":RendererInServerFuzzTest" ]
}