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/common", 62 "$av_codec_root_dir/services/services/common/event_manager/", 63 "$av_codec_root_dir/services/services/codec/server/post_processing", 64 "$av_codec_root_dir/services/services/common", 65 "$av_codec_root_dir/services/utils/include", 66 67 # av_codec_engine_codeclist_mock 68 "$av_codec_root_dir/services/engine/codeclist", 69 "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common/", 70] 71 72ohos_unittest("codec_server_coverage_unit_test") { 73 sanitize = av_codec_test_sanitize 74 module_out_path = module_output_path 75 cflags = av_codec_unittest_cflags 76 cflags_cc = cflags 77 include_dirs = codec_server_coverage_include_dirs 78 defines = av_codec_defines 79 if (av_codec_enable_special_codec) { 80 defines += [ "AV_CODEC_AUDIO_VIVID_CAPACITY" ] 81 } 82 83 sources = [ 84 "$av_codec_root_dir/frameworks/native/common/avcodec_errors.cpp", 85 "$av_codec_root_dir/services/dfx/avcodec_dfx_component.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 ] 110 111 external_deps = [ 112 "c_utils:utils", 113 "googletest:gmock_main", 114 "graphic_2d:libgraphic_utils", 115 "graphic_2d:librender_service_client", 116 "graphic_surface:surface", 117 "graphic_surface:sync_fence", 118 "hilog:libhilog", 119 "hisysevent:libhisysevent", 120 "ipc:ipc_single", 121 "media_foundation:media_foundation", 122 "window_manager:libwm", 123 ] 124 125 if (av_codec_support_drm) { 126 external_deps += [ 127 "drm_framework:drm_framework", 128 "drm_framework:native_drm", 129 ] 130 } 131 132 resource_config_file = 133 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 134} 135 136# 目的:反复mock单例模式的初始化方法 137# 作用:defines将CodecAbilitySingleton替换成Impl,在测试用例中继承Impl并重写GetInstance方法 138ohos_static_library("av_codec_engine_codeclist_mock") { 139 testonly = true 140 cflags = av_codec_unittest_cflags 141 cflags_cc = cflags 142 defines = [ "CodecAbilitySingleton=CodecAbilitySingletonImpl" ] 143 if (av_codec_enable_special_codec) { 144 defines += [ "AV_CODEC_AUDIO_VIVID_CAPACITY" ] 145 } 146 if (target_cpu == "arm64") { 147 av_codec_path = "\"/system/lib64\"" 148 } else { 149 av_codec_path = "\"/system/lib\"" 150 } 151 defines += [ "AV_CODEC_PATH=${av_codec_path}" ] 152 sanitize = av_codec_sanitize 153 include_dirs = codec_server_coverage_include_dirs 154 155 sources = [ 156 "$av_codec_root_dir/services/engine/codeclist/audio_codeclist_info.cpp", 157 "$av_codec_root_dir/services/engine/codeclist/codec_ability_singleton.cpp", 158 "$av_codec_root_dir/services/engine/codeclist/codeclist_builder.cpp", 159 "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common/hdi_codec.cpp", 160 ] 161 162 deps = [ 163 "$av_codec_root_dir/services/dfx:av_codec_service_dfx", 164 "$av_codec_root_dir/services/utils:av_codec_service_utils", 165 ] 166 167 external_deps = [ 168 "c_utils:utils", 169 "drivers_interface_codec:libcodec_proxy_3.0", 170 "googletest:gmock_main", 171 "graphic_surface:surface", 172 "graphic_surface:sync_fence", 173 "hilog:libhilog", 174 "ipc:ipc_single", 175 "media_foundation:media_foundation", 176 ] 177 subsystem_name = "multimedia" 178 part_name = "av_codec" 179} 180 181################################################################################################################## 182 183