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/utils/include", 65 66 # av_codec_engine_codeclist_mock 67 "$av_codec_root_dir/services/engine/codeclist", 68 "$av_codec_root_dir/../../graphic/graphic_2d/utils/sync_fence/export", 69 "$av_codec_root_dir/../../graphic/graphic_surface/surface/include", 70 "$av_codec_root_dir/../../graphic/graphic_2d/interfaces/inner_api", 71 "$av_codec_root_dir/../../window/window_manager/interfaces/innerkits", 72 "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common/", 73] 74 75ohos_unittest("codec_server_coverage_unit_test") { 76 sanitize = av_codec_test_sanitize 77 module_out_path = module_output_path 78 cflags = av_codec_unittest_cflags 79 cflags_cc = cflags 80 include_dirs = codec_server_coverage_include_dirs 81 defines = av_codec_defines 82 if (av_codec_enable_special_codec) { 83 defines += [ "AV_CODEC_AUDIO_VIVID_CAPACITY" ] 84 } 85 86 sources = [ 87 "$av_codec_root_dir/frameworks/native/common/avcodec_errors.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 "./codec_server_coverage_unit_test.cpp", 96 "./mock/codec_drm_decrypt_mock.cpp", 97 "./mock/codecbase_mock.cpp", 98 ] 99 100 # av_codec_engine_codeclist_mock 101 sources += [ 102 "$av_codec_root_dir/services/engine/codeclist/codeclist_core.cpp", 103 "./mock/codec_ability_singleton_mock.cpp", 104 ] 105 106 deps = [ 107 ":av_codec_engine_codeclist_mock", # av_codec_engine_codeclist_mock 108 "$av_codec_root_dir/services/dfx:av_codec_service_dfx", 109 "$av_codec_root_dir/services/utils:av_codec_service_utils", 110 "//third_party/googletest:gmock_main", 111 ] 112 113 external_deps = [ 114 "c_utils:utils", 115 "graphic_2d:libgraphic_utils", 116 "graphic_2d:librender_service_client", 117 "graphic_surface:surface", 118 "graphic_surface:sync_fence", 119 "hilog:libhilog", 120 "ipc:ipc_single", 121 "media_foundation:media_foundation", 122 "window_manager:libwm", 123 ] 124 125 resource_config_file = 126 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 127} 128 129# 目的:反复mock单例模式的初始化方法 130# 作用:defines将CodecAbilitySingleton替换成Impl,在测试用例中继承Impl并重写GetInstance方法 131ohos_static_library("av_codec_engine_codeclist_mock") { 132 testonly = true 133 cflags = av_codec_unittest_cflags 134 cflags_cc = cflags 135 defines = [ "CodecAbilitySingleton=CodecAbilitySingletonImpl" ] 136 if (av_codec_enable_special_codec) { 137 defines += [ "AV_CODEC_AUDIO_VIVID_CAPACITY" ] 138 } 139 if (target_cpu == "arm64") { 140 av_codec_path = "\"/system/lib64\"" 141 } else { 142 av_codec_path = "\"/system/lib\"" 143 } 144 defines += [ "AV_CODEC_PATH=${av_codec_path}" ] 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