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 19avsource_unittest_cflags = [ 20 "-std=c++17", 21 "-fno-rtti", 22 "-fno-exceptions", 23 "-Wall", 24 "-fno-common", 25 "-fstack-protector-strong", 26 "-Wshadow", 27 "-FPIC", 28 "-FS", 29 "-O2", 30 "-D_FORTIFY_SOURCE=2", 31 "-fvisibility=hidden", 32 "-Wformat=2", 33 "-Wdate-time", 34 "-Werror", 35 "-Wextra", 36 "-Wimplicit-fallthrough", 37 "-Wsign-compare", 38 "-Wunused-parameter", 39] 40 41################################################################################################################muxer 42ohos_unittest("avsource_capi_unit_test") { 43 sanitize = av_codec_test_sanitize 44 module_out_path = module_output_path 45 include_dirs = [ 46 "./", 47 "./capi", 48 "$av_codec_root_dir/interfaces/inner_api/native", 49 "$av_codec_root_dir/interfaces/kits/c", 50 "$av_codec_root_dir/test/unittest/format_test", 51 "$av_codec_root_dir/test/unittest/format_test/capi", 52 "$av_codec_root_dir/test/nativedemo/include", 53 "$av_codec_root_dir/test/nativedemo/avdemuxer/server_demo", 54 "//third_party/ffmpeg", 55 ] 56 57 cflags = avsource_unittest_cflags 58 59 if (av_codec_support_source) { 60 sources = [ 61 "$av_codec_root_dir/test/nativedemo/avdemuxer/server_demo/file_server_demo.cpp", 62 "./avsource_format_unit_test.cpp", 63 "./avsource_hevc_unit_test.cpp", 64 "./avsource_unit_test.cpp", 65 "./avsource_uri_unit_test.cpp", 66 "./capi/avsource_capi_mock.cpp", 67 "./capi/avsource_capi_mock_factory.cpp", 68 ] 69 } 70 71 if (target_cpu == "arm64" || is_emulator) { 72 av_codec_path = "\"/system/lib64\"" 73 } else { 74 av_codec_path = "\"/system/lib\"" 75 } 76 defines = [ "AV_CODEC_PATH=${av_codec_path}" ] 77 78 deps = [ "$av_codec_root_dir/interfaces/kits/c:capi_packages" ] 79 public_deps = 80 [ "$av_codec_root_dir/test/unittest/common:av_codec_capi_unit_test" ] 81 external_deps = [ 82 "av_codec:av_codec_client", 83 "c_utils:utils", 84 "graphic_2d:libgraphic_utils", 85 "graphic_surface:surface", 86 "hilog:libhilog", 87 "media_foundation:media_foundation", 88 "media_foundation:native_media_core", 89 ] 90 91 resource_config_file = 92 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 93} 94 95#################################################################################################################muxer 96ohos_unittest("avsource_inner_unit_test") { 97 sanitize = av_codec_test_sanitize 98 module_out_path = module_output_path 99 include_dirs = [ 100 "./", 101 "./inner", 102 "$av_codec_root_dir/interfaces/inner_api/native", 103 "$av_codec_root_dir/interfaces/kits/c", 104 "$av_codec_root_dir/test/unittest/format_test", 105 "$av_codec_root_dir/test/unittest/format_test/inner", 106 "$av_codec_root_dir/test/nativedemo/include", 107 "$av_codec_root_dir/test/nativedemo/avdemuxer/server_demo", 108 "//third_party/ffmpeg", 109 ] 110 111 if (target_cpu == "arm64" || is_emulator) { 112 av_codec_path = "\"/system/lib64\"" 113 } else { 114 av_codec_path = "\"/system/lib\"" 115 } 116 defines = [ 117 "AV_CODEC_PATH=${av_codec_path}", 118 "AVSOURCE_INNER_UNIT_TEST", 119 ] 120 121 cflags = avsource_unittest_cflags 122 123 if (av_codec_support_source) { 124 sources = [ 125 "$av_codec_root_dir/test/nativedemo/avdemuxer/server_demo/file_server_demo.cpp", 126 "./avsource_audio_vivid_unit_test.cpp", 127 "./avsource_format_unit_test.cpp", 128 "./avsource_hevc_unit_test.cpp", 129 "./avsource_unit_test.cpp", 130 "./avsource_uri_unit_test.cpp", 131 "./inner/avsource_inner_mock.cpp", 132 "./inner/avsource_inner_mock_factory.cpp", 133 ] 134 } 135 public_deps = 136 [ "$av_codec_root_dir/test/unittest/common:av_codec_inner_unit_test" ] 137 external_deps = [ 138 "av_codec:av_codec_client", 139 "c_utils:utils", 140 "graphic_2d:libgraphic_utils", 141 "graphic_surface:surface", 142 "hilog:libhilog", 143 "media_foundation:media_foundation", 144 ] 145 146 resource_config_file = 147 "$av_codec_root_dir/test/unittest/resources/ohos_test.xml" 148} 149