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_include_dirs = [
20  "$av_codec_root_dir/interfaces/inner_api/native",
21  "$av_codec_root_dir/interfaces/interfaces/inner_api/native",
22]
23
24av_codec_unittest_cflags = [
25  "-std=c++17",
26  "-fno-rtti",
27  "-fno-exceptions",
28  "-Wall",
29  "-fno-common",
30  "-fstack-protector-strong",
31  "-Wshadow",
32  "-FPIC",
33  "-FS",
34  "-O2",
35  "-D_FORTIFY_SOURCE=2",
36  "-fvisibility=hidden",
37  "-Wformat=2",
38  "-Wdate-time",
39  "-Werror",
40  "-Wextra",
41  "-Wimplicit-fallthrough",
42  "-Wsign-compare",
43  "-Wunused-parameter",
44]
45
46##################################################################################################################
47ohos_unittest("av_audio_capi_unit_test") {
48  sanitize = av_codec_test_sanitize
49  module_out_path = module_output_path
50  include_dirs = av_codec_unittest_include_dirs
51  include_dirs += [
52    "./",
53    "//third_party/ffmpeg",
54    "$av_codec_root_dir/interfaces/kits/c",
55    "$av_codec_root_dir/services/engine/common/include",
56    "$av_codec_root_dir/services/engine/base/include",
57    "$av_codec_root_dir/services/utils/include",
58    "$av_codec_root_dir/services/engine/codec/include/audio",
59    "$av_codec_root_dir/services/engine/factory",
60  ]
61
62  cflags = av_codec_unittest_cflags
63
64  cflags_cc = cflags
65
66  public_configs = []
67
68  if (av_codec_support_test) {
69    sources = [ "./audio_decoder_capi_unit_test.cpp" ]
70  }
71
72  deps = [
73    "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
74    "$av_codec_root_dir/interfaces/kits/c:capi_packages",
75    "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec",
76    "$av_codec_root_dir/services/services:av_codec_service",
77    "$av_codec_root_dir/services/utils:av_codec_service_utils",
78  ]
79
80  external_deps = [
81    "graphic_surface:surface",
82    "media_foundation:native_media_core",
83  ]
84
85  if (target_cpu == "arm64") {
86    av_codec_path = "\"/system/lib64\""
87  } else {
88    av_codec_path = "\"/system/lib\""
89  }
90  defines = [ "AV_CODEC_PATH=${av_codec_path}" ]
91
92  resource_config_file =
93      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
94}
95
96##################################################################################################################
97ohos_unittest("av_audio_codecbase_unit_test") {
98  sanitize = av_codec_test_sanitize
99  module_out_path = module_output_path
100  include_dirs = av_codec_unittest_include_dirs
101  include_dirs += [
102    "./",
103    "//third_party/ffmpeg",
104    "$av_codec_root_dir/interfaces/kits/c",
105    "$av_codec_root_dir/services/engine/common/include",
106    "$av_codec_root_dir/services/engine/base/include",
107    "$av_codec_root_dir/services/utils/include",
108    "$av_codec_root_dir/services/engine/codec/include/audio",
109    "$av_codec_root_dir/services/engine/factory",
110  ]
111
112  cflags = av_codec_unittest_cflags
113
114  cflags_cc = cflags
115
116  public_configs = []
117
118  if (av_codec_support_test) {
119    sources = [ "./audio_decoder_codecbase_unit_test.cpp" ]
120  }
121
122  deps = [
123    "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
124    "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec",
125    "$av_codec_root_dir/services/utils:av_codec_service_utils",
126  ]
127
128  external_deps = [
129    "graphic_surface:surface",
130    "hilog:libhilog",
131  ]
132
133  if (target_cpu == "arm64") {
134    av_codec_path = "\"/system/lib64\""
135  } else {
136    av_codec_path = "\"/system/lib\""
137  }
138  defines = [ "AV_CODEC_PATH=${av_codec_path}" ]
139
140  resource_config_file =
141      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
142}
143
144##################################################################################################################
145ohos_unittest("av_audio_decode_ability_unit_test") {
146  sanitize = av_codec_test_sanitize
147  module_out_path = module_output_path
148  include_dirs = av_codec_unittest_include_dirs
149  include_dirs += [
150    "./",
151    "//third_party/ffmpeg",
152    "$av_codec_root_dir/interfaces/kits/c",
153    "$av_codec_root_dir/services/engine/common/include",
154    "$av_codec_root_dir/services/engine/base/include",
155    "$av_codec_root_dir/services/utils/include",
156    "$av_codec_root_dir/services/engine/codec/include/audio",
157    "$av_codec_root_dir/services/engine/factory",
158  ]
159
160  cflags = av_codec_unittest_cflags
161
162  cflags_cc = cflags
163
164  public_configs = []
165
166  if (av_codec_support_test) {
167    sources = [ "./audio_decoder_ability_unit_test.cpp" ]
168  }
169
170  deps = [
171    "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
172    "$av_codec_root_dir/interfaces/kits/c:capi_packages",
173    "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec",
174    "$av_codec_root_dir/services/services:av_codec_service",
175    "$av_codec_root_dir/services/utils:av_codec_service_utils",
176  ]
177
178  external_deps = [
179    "graphic_surface:surface",
180    "media_foundation:native_media_core",
181  ]
182
183  if (target_cpu == "arm64") {
184    av_codec_path = "\"/system/lib64\""
185  } else {
186    av_codec_path = "\"/system/lib\""
187  }
188  defines = [ "AV_CODEC_PATH=${av_codec_path}" ]
189
190  resource_config_file =
191      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
192}
193
194##################################################################################################################
195ohos_unittest("av_audio_inner_unit_test") {
196  sanitize = av_codec_test_sanitize
197  module_out_path = module_output_path
198  include_dirs = av_codec_unittest_include_dirs
199  include_dirs += [
200    "./",
201    "//third_party/ffmpeg",
202    "$av_codec_root_dir/interfaces/kits/c",
203    "$av_codec_root_dir/services/engine/common/include",
204    "$av_codec_root_dir/services/engine/base/include",
205    "$av_codec_root_dir/services/utils/include",
206    "$av_codec_root_dir/services/engine/codec/include/audio",
207    "$av_codec_root_dir/services/engine/factory",
208  ]
209
210  cflags = av_codec_unittest_cflags
211
212  cflags_cc = cflags
213
214  public_configs = []
215
216  if (av_codec_support_test) {
217    sources = [ "./audio_decoder_inner_unit_test.cpp" ]
218  }
219
220  deps = [
221    "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
222    "$av_codec_root_dir/interfaces/kits/c:capi_packages",
223    "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec",
224    "$av_codec_root_dir/services/services:av_codec_service",
225    "$av_codec_root_dir/services/utils:av_codec_service_utils",
226  ]
227
228  external_deps = [ "graphic_surface:surface" ]
229
230  if (target_cpu == "arm64") {
231    av_codec_path = "\"/system/lib64\""
232  } else {
233    av_codec_path = "\"/system/lib\""
234  }
235  defines = [ "AV_CODEC_PATH=${av_codec_path}" ]
236
237  resource_config_file =
238      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
239}
240
241##################################################################################################################
242ohos_unittest("av_audio_encoder_capi_unit_test") {
243  sanitize = av_codec_test_sanitize
244  module_out_path = module_output_path
245  include_dirs = av_codec_unittest_include_dirs
246  include_dirs += [
247    "./",
248    "//third_party/ffmpeg",
249    "$av_codec_root_dir/interfaces/kits/c",
250    "$av_codec_root_dir/services/engine/common/include",
251    "$av_codec_root_dir/services/engine/base/include",
252    "$av_codec_root_dir/services/utils/include",
253    "$av_codec_root_dir/services/engine/codec/include/audio",
254    "$av_codec_root_dir/services/engine/factory",
255  ]
256
257  cflags = av_codec_unittest_cflags
258
259  cflags_cc = cflags
260
261  public_configs = []
262
263  if (av_codec_support_test) {
264    sources = [ "./audio_encoder_capi_unit_test.cpp" ]
265  }
266
267  deps = [
268    "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
269    "$av_codec_root_dir/interfaces/kits/c:capi_packages",
270    "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec",
271    "$av_codec_root_dir/services/services:av_codec_service",
272    "$av_codec_root_dir/services/utils:av_codec_service_utils",
273  ]
274
275  external_deps = [
276    "graphic_surface:surface",
277    "media_foundation:native_media_core",
278  ]
279
280  if (target_cpu == "arm64") {
281    av_codec_path = "\"/system/lib64\""
282  } else {
283    av_codec_path = "\"/system/lib\""
284  }
285  defines = [ "AV_CODEC_PATH=${av_codec_path}" ]
286
287  resource_config_file =
288      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
289}
290
291##################################################################################################################
292ohos_unittest("av_audio_encoder_avbuffer_capi_unit_test") {
293  sanitize = av_codec_test_sanitize
294  module_out_path = module_output_path
295  include_dirs = av_codec_unittest_include_dirs
296  include_dirs += [
297    "./",
298    "//third_party/ffmpeg",
299    "$av_codec_root_dir/interfaces/kits/c",
300    "$av_codec_root_dir/services/engine/common/include",
301    "$av_codec_root_dir/services/engine/base/include",
302    "$av_codec_root_dir/services/utils/include",
303    "$av_codec_root_dir/services/engine/codec/include/audio",
304    "$av_codec_root_dir/services/engine/factory",
305  ]
306
307  cflags = av_codec_unittest_cflags
308
309  cflags_cc = cflags
310
311  public_configs = []
312
313  if (av_codec_support_test) {
314    sources = [ "./audio_encoder_avbuffer_capi_unit_test.cpp" ]
315  }
316
317  deps = [
318    "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
319    "$av_codec_root_dir/interfaces/kits/c:capi_packages",
320    "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec",
321    "$av_codec_root_dir/services/services:av_codec_service",
322    "$av_codec_root_dir/services/utils:av_codec_service_utils",
323  ]
324
325  external_deps = [
326    "graphic_surface:surface",
327    "media_foundation:media_foundation",
328    "media_foundation:native_media_core",
329  ]
330
331  if (target_cpu == "arm64") {
332    av_codec_path = "\"/system/lib64\""
333  } else {
334    av_codec_path = "\"/system/lib\""
335  }
336  defines = [ "AV_CODEC_PATH=${av_codec_path}" ]
337
338  resource_config_file =
339      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
340}
341
342##################################################################################################################
343ohos_unittest("av_audio_decoder_avbuffer_capi_unit_test") {
344  sanitize = av_codec_test_sanitize
345  module_out_path = module_output_path
346  include_dirs = av_codec_unittest_include_dirs
347  include_dirs += [
348    "./",
349    "//third_party/ffmpeg",
350    "$av_codec_root_dir/interfaces/kits/c",
351    "$av_codec_root_dir/services/engine/common/include",
352    "$av_codec_root_dir/services/engine/base/include",
353    "$av_codec_root_dir/services/utils/include",
354    "$av_codec_root_dir/services/engine/codec/include/audio",
355    "$av_codec_root_dir/services/engine/factory",
356    "$av_codec_root_dir/test/unittest/common/common_mock/",
357    "$av_codec_root_dir/test/unittest/common/common_mock/drm_mock/capi/",
358  ]
359
360  cflags = av_codec_unittest_cflags
361
362  cflags_cc = cflags
363
364  public_configs = []
365
366  if (av_codec_support_test) {
367    sources = [ "./audio_decoder_avbuffer_capi_unit_test.cpp" ]
368  }
369  if (av_codec_support_drm) {
370    sources += [ "$av_codec_root_dir/test/unittest/common/common_mock/drm_mock/capi/media_key_system_mock.cpp" ]
371  }
372
373  deps = [
374    "$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
375    "$av_codec_root_dir/interfaces/kits/c:capi_packages",
376    "$av_codec_root_dir/services/engine/codec/audio:av_codec_audio_ffmpeg_codec",
377    "$av_codec_root_dir/services/services:av_codec_service",
378    "$av_codec_root_dir/services/utils:av_codec_service_utils",
379  ]
380
381  external_deps = [
382    "graphic_surface:surface",
383    "media_foundation:media_foundation",
384    "media_foundation:native_media_core",
385  ]
386
387  if (target_cpu == "arm64") {
388    av_codec_path = "\"/system/lib64\""
389  } else {
390    av_codec_path = "\"/system/lib\""
391  }
392  defines = [ "AV_CODEC_PATH=${av_codec_path}" ]
393
394  if (av_codec_support_drm) {
395    external_deps += [
396      "drm_framework:drm_framework",
397      "drm_framework:native_drm",
398    ]
399  }
400
401  resource_config_file =
402      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
403}
404
405##################################################################################################################
406ohos_unittest("av_audio_media_codec_unit_test") {
407  sanitize = av_codec_test_sanitize
408  module_out_path = module_output_path
409  include_dirs = av_codec_unittest_include_dirs
410  include_dirs += [
411    "./",
412    "$av_codec_root_dir/interfaces",
413    "$av_codec_root_dir/interfaces/kits/c",
414    "$av_codec_root_dir/services/engine/common/include",
415    "$av_codec_root_dir/services/media_engine/modules/media_codec",
416  ]
417
418  cflags = [
419    "-fno-exceptions",
420    "-Wall",
421    "-fno-common",
422    "-fstack-protector-all",
423    "-Wshadow",
424    "-FPIC",
425    "-FS",
426    "-O2",
427    "-D_FORTIFY_SOURCE=2",
428    "-Wformat=2",
429    "-Wdate-time",
430  ]
431
432  cflags_cc = [
433    "-std=c++17",
434    "-fno-rtti",
435  ]
436
437  public_configs = []
438
439  sources = [ "./audio_media_codec_unit_test.cpp" ]
440
441  deps = [ "$av_codec_root_dir/services/media_engine/modules:av_codec_media_engine_modules" ]
442
443  external_deps = [
444    "c_utils:utils",
445    "media_foundation:media_foundation",
446  ]
447
448  resource_config_file =
449      "$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
450}
451