1# Copyright (c) 2023 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/test.gni") 15import("//foundation/multimedia/av_codec/config.gni") 16 17module_output_path = "av_codec/unittest" 18 19av_codec_unittest_include_dirs = [ 20 "$av_codec_root_dir/interfaces/inner_api/native", 21 "$av_codec_root_dir/interfaces/interfaces/inner_api/native", 22] 23 24av_codec_unittest_cflags = [ 25 "-std=c++17", 26 "-fno-rtti", 27 "-fno-exceptions", 28 "-Wall", 29 "-fno-common", 30 "-fstack-protector-strong", 31 "-Wshadow", 32 "-FPIC", 33 "-FS", 34 "-O2", 35 "-D_FORTIFY_SOURCE=2", 36 "-fvisibility=hidden", 37 "-Wformat=2", 38 "-Wdate-time", 39 "-Werror", 40 "-Wextra", 41 "-Wimplicit-fallthrough", 42 "-Wsign-compare", 43 "-Wunused-parameter", 44] 45 46################################################################################################################## 47ohos_unittest("av_audio_capi_unit_test") { 48 sanitize = av_codec_test_sanitize 49 module_out_path = module_output_path 50 include_dirs = av_codec_unittest_include_dirs 51 include_dirs += [ 52 "./", 53 "$av_codec_root_dir/interfaces/kits/c", 54 "$av_codec_root_dir/services/engine/common/include", 55 "$av_codec_root_dir/services/engine/base/include", 56 "$av_codec_root_dir/services/utils/include", 57 "$av_codec_root_dir/services/engine/codec/include/audio", 58 "$av_codec_root_dir/services/engine/factory", 59 ] 60 61 cflags = av_codec_unittest_cflags 62 63 cflags_cc = cflags 64 65 public_configs = [] 66 67 if (av_codec_support_test) { 68 sources = [ "./audio_decoder_capi_unit_test.cpp" ] 69 } 70 71 deps = [ 72 "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client", 73 "$av_codec_root_dir/interfaces/kits/c:capi_packages", 74 "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec", 75 "$av_codec_root_dir/services/services:av_codec_service", 76 "$av_codec_root_dir/services/utils:av_codec_service_utils", 77 ] 78 79 external_deps = [ 80 "ffmpeg:libohosffmpeg", 81 "graphic_surface:surface", 82 "media_foundation:native_media_core", 83 ] 84 85 if (target_cpu == "arm64") { 86 av_codec_path = "\"/system/lib64\"" 87 } else { 88 av_codec_path = "\"/system/lib\"" 89 } 90 defines = [ "AV_CODEC_PATH=${av_codec_path}" ] 91 92 resource_config_file = 93 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 94} 95 96################################################################################################################## 97ohos_unittest("av_audio_codecbase_unit_test") { 98 sanitize = av_codec_test_sanitize 99 module_out_path = module_output_path 100 include_dirs = av_codec_unittest_include_dirs 101 include_dirs += [ 102 "./", 103 "$av_codec_root_dir/interfaces/kits/c", 104 "$av_codec_root_dir/services/engine/common/include", 105 "$av_codec_root_dir/services/engine/base/include", 106 "$av_codec_root_dir/services/utils/include", 107 "$av_codec_root_dir/services/engine/codec/include/audio", 108 "$av_codec_root_dir/services/engine/factory", 109 ] 110 111 cflags = av_codec_unittest_cflags 112 113 cflags_cc = cflags 114 115 public_configs = [] 116 117 if (av_codec_support_test) { 118 sources = [ "./audio_decoder_codecbase_unit_test.cpp" ] 119 } 120 121 deps = [ 122 "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client", 123 "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec", 124 "$av_codec_root_dir/services/utils:av_codec_service_utils", 125 ] 126 127 external_deps = [ 128 "ffmpeg:libohosffmpeg", 129 "graphic_surface:surface", 130 "hilog:libhilog", 131 ] 132 133 if (target_cpu == "arm64") { 134 av_codec_path = "\"/system/lib64\"" 135 } else { 136 av_codec_path = "\"/system/lib\"" 137 } 138 defines = [ "AV_CODEC_PATH=${av_codec_path}" ] 139 140 resource_config_file = 141 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 142} 143 144################################################################################################################## 145ohos_unittest("av_audio_decode_ability_unit_test") { 146 sanitize = av_codec_test_sanitize 147 module_out_path = module_output_path 148 include_dirs = av_codec_unittest_include_dirs 149 include_dirs += [ 150 "./", 151 "$av_codec_root_dir/interfaces/kits/c", 152 "$av_codec_root_dir/services/engine/common/include", 153 "$av_codec_root_dir/services/engine/base/include", 154 "$av_codec_root_dir/services/utils/include", 155 "$av_codec_root_dir/services/engine/codec/include/audio", 156 "$av_codec_root_dir/services/engine/factory", 157 ] 158 159 cflags = av_codec_unittest_cflags 160 161 cflags_cc = cflags 162 163 public_configs = [] 164 165 if (av_codec_support_test) { 166 sources = [ "./audio_decoder_ability_unit_test.cpp" ] 167 } 168 169 deps = [ 170 "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client", 171 "$av_codec_root_dir/interfaces/kits/c:capi_packages", 172 "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec", 173 "$av_codec_root_dir/services/services:av_codec_service", 174 "$av_codec_root_dir/services/utils:av_codec_service_utils", 175 ] 176 177 external_deps = [ 178 "ffmpeg:libohosffmpeg", 179 "graphic_surface:surface", 180 "media_foundation:native_media_core", 181 ] 182 183 if (target_cpu == "arm64") { 184 av_codec_path = "\"/system/lib64\"" 185 } else { 186 av_codec_path = "\"/system/lib\"" 187 } 188 defines = [ "AV_CODEC_PATH=${av_codec_path}" ] 189 190 resource_config_file = 191 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 192} 193 194################################################################################################################## 195ohos_unittest("av_audio_inner_unit_test") { 196 sanitize = av_codec_test_sanitize 197 module_out_path = module_output_path 198 include_dirs = av_codec_unittest_include_dirs 199 include_dirs += [ 200 "./", 201 "$av_codec_root_dir/interfaces/kits/c", 202 "$av_codec_root_dir/services/engine/common/include", 203 "$av_codec_root_dir/services/engine/base/include", 204 "$av_codec_root_dir/services/utils/include", 205 "$av_codec_root_dir/services/engine/codec/include/audio", 206 "$av_codec_root_dir/services/engine/factory", 207 ] 208 209 cflags = av_codec_unittest_cflags 210 211 cflags_cc = cflags 212 213 public_configs = [] 214 215 if (av_codec_support_test) { 216 sources = [ "./audio_decoder_inner_unit_test.cpp" ] 217 } 218 219 deps = [ 220 "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client", 221 "$av_codec_root_dir/interfaces/kits/c:capi_packages", 222 "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec", 223 "$av_codec_root_dir/services/services:av_codec_service", 224 "$av_codec_root_dir/services/utils:av_codec_service_utils", 225 ] 226 227 external_deps = [ 228 "ffmpeg:libohosffmpeg", 229 "graphic_surface:surface", 230 ] 231 232 if (target_cpu == "arm64") { 233 av_codec_path = "\"/system/lib64\"" 234 } else { 235 av_codec_path = "\"/system/lib\"" 236 } 237 defines = [ "AV_CODEC_PATH=${av_codec_path}" ] 238 239 resource_config_file = 240 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 241} 242 243################################################################################################################## 244ohos_unittest("av_audio_encoder_capi_unit_test") { 245 sanitize = av_codec_test_sanitize 246 module_out_path = module_output_path 247 include_dirs = av_codec_unittest_include_dirs 248 include_dirs += [ 249 "./", 250 "$av_codec_root_dir/interfaces/kits/c", 251 "$av_codec_root_dir/services/engine/common/include", 252 "$av_codec_root_dir/services/engine/base/include", 253 "$av_codec_root_dir/services/utils/include", 254 "$av_codec_root_dir/services/engine/codec/include/audio", 255 "$av_codec_root_dir/services/engine/factory", 256 ] 257 258 cflags = av_codec_unittest_cflags 259 260 cflags_cc = cflags 261 262 public_configs = [] 263 264 if (av_codec_support_test) { 265 sources = [ "./audio_encoder_capi_unit_test.cpp" ] 266 } 267 268 deps = [ 269 "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client", 270 "$av_codec_root_dir/interfaces/kits/c:capi_packages", 271 "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec", 272 "$av_codec_root_dir/services/services:av_codec_service", 273 "$av_codec_root_dir/services/utils:av_codec_service_utils", 274 ] 275 276 external_deps = [ 277 "ffmpeg:libohosffmpeg", 278 "graphic_surface:surface", 279 "media_foundation:native_media_core", 280 ] 281 282 if (target_cpu == "arm64") { 283 av_codec_path = "\"/system/lib64\"" 284 } else { 285 av_codec_path = "\"/system/lib\"" 286 } 287 defines = [ "AV_CODEC_PATH=${av_codec_path}" ] 288 289 resource_config_file = 290 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 291} 292 293################################################################################################################## 294ohos_unittest("av_audio_encoder_avbuffer_capi_unit_test") { 295 sanitize = av_codec_test_sanitize 296 module_out_path = module_output_path 297 include_dirs = av_codec_unittest_include_dirs 298 include_dirs += [ 299 "./", 300 "$av_codec_root_dir/interfaces/kits/c", 301 "$av_codec_root_dir/services/engine/common/include", 302 "$av_codec_root_dir/services/engine/base/include", 303 "$av_codec_root_dir/services/utils/include", 304 "$av_codec_root_dir/services/engine/codec/include/audio", 305 "$av_codec_root_dir/services/engine/factory", 306 ] 307 308 cflags = av_codec_unittest_cflags 309 310 cflags_cc = cflags 311 312 public_configs = [] 313 314 if (av_codec_support_test) { 315 sources = [ "./audio_encoder_avbuffer_capi_unit_test.cpp" ] 316 } 317 318 deps = [ 319 "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client", 320 "$av_codec_root_dir/interfaces/kits/c:capi_packages", 321 "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec", 322 "$av_codec_root_dir/services/services:av_codec_service", 323 "$av_codec_root_dir/services/utils:av_codec_service_utils", 324 ] 325 326 external_deps = [ 327 "ffmpeg:libohosffmpeg", 328 "graphic_surface:surface", 329 "media_foundation:media_foundation", 330 "media_foundation:native_media_core", 331 ] 332 333 if (target_cpu == "arm64") { 334 av_codec_path = "\"/system/lib64\"" 335 } else { 336 av_codec_path = "\"/system/lib\"" 337 } 338 defines = [ "AV_CODEC_PATH=${av_codec_path}" ] 339 340 resource_config_file = 341 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 342} 343 344################################################################################################################## 345ohos_unittest("av_audio_decoder_avbuffer_capi_unit_test") { 346 sanitize = av_codec_test_sanitize 347 module_out_path = module_output_path 348 include_dirs = av_codec_unittest_include_dirs 349 include_dirs += [ 350 "./", 351 "$av_codec_root_dir/interfaces/kits/c", 352 "$av_codec_root_dir/services/engine/common/include", 353 "$av_codec_root_dir/services/engine/base/include", 354 "$av_codec_root_dir/services/utils/include", 355 "$av_codec_root_dir/services/engine/codec/include/audio", 356 "$av_codec_root_dir/services/engine/factory", 357 "$av_codec_root_dir/test/unittest/common/common_mock/", 358 "$av_codec_root_dir/test/unittest/common/common_mock/drm_mock/capi/", 359 ] 360 361 cflags = av_codec_unittest_cflags 362 363 cflags_cc = cflags 364 365 public_configs = [] 366 367 if (av_codec_support_test) { 368 sources = [ "./audio_decoder_avbuffer_capi_unit_test.cpp" ] 369 } 370 if (av_codec_support_drm) { 371 sources += [ "$av_codec_root_dir/test/unittest/common/common_mock/drm_mock/capi/media_key_system_mock.cpp" ] 372 } 373 374 deps = [ 375 "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client", 376 "$av_codec_root_dir/interfaces/kits/c:capi_packages", 377 "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec", 378 "$av_codec_root_dir/services/services:av_codec_service", 379 "$av_codec_root_dir/services/utils:av_codec_service_utils", 380 ] 381 382 external_deps = [ 383 "ffmpeg:libohosffmpeg", 384 "graphic_surface:surface", 385 "media_foundation:media_foundation", 386 "media_foundation:native_media_core", 387 ] 388 389 if (target_cpu == "arm64") { 390 av_codec_path = "\"/system/lib64\"" 391 } else { 392 av_codec_path = "\"/system/lib\"" 393 } 394 defines = [ "AV_CODEC_PATH=${av_codec_path}" ] 395 defines += av_codec_defines 396 if (av_codec_support_drm) { 397 external_deps += [ 398 "drm_framework:drm_framework", 399 "drm_framework:native_drm", 400 ] 401 } 402 403 resource_config_file = 404 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 405} 406 407################################################################################################################## 408ohos_unittest("av_audio_media_codec_unit_test") { 409 sanitize = av_codec_test_sanitize 410 module_out_path = module_output_path 411 include_dirs = av_codec_unittest_include_dirs 412 include_dirs += [ 413 "./", 414 "$av_codec_root_dir/interfaces", 415 "$av_codec_root_dir/interfaces/kits/c", 416 "$av_codec_root_dir/services/drm_decryptor", 417 "$av_codec_root_dir/services/engine/common/include", 418 "$av_codec_root_dir/services/media_engine/modules/media_codec", 419 ] 420 421 cflags = [ 422 "-fno-exceptions", 423 "-Wall", 424 "-fno-common", 425 "-fstack-protector-all", 426 "-Wshadow", 427 "-FPIC", 428 "-FS", 429 "-O2", 430 "-D_FORTIFY_SOURCE=2", 431 "-Wformat=2", 432 "-Wdate-time", 433 ] 434 435 cflags_cc = [ 436 "-std=c++17", 437 "-fno-rtti", 438 ] 439 440 public_configs = [] 441 442 sources = [ "./audio_media_codec_unit_test.cpp" ] 443 444 deps = [ "$av_codec_root_dir/services/media_engine/modules:av_codec_media_engine_modules" ] 445 446 external_deps = [ 447 "c_utils:utils", 448 "media_foundation:media_foundation", 449 ] 450 451 resource_config_file = 452 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 453} 454 455################################################################################################################## 456ohos_unittest("audio_codec_inner_avbuffer_unit_test") { 457 sanitize = av_codec_test_sanitize 458 module_out_path = module_output_path 459 include_dirs = av_codec_unittest_include_dirs 460 include_dirs += [ 461 "./", 462 "$av_codec_root_dir/interfaces", 463 "$av_codec_root_dir/interfaces/kits/c", 464 "$av_codec_root_dir/services/drm_decryptor", 465 "$av_codec_root_dir/services/engine/common/include", 466 "$av_codec_root_dir/services/media_engine/modules/media_codec", 467 "$av_codec_root_dir/framework/native/avcodec", 468 "$av_codec_root_dir/test/nativedemo/include", 469 ] 470 471 cflags = [ 472 "-fno-exceptions", 473 "-Wall", 474 "-fno-common", 475 "-fstack-protector-all", 476 "-Wshadow", 477 "-FPIC", 478 "-FS", 479 "-O2", 480 "-D_FORTIFY_SOURCE=2", 481 "-Wformat=2", 482 "-Wdate-time", 483 ] 484 485 cflags_cc = [ 486 "-std=c++17", 487 "-fno-rtti", 488 ] 489 490 public_configs = [] 491 492 sources = [ "./audio_codec_inner_avbuffer_unit_test.cpp" ] 493 494 deps = [ 495 "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client", 496 "$av_codec_root_dir/interfaces/kits/c:capi_packages", 497 "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec", 498 "$av_codec_root_dir/services/media_engine/modules:av_codec_media_engine_modules", 499 "$av_codec_root_dir/services/services:av_codec_service", 500 "$av_codec_root_dir/services/utils:av_codec_service_utils", 501 ] 502 503 external_deps = [ 504 "c_utils:utils", 505 "media_foundation:media_foundation", 506 ] 507 508 resource_config_file = 509 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 510} 511