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/AVCodec_Video/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 "../vcodec_framework_test/common/utils", 52 "./mock/include", 53 "$av_codec_root_dir/test/unittest/common", 54 "$av_codec_root_dir/interfaces/inner_api/native", 55 "$av_codec_root_dir/services/dfx/include", 56 "$av_codec_root_dir/services/drm_decryptor", 57 "$av_codec_root_dir/services/engine/base/include/", 58 "$av_codec_root_dir/services/engine/codec/include/audio/", 59 "$av_codec_root_dir/services/engine/common/include/", 60 "$av_codec_root_dir/services/include", 61 "$av_codec_root_dir/services/services/codec/server", 62 "$av_codec_root_dir/services/services/common", 63 "$av_codec_root_dir/services/services/common/event_manager/", 64 "$av_codec_root_dir/services/services/codec/server/post_processing", 65 "$av_codec_root_dir/services/services/common", 66 "$av_codec_root_dir/services/utils/include", 67 68 # av_codec_engine_codeclist_mock 69 "$av_codec_root_dir/services/engine/codeclist", 70 "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common/", 71 "$av_codec_root_dir/services/services/common/adaptive_framerate_controller", 72] 73 74ohos_unittest("codec_server_coverage_unit_test") { 75 sanitize = av_codec_test_sanitize 76 module_out_path = module_output_path 77 cflags = av_codec_unittest_cflags 78 cflags_cc = cflags 79 include_dirs = codec_server_coverage_include_dirs 80 defines = av_codec_defines 81 if (av_codec_enable_special_codec) { 82 defines += [ "AV_CODEC_AUDIO_VIVID_CAPACITY" ] 83 } 84 85 sources = [ 86 "$av_codec_root_dir/frameworks/native/common/avcodec_errors.cpp", 87 "$av_codec_root_dir/services/dfx/avcodec_dfx_component.cpp", 88 "$av_codec_root_dir/services/services/codec/server/codec_factory.cpp", 89 "$av_codec_root_dir/services/services/codec/server/codec_param_checker.cpp", 90 "$av_codec_root_dir/services/services/codec/server/codec_server.cpp", 91 "$av_codec_root_dir/services/services/codec/server/post_processing/dynamic_controller.cpp", 92 "$av_codec_root_dir/services/services/codec/server/post_processing/dynamic_interface.cpp", 93 "$av_codec_root_dir/services/services/codec/server/post_processing/state_machine.cpp", 94 "$av_codec_root_dir/services/services/codec/server/temporal_scalability.cpp", 95 "../vcodec_framework_test/common/utils/unittest_utils.cpp", 96 "./codec_server_coverage_unit_test.cpp", 97 "./mock/codec_drm_decrypt_mock.cpp", 98 "./mock/codecbase_mock.cpp", 99 "./post_processing_coverage_unit_test.cpp", 100 ] 101 102 # av_codec_engine_codeclist_mock 103 sources += [ 104 "$av_codec_root_dir/services/engine/codeclist/codeclist_core.cpp", 105 "./mock/codec_ability_singleton_mock.cpp", 106 ] 107 108 deps = [ 109 ":av_codec_engine_codeclist_mock", # av_codec_engine_codeclist_mock 110 "$av_codec_root_dir/services/dfx:av_codec_service_dfx", 111 "$av_codec_root_dir/services/utils:av_codec_service_utils", 112 "$av_codec_root_dir/services/services/common/adaptive_framerate_controller:adaptive_framerate_controller", 113 ] 114 115 external_deps = [ 116 "c_utils:utils", 117 "eventhandler:libeventhandler", 118 "googletest:gmock_main", 119 "graphic_2d:libgraphic_utils", 120 "graphic_2d:librender_service_base", 121 "graphic_2d:librender_service_client", 122 "graphic_surface:surface", 123 "graphic_surface:sync_fence", 124 "hilog:libhilog", 125 "hisysevent:libhisysevent", 126 "ipc:ipc_single", 127 "media_foundation:media_foundation", 128 "window_manager:libwm", 129 ] 130 131 if (av_codec_support_drm) { 132 external_deps += [ 133 "drm_framework:drm_framework", 134 "drm_framework:native_drm", 135 ] 136 } 137 138 resource_config_file = 139 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 140} 141 142# 目的:反复mock单例模式的初始化方法 143# 作用:defines将CodecAbilitySingleton替换成Impl,在测试用例中继承Impl并重写GetInstance方法 144ohos_static_library("av_codec_engine_codeclist_mock") { 145 testonly = true 146 cflags = av_codec_unittest_cflags 147 cflags_cc = cflags 148 defines = [ "CodecAbilitySingleton=CodecAbilitySingletonImpl" ] 149 if (av_codec_enable_special_codec) { 150 defines += [ "AV_CODEC_AUDIO_VIVID_CAPACITY" ] 151 } 152 if (target_cpu == "arm64") { 153 av_codec_path = "\"/system/lib64\"" 154 } else { 155 av_codec_path = "\"/system/lib\"" 156 } 157 defines += [ "AV_CODEC_PATH=${av_codec_path}" ] 158 sanitize = av_codec_sanitize 159 include_dirs = codec_server_coverage_include_dirs 160 161 sources = [ 162 "$av_codec_root_dir/services/engine/codeclist/audio_codeclist_info.cpp", 163 "$av_codec_root_dir/services/engine/codeclist/codec_ability_singleton.cpp", 164 "$av_codec_root_dir/services/engine/codeclist/codeclist_builder.cpp", 165 "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common/hdi_codec.cpp", 166 ] 167 168 deps = [ 169 "$av_codec_root_dir/services/dfx:av_codec_service_dfx", 170 "$av_codec_root_dir/services/utils:av_codec_service_utils", 171 ] 172 173 external_deps = [ 174 "c_utils:utils", 175 "drivers_interface_codec:libcodec_proxy_4.0", 176 "googletest:gmock_main", 177 "graphic_surface:surface", 178 "graphic_surface:sync_fence", 179 "hilog:libhilog", 180 "ipc:ipc_single", 181 "media_foundation:media_foundation", 182 ] 183 subsystem_name = "multimedia" 184 part_name = "av_codec" 185} 186 187################################################################################################################## 188 189