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"
18dash_test_sources = [
19  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/base64/base64_utils.cpp",
20  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/dash_media_downloader.cpp",
21  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/dash_mpd_downloader.cpp",
22  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/dash_segment_downloader.cpp",
23  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_adpt_set_manager.cpp",
24  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_adpt_set_node.cpp",
25  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_com_attrs_elements.cpp",
26  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_content_comp_node.cpp",
27  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_descriptor_node.cpp",
28  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_manager_util.cpp",
29  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_manager.cpp",
30  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_node.cpp",
31  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_parser.cpp",
32  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_util.cpp",
33  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mult_seg_base_node.cpp",
34  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_period_manager.cpp",
35  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_period_node.cpp",
36  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_representation_manager.cpp",
37  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_representation_node.cpp",
38  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_seg_base_node.cpp",
39  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_seg_list_node.cpp",
40  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_seg_template_node.cpp",
41  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_seg_tmline_node.cpp",
42  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_seg_url_node.cpp",
43  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_url_type_node.cpp",
44  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/i_dash_mpd_node.cpp",
45  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/mpd_parser/sidx_box_parser.cpp",
46  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/download/downloader.cpp",
47  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/download/network_client/http_curl_client.cpp",
48  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/xml/xml_element.cpp",
49  "$av_codec_root_dir/services/media_engine/plugins/source/http_source/xml/xml_parser.cpp",
50  "$av_codec_root_dir/test/unittest/common/http_server_demo.cpp",
51]
52config("dash_unittest_cfg") {
53  defines = [
54    "HST_ANY_WITH_NO_RTTI",
55    "MEDIA_OHOS",
56  ]
57
58  cflags = [
59    "-Wno-sign-compare",
60    "-fno-exceptions",
61    "-fno-common",
62    "-fstack-protector-all",
63    "-Wshadow",
64    "-FPIC",
65    "-FS",
66    "-O2",
67    "-D_FORTIFY_SOURCE=2",
68    "-Wformat=2",
69    "-Wdate-time",
70  ]
71
72  cflags_cc = [
73    "-std=c++17",
74    "-fno-rtti",
75  ]
76
77  include_dirs = [
78    "$av_codec_root_dir/interfaces",
79    "$av_codec_root_dir/interfaces/inner_api/native",
80    "$av_codec_root_dir/services/media_engine/plugins/source/http_source",
81    "$av_codec_root_dir/services/media_engine/plugins/source/http_source/download",
82    "$av_codec_root_dir/services/media_engine/plugins/source/http_source/xml",
83    "$av_codec_root_dir/services/media_engine/plugins/source/http_source/base64",
84    "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash",
85    "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/include",
86    "$av_codec_root_dir/services/media_engine/plugins/source/http_source/dash/include/mpd_parser",
87    "$av_codec_root_dir/test/unittest/common",
88    "$media_foundation_root_dir/interface/inner_api",
89    "$media_foundation_root_dir/src",
90    "//third_party/curl/include",
91    "//third_party/openssl/include",
92  ]
93}
94
95ohos_unittest("dash_xml_unit_test") {
96  module_out_path = module_output_path
97  testonly = true
98  configs = [
99    ":dash_unittest_cfg",
100    "$av_codec_root_dir/services/dfx:av_codec_service_log_dfx_public_config",
101  ]
102  sources = dash_test_sources + [ "dash_xml_unit_test.cpp" ]
103  deps = [
104    "$av_codec_root_dir/services/dfx:av_codec_service_dfx",
105    "//third_party/curl:curl_shared",
106    "//third_party/openssl:libcrypto_shared",
107  ]
108
109  external_deps = [
110    "c_utils:utils",
111    "graphic_surface:surface",
112    "hilog:libhilog",
113    "init:libbegetutil",
114    "ipc:ipc_single",
115    "libxml2:libxml2",
116    "media_foundation:media_foundation",
117    "netmanager_base:net_conn_manager_if",
118    "safwk:system_ability_fwk",
119  ]
120}
121
122ohos_unittest("dash_mpd_parser_unit_test") {
123  module_out_path = module_output_path
124  testonly = true
125  configs = [
126    ":dash_unittest_cfg",
127    "$av_codec_root_dir/services/dfx:av_codec_service_log_dfx_public_config",
128  ]
129  sources = dash_test_sources + [ "dash_mpd_parser_unit_test.cpp" ]
130  deps = [
131    "$av_codec_root_dir/services/dfx:av_codec_service_dfx",
132    "//third_party/curl:curl_shared",
133    "//third_party/openssl:libcrypto_shared",
134  ]
135
136  external_deps = [
137    "c_utils:utils",
138    "graphic_surface:surface",
139    "hilog:libhilog",
140    "init:libbegetutil",
141    "ipc:ipc_single",
142    "libxml2:libxml2",
143    "media_foundation:media_foundation",
144    "netmanager_base:net_conn_manager_if",
145    "safwk:system_ability_fwk",
146  ]
147}
148
149ohos_unittest("dash_media_downloader_unit_test") {
150  module_out_path = module_output_path
151  testonly = true
152  configs = [
153    ":dash_unittest_cfg",
154    "$av_codec_root_dir/services/dfx:av_codec_service_log_dfx_public_config",
155  ]
156  sources = dash_test_sources + [ "dash_media_downloader_unit_test.cpp" ]
157  deps = [
158    "$av_codec_root_dir/services/dfx:av_codec_service_dfx",
159    "//third_party/curl:curl_shared",
160    "//third_party/openssl:libcrypto_shared",
161  ]
162
163  external_deps = [
164    "c_utils:utils",
165    "graphic_surface:surface",
166    "hilog:libhilog",
167    "init:libbegetutil",
168    "ipc:ipc_single",
169    "libxml2:libxml2",
170    "media_foundation:media_foundation",
171    "netmanager_base:net_conn_manager_if",
172    "safwk:system_ability_fwk",
173  ]
174
175  resource_config_file =
176      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
177}
178
179ohos_unittest("dash_mpd_downloader_unit_test") {
180  module_out_path = module_output_path
181  testonly = true
182  configs = [
183    ":dash_unittest_cfg",
184    "$av_codec_root_dir/services/dfx:av_codec_service_log_dfx_public_config",
185  ]
186  sources = dash_test_sources + [ "dash_mpd_downloader_unit_test.cpp" ]
187  deps = [
188    "$av_codec_root_dir/services/dfx:av_codec_service_dfx",
189    "//third_party/curl:curl_shared",
190    "//third_party/openssl:libcrypto_shared",
191  ]
192
193  external_deps = [
194    "c_utils:utils",
195    "graphic_surface:surface",
196    "hilog:libhilog",
197    "init:libbegetutil",
198    "ipc:ipc_single",
199    "libxml2:libxml2",
200    "media_foundation:media_foundation",
201    "netmanager_base:net_conn_manager_if",
202    "safwk:system_ability_fwk",
203  ]
204
205  resource_config_file =
206      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
207}
208
209ohos_unittest("dash_segment_downloader_unit_test") {
210  module_out_path = module_output_path
211  testonly = true
212  configs = [
213    ":dash_unittest_cfg",
214    "$av_codec_root_dir/services/dfx:av_codec_service_log_dfx_public_config",
215  ]
216  sources = dash_test_sources + [ "dash_segment_downloader_unit_test.cpp" ]
217  deps = [
218    "$av_codec_root_dir/services/dfx:av_codec_service_dfx",
219    "//third_party/curl:curl_shared",
220    "//third_party/openssl:libcrypto_shared",
221  ]
222
223  external_deps = [
224    "c_utils:utils",
225    "graphic_surface:surface",
226    "hilog:libhilog",
227    "init:libbegetutil",
228    "ipc:ipc_single",
229    "libxml2:libxml2",
230    "media_foundation:media_foundation",
231    "netmanager_base:net_conn_manager_if",
232    "safwk:system_ability_fwk",
233  ]
234
235  resource_config_file =
236      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
237}
238