1# Copyright (c) 2021-2024 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/ohos.gni")
15import("//build/ohos_var.gni")
16import("//build/test.gni")
17import("//foundation/ability/dmsfwk/dmsfwk.gni")
18import("../../../dmsfwk.gni")
19
20module_output_path = "dmsfwk/distributedschedsvrtest"
21
22distributed_service = "//foundation/ability/dmsfwk/services"
23
24dsched_configs =
25    [ "${distributed_service}/dtbschedmgr:distributed_sched_config" ]
26
27config("test_config") {
28  visibility = [ ":*" ]
29  include_dirs = [
30    "${distributed_service}/dtbschedmgr/include",
31    "${distributed_service}/dtbschedmgr/include/continue",
32    "${distributed_service}/dtbschedmgr/include/continue/state",
33    "${distributed_service}/dtbschedmgr/include/continue/state/source_state",
34    "${distributed_service}/dtbschedmgr/include/continue/state/sink_state",
35    "${distributed_service}/dtbschedmgr/include/distributedWant",
36    "${distributed_service}/dtbschedmgr/include/softbus_adapter/transport",
37    "${distributed_service}/dtbschedmgr/test/unittest",
38    "${dms_path}/common/include",
39    "${dms_path}/interfaces/innerkits/distributed_event/include",
40    "${dms_path}/interfaces/innerkits/tests",
41  ]
42}
43
44dsched_external_deps = [
45  "ability_base:base",
46  "ability_base:want",
47  "ability_base:zuri",
48  "ability_runtime:ability_manager",
49  "ability_runtime:app_manager",
50  "ability_runtime:dataobs_manager",
51  "ability_runtime:mission_info",
52  "access_token:libaccesstoken_sdk",
53  "access_token:libnativetoken_shared",
54  "access_token:libtokensetproc_shared",
55  "bundle_framework:appexecfwk_base",
56  "bundle_framework:appexecfwk_core",
57  "cJSON:cjson",
58  "c_utils:utils",
59  "data_share:datashare_consumer",
60  "device_auth:deviceauth_sdk",
61  "device_info_manager:distributed_device_profile_common",
62  "device_info_manager:distributed_device_profile_sdk",
63  "device_manager:devicemanagersdk",
64  "device_security_level:dslm_sdk",
65  "distributed_bundle_framework:dbms_fwk",
66  "dmsfwk:continuation_manager",
67  "dsoftbus:softbus_client",
68  "eventhandler:libeventhandler",
69  "ffrt:libffrt",
70  "hilog:libhilog",
71  "hisysevent:libhisysevent",
72  "hitrace:hitrace_meter",
73  "hitrace:libhitracechain",
74  "init:libbegetutil",
75  "ipc:ipc_core",
76  "kv_store:distributeddata_inner",
77  "safwk:system_ability_fwk",
78  "samgr:samgr_proxy",
79  "window_manager:libwsutils",
80  "window_manager:scene_session",
81  "window_manager:session_manager_lite",
82]
83if (os_account_part) {
84  dsched_external_deps += [ "os_account:os_account_innerkits" ]
85}
86
87if (dmsfwk_report_memmgr) {
88  dsched_external_deps += [ "memmgr:memmgrclient" ]
89}
90
91if (dmsfwk_report_memmgr_plugins) {
92  dsched_external_deps += [ "memmgr_override:memmgrclient" ]
93}
94
95if (dmsfwk_standard_form_share) {
96  dsched_external_deps += [ "form_fwk:form_manager" ]
97}
98
99if (dmsfwk_mission_manager) {
100  dsched_external_deps += [ "image_framework:image_native" ]
101}
102
103if (efficiency_manager_service_enable) {
104  dsched_external_deps += [ "resource_schedule_service:ressched_client" ]
105}
106
107if (dmsfwk_ces_listener) {
108  dsched_external_deps += [ "common_event_service:cesfwk_innerkits" ]
109}
110
111if (dmsfwk_mmi_listener) {
112  dsched_external_deps += [ "input:libmmi-client" ]
113}
114
115dsched_public_deps = [
116  "${distributed_service}/dtbschedmgr:distributedschedsvr",
117  "${dms_path}/common:distributed_sched_utils",
118]
119
120dtbschedmgr_sources = [ "unittest/distributed_sched_test_util.cpp" ]
121
122distributed_event_sources = [
123  "${dms_path}/interfaces/innerkits/distributed_event/src/dms_client.cpp",
124  "${dms_path}/interfaces/innerkits/distributed_event/src/dms_handler.cpp",
125  "${dms_path}/interfaces/innerkits/distributed_event/src/dms_listener_stub.cpp",
126  "${dms_path}/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp",
127]
128
129ohos_unittest("distributedschedsvrtest") {
130  module_out_path = module_output_path
131
132  sources = [
133    "unittest/continue_scene_session_handler_test.cpp",
134    "unittest/distributed_sched_adapter_test.cpp",
135    "unittest/distributed_sched_service_first_test.cpp",
136    "unittest/distributed_sched_service_second_test.cpp",
137    "unittest/distributed_sched_stub_test.cpp",
138    "unittest/dms_callback_task_test.cpp",
139    "unittest/dms_token_callback_test.cpp",
140    "unittest/mock_distributed_sched.cpp",
141    "unittest/mock_remote_stub.cpp",
142  ]
143  sources += dtbschedmgr_sources
144
145  configs = [
146    ":test_config",
147    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
148  ]
149  configs += dsched_configs
150  if (is_standard_system) {
151    external_deps = dsched_external_deps
152    public_deps = dsched_public_deps
153  }
154
155  if (dmsfwk_report_memmgr || dmsfwk_report_memmgr_plugins) {
156    defines = [ "SUPPORT_DISTRIBUTEDCOMPONENT_TO_MEMMGR" ]
157  }
158
159  part_name = "dmsfwk"
160  subsystem_name = "ability"
161}
162
163ohos_unittest("distributedcalltest") {
164  sanitize = {
165    cfi = true
166    cfi_cross_dso = true
167    debug = false
168  }
169  module_out_path = module_output_path
170
171  sources = [
172    "unittest/app_state_observer_test.cpp",
173    "unittest/distributed_sched_call_test.cpp",
174  ]
175
176  configs = [
177    ":test_config",
178    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
179  ]
180  configs += dsched_configs
181  if (is_standard_system) {
182    external_deps = dsched_external_deps
183    public_deps = dsched_public_deps
184  }
185  part_name = "dmsfwk"
186  subsystem_name = "ability"
187}
188
189ohos_unittest("dmsfreeinstallcbtest") {
190  sanitize = {
191    cfi = true
192    cfi_cross_dso = true
193    debug = false
194  }
195  module_out_path = module_output_path
196
197  sources = [
198    "unittest/dms_free_install_callback_test.cpp",
199    "unittest/mock_remote_stub.cpp",
200  ]
201
202  configs = [
203    ":test_config",
204    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
205  ]
206  configs += dsched_configs
207  if (is_standard_system) {
208    external_deps = dsched_external_deps
209    public_deps = dsched_public_deps
210  }
211  part_name = "dmsfwk"
212  subsystem_name = "ability"
213}
214
215ohos_unittest("dschedcontinuetest") {
216  sanitize = {
217    cfi = true
218    cfi_cross_dso = true
219    debug = false
220  }
221  module_out_path = module_output_path
222  sources = [
223    "unittest/distributed_sched_continuation_test.cpp",
224    "unittest/dms_version_manager_test.cpp",
225    "unittest/mock_distributed_sched.cpp",
226    "unittest/mock_remote_stub.cpp",
227  ]
228  sources += dtbschedmgr_sources
229
230  configs = [
231    ":test_config",
232    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
233  ]
234  configs += dsched_configs
235  if (is_standard_system) {
236    external_deps = dsched_external_deps
237    public_deps = dsched_public_deps
238  }
239
240  if (dmsfwk_mission_manager) {
241    defines = [ "SUPPORT_DISTRIBUTED_MISSION_MANAGER" ]
242  }
243
244  if (dmsfwk_standard_form_share) {
245    defines += [ "SUPPORT_DISTRIBUTED_FORM_SHARE" ]
246  }
247
248  part_name = "dmsfwk"
249  subsystem_name = "ability"
250}
251
252ohos_unittest("dschedconnecttest") {
253  sanitize = {
254    cfi = true
255    cfi_cross_dso = true
256    debug = false
257  }
258  module_out_path = module_output_path
259
260  sources = [
261    "unittest/distributed_sched_connect_test.cpp",
262    "unittest/mock_remote_stub.cpp",
263  ]
264  sources += dtbschedmgr_sources
265
266  configs = [
267    ":test_config",
268    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
269  ]
270  configs += dsched_configs
271  if (is_standard_system) {
272    external_deps = dsched_external_deps
273    public_deps = dsched_public_deps
274  }
275  part_name = "dmsfwk"
276  subsystem_name = "ability"
277}
278
279ohos_unittest("dschedpermissiontest") {
280  sanitize = {
281    cfi = true
282    cfi_cross_dso = true
283    debug = false
284  }
285  module_out_path = module_output_path
286
287  sources = [ "unittest/distributed_sched_permission_test.cpp" ]
288  sources += dtbschedmgr_sources
289
290  configs = [
291    ":test_config",
292    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
293  ]
294  configs += dsched_configs
295  if (is_standard_system) {
296    external_deps = dsched_external_deps
297    public_deps = dsched_public_deps
298  }
299  if (token_sync_enable) {
300    cflags_cc = [ "-DTOKEN_SYNC_ENABLE" ]
301  }
302  part_name = "dmsfwk"
303  subsystem_name = "ability"
304}
305
306ohos_unittest("dschedmissionmanagertest") {
307  sanitize = {
308    cfi = true
309    cfi_cross_dso = true
310    debug = false
311  }
312  module_out_path = module_output_path
313  cflags = [ "-Dprivate=public" ]
314  sources = [
315    "unittest/mission/distributed_bm_storage_test.cpp",
316    "unittest/mission/distributed_data_storage_test.cpp",
317    "unittest/mission/distributed_mission_info_test.cpp",
318    "unittest/mission/dms_continue_manager_test.cpp",
319    "unittest/mission/dms_mission_manager_test.cpp",
320    "unittest/mission/dsched_sync_e2e_test.cpp",
321    "unittest/mission/mission_info_converter_test.cpp",
322    "unittest/mission/snapshot_test.cpp",
323    "unittest/mock_remote_stub.cpp",
324  ]
325  sources += dtbschedmgr_sources
326
327  configs = [
328    ":test_config",
329    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
330  ]
331  configs += dsched_configs
332
333  if (is_standard_system) {
334    external_deps = dsched_external_deps
335    external_deps += [ "config_policy:configpolicy_util" ]
336    public_deps = dsched_public_deps
337  }
338  part_name = "dmsfwk"
339  subsystem_name = "ability"
340}
341
342ohos_unittest("bundlemanagerinternaltest") {
343  sanitize = {
344    cfi = true
345    cfi_cross_dso = true
346    debug = false
347  }
348  module_out_path = module_output_path
349  sources = [ "unittest/bundle_manager_internal_test.cpp" ]
350  sources += dtbschedmgr_sources
351
352  configs = [
353    ":test_config",
354    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
355  ]
356  configs += dsched_configs
357
358  if (is_standard_system) {
359    external_deps = dsched_external_deps
360    public_deps = dsched_public_deps
361  }
362  part_name = "dmsfwk"
363  subsystem_name = "ability"
364}
365
366ohos_unittest("softbusadaptertest") {
367  module_out_path = module_output_path
368  cflags = [ "-Dprivate=public" ]
369  sources = [ "unittest/softbus_adapter/softbus_transport_test.cpp" ]
370
371  if (!dmsfwk_softbus_adapter_common) {
372    sources += [
373      "unittest/softbus_adapter/mock_softbus_adapter.cpp",
374      "unittest/softbus_adapter/softbus_adapter_test.cpp",
375    ]
376  } else {
377    sources += [ "unittest/softbus_adapter/softbus_adapter_common_test.cpp" ]
378  }
379
380  configs = [
381    ":test_config",
382    "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags",
383  ]
384  configs += dsched_configs
385
386  if (is_standard_system) {
387    external_deps = dsched_external_deps
388    public_deps = dsched_public_deps
389  }
390  external_deps += [ "googletest:gmock" ]
391  part_name = "dmsfwk"
392  subsystem_name = "ability"
393}
394
395ohos_unittest("hisyseventreporttest") {
396  sanitize = {
397    cfi = true
398    cfi_cross_dso = true
399    debug = false
400  }
401  module_out_path = module_output_path
402  sources = [ "unittest/dms_hisysevent_report_test.cpp" ]
403
404  configs = [
405    ":test_config",
406    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
407  ]
408  configs += dsched_configs
409  deps = []
410  if (is_standard_system) {
411    external_deps = dsched_external_deps
412    public_deps = dsched_public_deps
413  }
414  part_name = "dmsfwk"
415  subsystem_name = "ability"
416}
417
418ohos_unittest("distributeduidtest") {
419  module_out_path = module_output_path
420
421  sources = [ "unittest/distributed_sched_uid_test.cpp" ]
422  sources += dtbschedmgr_sources
423
424  configs = [
425    ":test_config",
426    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
427  ]
428  configs += dsched_configs
429  if (is_standard_system) {
430    external_deps = dsched_external_deps
431    public_deps = dsched_public_deps
432  }
433  part_name = "dmsfwk"
434  subsystem_name = "ability"
435}
436
437ohos_unittest("distributedwanttest") {
438  sanitize = {
439    blocklist = "./cfi_blocklist.txt"
440    cfi = true
441    cfi_cross_dso = true
442    debug = false
443  }
444  module_out_path = module_output_path
445
446  sources = [
447    "unittest/distributedWant/distributed_operation_test.cpp",
448    "unittest/distributedWant/distributed_want_params_test.cpp",
449    "unittest/distributedWant/distributed_want_params_wrapper_test.cpp",
450    "unittest/distributedWant/distributed_want_test.cpp",
451  ]
452
453  configs = [
454    ":test_config",
455    "${distributed_service}/dtbschedmgr/test/resource:coverage_flags",
456  ]
457  configs += dsched_configs
458  if (is_standard_system) {
459    external_deps = dsched_external_deps
460    public_deps = dsched_public_deps
461  }
462  part_name = "dmsfwk"
463  subsystem_name = "ability"
464}
465
466ohos_unittest("dmsbasetest") {
467  sanitize = {
468    cfi = true
469    cfi_cross_dso = true
470    debug = false
471  }
472  module_out_path = module_output_path
473  cflags = [ "-Dprivate=public" ]
474  sources = [
475    "unittest/deviceManager/dms_device_info_test.cpp",
476    "unittest/dfx/distributed_radar_test.cpp",
477    "unittest/dfx/distributed_sched_dumper_test.cpp",
478    "unittest/dfx/distributed_ue_test.cpp",
479    "unittest/dfx/dms_continue_time_dumper_test.cpp",
480    "unittest/dfx/dms_hisysevent_report_test.cpp",
481  ]
482  sources += dtbschedmgr_sources
483
484  configs = [
485    ":test_config",
486    "./resource:coverage_flags",
487  ]
488  deps = []
489  configs += dsched_configs
490  if (is_standard_system) {
491    external_deps = dsched_external_deps
492    public_deps = dsched_public_deps
493  }
494  part_name = "dmsfwk"
495  subsystem_name = "ability"
496}
497
498ohos_unittest("dschedswitchstatustest") {
499  sanitize = {
500    cfi = true
501    cfi_cross_dso = true
502    debug = false
503  }
504  module_out_path = module_output_path
505
506  sources = [ "unittest/switch_status_dependency_test.cpp" ]
507
508  configs = [
509    ":test_config",
510    "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags",
511  ]
512  configs += dsched_configs
513  deps = []
514  if (is_standard_system) {
515    external_deps = dsched_external_deps
516    public_deps = dsched_public_deps
517  }
518  part_name = "dmsfwk"
519  subsystem_name = "ability"
520}
521
522ohos_unittest("dschedcontinuestatetest") {
523  sanitize = {
524    cfi = true
525    cfi_cross_dso = true
526    debug = false
527  }
528  module_out_path = module_output_path
529  cflags = [ "-Dprivate=public" ]
530  sources = [
531    "unittest/continue/dsched_continue_manager_test.cpp",
532    "unittest/continue/dsched_continue_state_test.cpp",
533    "unittest/continue/dsched_continue_test.cpp",
534    "unittest/mock_distributed_sched.cpp",
535  ]
536  sources += dtbschedmgr_sources
537  configs = [
538    ":test_config",
539    "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags",
540  ]
541  configs += dsched_configs
542  deps = []
543  if (is_standard_system) {
544    external_deps = dsched_external_deps
545    public_deps = dsched_public_deps
546  }
547  part_name = "dmsfwk"
548  subsystem_name = "ability"
549}
550
551ohos_unittest("distributedeventtest") {
552  sanitize = {
553    cfi = true
554    cfi_cross_dso = true
555    debug = false
556  }
557  module_out_path = module_output_path
558  cflags = [ "-Dprivate=public" ]
559  sources = [
560    "unittest/distributed_event/dms_client_test.cpp",
561    "unittest/distributed_event/dms_handler_test.cpp",
562    "unittest/distributed_event/dms_listener_stub_test.cpp",
563    "unittest/distributed_event/dms_sa_cilent_test.cpp",
564  ]
565  sources += dtbschedmgr_sources
566  sources += distributed_event_sources
567  configs = [
568    ":test_config",
569    "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags",
570  ]
571  configs += dsched_configs
572  deps = []
573  if (is_standard_system) {
574    external_deps = dsched_external_deps
575    public_deps = dsched_public_deps
576  }
577  part_name = "dmsfwk"
578  subsystem_name = "ability"
579}
580
581ohos_unittest("distributedadaptertest") {
582  module_out_path = module_output_path
583  cflags = [ "-Dprivate=public" ]
584  sources = [
585    "unittest/dms_network_adapter_test.cpp",
586    "unittest/dtbschedmgr_device_info_storage_test.cpp",
587  ]
588  if (dmsfwk_mmi_listener) {
589    sources += [ "unittest/adapter/mmi_adapter_test.cpp" ]
590  }
591  sources += dtbschedmgr_sources
592  configs = [
593    ":test_config",
594    "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags",
595  ]
596  configs += dsched_configs
597  deps = []
598  if (is_standard_system) {
599    external_deps = dsched_external_deps
600    public_deps = dsched_public_deps
601  }
602  part_name = "dmsfwk"
603  subsystem_name = "ability"
604}
605
606group("unittest") {
607  testonly = true
608  deps = [
609    ":bundlemanagerinternaltest",
610    ":distributedadaptertest",
611    ":distributedcalltest",
612    ":distributedeventtest",
613    ":distributedschedsvrtest",
614    ":distributeduidtest",
615    ":distributedwanttest",
616    ":dmsbasetest",
617    ":dmsfreeinstallcbtest",
618    ":dschedconnecttest",
619    ":dschedcontinuestatetest",
620    ":dschedcontinuetest",
621    ":dschedswitchstatustest",
622    ":hisyseventreporttest",
623    ":softbusadaptertest",
624    "${dms_path}/common/test/unittest:distributed_sched_utils_test",
625  ]
626  if (dmsfwk_mission_manager) {
627    deps += [
628      ":dschedmissionmanagertest",
629      ":dschedpermissiontest",
630    ]
631  }
632}
633