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_cflags = [ 20 "-std=c++17", 21 "-fno-rtti", 22 "-Wall", 23 "-fno-common", 24 "-fstack-protector-strong", 25 "-Wshadow", 26 "-FPIC", 27 "-FS", 28 "-O2", 29 "-D_FORTIFY_SOURCE=2", 30 "-fvisibility=hidden", 31 "-Wformat=2", 32 "-Wdate-time", 33 "-Werror", 34 "-Wextra", 35 "-Wimplicit-fallthrough", 36 "-Wsign-compare", 37 "-Wno-unused-function", 38 "-Wno-unused-parameter", 39 "-Dprivate=public", 40 "-Dprotected=public", 41] 42 43group("codec_server_test") { 44 testonly = true 45 deps = [ ":codec_server_coverage_unit_test" ] 46} 47 48################################################################################################################## 49codec_server_coverage_include_dirs = [ 50 "./", 51 "./mock/include", 52 "$av_codec_root_dir/test/unittest/common", 53 "$av_codec_root_dir/interfaces/inner_api/native", 54 "$av_codec_root_dir/services/dfx/include", 55 "$av_codec_root_dir/services/drm_decryptor", 56 "$av_codec_root_dir/services/engine/base/include/", 57 "$av_codec_root_dir/services/engine/codec/include/audio/", 58 "$av_codec_root_dir/services/engine/common/include/", 59 "$av_codec_root_dir/services/include", 60 "$av_codec_root_dir/services/services/codec/server", 61 "$av_codec_root_dir/services/services/codec/server/post_processing", 62 "$av_codec_root_dir/services/utils/include", 63 64 # av_codec_engine_codeclist_mock 65 "$av_codec_root_dir/services/engine/codeclist", 66 "$av_codec_root_dir/../../graphic/graphic_2d/utils/sync_fence/export", 67 "$av_codec_root_dir/../../graphic/graphic_surface/surface/include", 68 "$av_codec_root_dir/../../graphic/graphic_2d/interfaces/inner_api", 69 "$av_codec_root_dir/../../window/window_manager/interfaces/innerkits", 70 "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common/", 71] 72 73ohos_unittest("codec_server_coverage_unit_test") { 74 sanitize = av_codec_test_sanitize 75 module_out_path = module_output_path 76 cflags = av_codec_unittest_cflags 77 cflags_cc = cflags 78 include_dirs = codec_server_coverage_include_dirs 79 defines = av_codec_defines 80 if (av_codec_enable_special_codec) { 81 defines += [ "AV_CODEC_AUDIO_VIVID_CAPACITY" ] 82 } 83 84 sources = [ 85 "$av_codec_root_dir/frameworks/native/common/avcodec_errors.cpp", 86 "$av_codec_root_dir/services/services/codec/server/codec_factory.cpp", 87 "$av_codec_root_dir/services/services/codec/server/codec_param_checker.cpp", 88 "$av_codec_root_dir/services/services/codec/server/codec_server.cpp", 89 "$av_codec_root_dir/services/services/codec/server/post_processing/dynamic_controller.cpp", 90 "$av_codec_root_dir/services/services/codec/server/post_processing/dynamic_interface.cpp", 91 "$av_codec_root_dir/services/services/codec/server/post_processing/state_machine.cpp", 92 "$av_codec_root_dir/services/services/codec/server/temporal_scalability.cpp", 93 "./codec_server_coverage_unit_test.cpp", 94 "./mock/codec_drm_decrypt_mock.cpp", 95 "./mock/codecbase_mock.cpp", 96 ] 97 98 # av_codec_engine_codeclist_mock 99 sources += [ 100 "$av_codec_root_dir/services/engine/codeclist/codeclist_core.cpp", 101 "./mock/codec_ability_singleton_mock.cpp", 102 ] 103 104 deps = [ 105 ":av_codec_engine_codeclist_mock", # av_codec_engine_codeclist_mock 106 "$av_codec_root_dir/services/dfx:av_codec_service_dfx", 107 "$av_codec_root_dir/services/utils:av_codec_service_utils", 108 "//third_party/googletest:gmock_main", 109 ] 110 111 external_deps = [ 112 "c_utils:utils", 113 "graphic_2d:libgraphic_utils", 114 "graphic_2d:librender_service_client", 115 "graphic_surface:surface", 116 "graphic_surface:sync_fence", 117 "hilog:libhilog", 118 "ipc:ipc_single", 119 "media_foundation:media_foundation", 120 "window_manager:libwm", 121 ] 122 123 resource_config_file = 124 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 125} 126 127# 目的:反复mock单例模式的初始化方法 128# 作用:defines将CodecAbilitySingleton替换成Impl,在测试用例中继承Impl并重写GetInstance方法 129ohos_static_library("av_codec_engine_codeclist_mock") { 130 testonly = true 131 cflags = av_codec_unittest_cflags 132 cflags_cc = cflags 133 defines = [ "CodecAbilitySingleton=CodecAbilitySingletonImpl" ] 134 if (av_codec_enable_special_codec) { 135 defines += [ "AV_CODEC_AUDIO_VIVID_CAPACITY" ] 136 } 137 if (target_cpu == "arm64") { 138 av_codec_path = "\"/system/lib64\"" 139 } else { 140 av_codec_path = "\"/system/lib\"" 141 } 142 defines += [ "AV_CODEC_PATH=${av_codec_path}" ] 143 sanitize = av_codec_sanitize 144 include_dirs = codec_server_coverage_include_dirs 145 146 sources = [ 147 "$av_codec_root_dir/services/engine/codeclist/audio_codeclist_info.cpp", 148 "$av_codec_root_dir/services/engine/codeclist/codec_ability_singleton.cpp", 149 "$av_codec_root_dir/services/engine/codeclist/codeclist_builder.cpp", 150 "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common/hdi_codec.cpp", 151 ] 152 153 deps = [ 154 "$av_codec_root_dir/services/dfx:av_codec_service_dfx", 155 "$av_codec_root_dir/services/utils:av_codec_service_utils", 156 "//third_party/googletest:gmock_main", 157 ] 158 159 external_deps = [ 160 "c_utils:utils", 161 "drivers_interface_codec:libcodec_proxy_3.0", 162 "graphic_surface:surface", 163 "graphic_surface:sync_fence", 164 "hilog:libhilog", 165 "ipc:ipc_single", 166 "media_foundation:media_foundation", 167 ] 168 subsystem_name = "multimedia" 169 part_name = "av_codec" 170} 171 172################################################################################################################## 173 174