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 "./post_processing_coverage_unit_test.cpp", 97 ] 98 99 # av_codec_engine_codeclist_mock 100 sources += [ 101 "$av_codec_root_dir/services/engine/codeclist/codeclist_core.cpp", 102 "./mock/codec_ability_singleton_mock.cpp", 103 ] 104 105 deps = [ 106 ":av_codec_engine_codeclist_mock", # av_codec_engine_codeclist_mock 107 "$av_codec_root_dir/services/dfx:av_codec_service_dfx", 108 "$av_codec_root_dir/services/utils:av_codec_service_utils", 109 "//third_party/googletest:gmock_main", 110 ] 111 112 external_deps = [ 113 "c_utils:utils", 114 "graphic_2d:libgraphic_utils", 115 "graphic_2d:librender_service_client", 116 "graphic_surface:surface", 117 "graphic_surface:sync_fence", 118 "hilog:libhilog", 119 "ipc:ipc_single", 120 "media_foundation:media_foundation", 121 "window_manager:libwm", 122 ] 123 124 if (av_codec_support_drm) { 125 external_deps += [ 126 "drm_framework:drm_framework", 127 "drm_framework:native_drm", 128 ] 129 } 130 131 resource_config_file = 132 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 133} 134 135# 目的:反复mock单例模式的初始化方法 136# 作用:defines将CodecAbilitySingleton替换成Impl,在测试用例中继承Impl并重写GetInstance方法 137ohos_static_library("av_codec_engine_codeclist_mock") { 138 testonly = true 139 cflags = av_codec_unittest_cflags 140 cflags_cc = cflags 141 defines = [ "CodecAbilitySingleton=CodecAbilitySingletonImpl" ] 142 if (av_codec_enable_special_codec) { 143 defines += [ "AV_CODEC_AUDIO_VIVID_CAPACITY" ] 144 } 145 sanitize = av_codec_sanitize 146 include_dirs = codec_server_coverage_include_dirs 147 148 sources = [ 149 "$av_codec_root_dir/services/engine/codeclist/audio_codeclist_info.cpp", 150 "$av_codec_root_dir/services/engine/codeclist/codec_ability_singleton.cpp", 151 "$av_codec_root_dir/services/engine/codeclist/codeclist_builder.cpp", 152 "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common/hdi_codec.cpp", 153 ] 154 155 deps = [ 156 "$av_codec_root_dir/services/dfx:av_codec_service_dfx", 157 "$av_codec_root_dir/services/utils:av_codec_service_utils", 158 "//third_party/googletest:gmock_main", 159 ] 160 161 external_deps = [ 162 "c_utils:utils", 163 "drivers_interface_codec:libcodec_proxy_3.0", 164 "graphic_surface:surface", 165 "graphic_surface:sync_fence", 166 "hilog:libhilog", 167 "ipc:ipc_single", 168 "media_foundation:media_foundation", 169 ] 170 subsystem_name = "multimedia" 171 part_name = "av_codec" 172} 173 174################################################################################################################## 175 176