1# Copyright (c) 2021-2022 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("../../../../services/accountmgr/os_account_service.gni")
16
17module_output_path = "os_account/tools"
18
19ohos_moduletest("account_command_create_module_test") {
20  branch_protector_ret = "pac_ret"
21
22  sanitize = {
23    cfi = true
24    cfi_cross_dso = true
25    debug = false
26  }
27
28  module_out_path = module_output_path
29
30  include_dirs = [ "${ability_runtime_path}/tools/test/systemtest/aa" ]
31
32  sources = [
33    "${ability_runtime_path}/tools/test/systemtest/aa/tool_system_test.cpp",
34    "${tools_path}/acm/src/account_command.cpp",
35    "account_command_create_module_test.cpp",
36    "account_command_util.cpp",
37  ]
38
39  configs = [
40    "${ability_runtime_path}/interfaces/inner_api/ability_manager:ability_manager_public_config",
41    "${tools_path}/acm:tools_acm_config",
42  ]
43
44  cflags = []
45  if (target_cpu == "arm") {
46    cflags += [ "-DBINDER_IPC_32BIT" ]
47  }
48
49  deps = [
50    "${common_path}:libaccount_common",
51    "${os_account_innerkits_native_path}:os_account_innerkits",
52    "//third_party/googletest:gtest_main",
53  ]
54
55  external_deps = [
56    "ability_base:base",
57    "ability_runtime:tools_aa_source_set",
58    "c_utils:utils",
59    "hilog:libhilog",
60    "ipc:ipc_single",
61    "os_account:os_account_innerkits",
62  ]
63  cflags_cc = [ "-DACCOUNT_TEST" ]
64}
65
66ohos_moduletest("account_command_create_module_mock_test") {
67  branch_protector_ret = "pac_ret"
68
69  sanitize = {
70    cfi = true
71    cfi_cross_dso = true
72    debug = false
73  }
74
75  module_out_path = module_output_path
76
77  include_dirs = [
78    "${ability_runtime_path}/tools/test/systemtest/aa",
79    "${app_account_innerkits_native_path}/include",
80    "${os_account_dfx_path}/hidumper_adapter",
81    "${services_path}/accountmgr/include/bundle_manager_adapter",
82    "${services_path}/accountmgr/include/ability_manager_adapter",
83    "${services_path}/accountmgr/include",
84    "${os_account_dfx_path}/hitrace_adapter",
85    "${services_path}/accountmgr/include/account_iam",
86    "${services_path}/accountmgr/include/appaccount",
87    "${services_path}/accountmgr/include/domain_account",
88    "${services_path}/accountmgr/include/osaccount",
89    "${bundle_framework_path}/interfaces/inner_api/appexecfwk_core/include",
90    "${os_account_path}/interfaces/innerkits/ohosaccount/native/include/",
91  ]
92
93  sources = [
94    "${ability_runtime_path}/tools/test/systemtest/aa/tool_system_test.cpp",
95    "${app_account_services_path}/test/mock/common/ability_manager_adapter_mock.cpp",
96    "${app_account_services_path}/test/mock/common/bundle_manager_adapter.cpp",
97    "${common_path}/log/src/account_log_wrapper.cpp",
98    "${innerkits_native_path}/src/account_info_parcel.cpp",
99    "${innerkits_native_path}/src/account_proxy.cpp",
100    "${innerkits_native_path}/src/ohos_account_kits.cpp",
101    "${innerkits_native_path}/src/ohos_account_kits_impl.cpp",
102    "${os_account_dfx_path}/hidumper_adapter/account_dump_helper.cpp",
103    "${os_account_dfx_path}/hitrace_adapter/hitrace_adapter.cpp",
104    "${services_path}/accountmgr/src/account_iam/account_iam_callback.cpp",
105    "${services_path}/accountmgr/src/account_iam/account_iam_mgr_stub.cpp",
106    "${services_path}/accountmgr/src/account_iam/account_iam_service.cpp",
107    "${services_path}/accountmgr/src/account_iam/inner_account_iam_manager.cpp",
108    "${services_path}/accountmgr/src/appaccount/app_account_control_manager.cpp",
109    "${tools_path}/acm/src/account_command.cpp",
110    "account_command_create_module_test.cpp",
111    "account_command_util.cpp",
112  ]
113  sources += account_service_sources
114  configs = [
115    "${ability_runtime_path}/interfaces/inner_api/ability_manager:ability_manager_public_config",
116    "${tools_path}/acm:tools_acm_config",
117  ]
118
119  cflags = []
120  if (target_cpu == "arm") {
121    cflags += [ "-DBINDER_IPC_32BIT" ]
122  }
123
124  deps = [
125    "${account_iam_framework_path}:account_iam_innerkits",
126    "${common_path}:libaccount_common",
127    "${domain_account_framework_path}:domain_account_innerkits",
128    "${innerkits_native_path}:libaccountkits",
129    "${os_account_innerkits_native_path}:os_account_innerkits",
130    "//third_party/googletest:gmock_main",
131    "//third_party/googletest:gtest_main",
132  ]
133
134  use_exceptions = true
135
136  external_deps = [
137    "ability_base:want",
138    "ability_runtime:ability_manager",
139    "ability_runtime:app_manager",
140    "ability_runtime:tools_aa_source_set",
141    "ability_runtime:wantagent_innerkits",
142    "access_token:libaccesstoken_sdk",
143    "access_token:libtokenid_sdk",
144    "access_token:libtokensetproc_shared",
145    "bundle_framework:appexecfwk_base",
146    "bundle_framework:appexecfwk_core",
147    "c_utils:utils",
148    "config_policy:configpolicy_util",
149    "hilog:libhilog",
150    "ipc:ipc_single",
151    "mbedtls:mbedtls_shared",
152    "safwk:system_ability_fwk",
153    "samgr:samgr_proxy",
154  ]
155  if (has_huks_part) {
156    external_deps += [ "huks:libhukssdk" ]
157  }
158  cflags_cc = []
159  if (has_user_auth_part) {
160    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
161    external_deps += [ "user_auth_framework:userauth_client" ]
162  }
163  if (has_ces_part) {
164    cflags_cc += [ "-DHAS_CES_PART" ]
165    external_deps += [ "common_event_service:cesfwk_innerkits" ]
166  }
167  if (has_kv_store_part) {
168    external_deps += [ "kv_store:distributeddata_inner" ]
169  }
170  cflags_cc += [ "-DACCOUNT_TEST" ]
171  cflags_cc += [ "-DBUNDLE_ADAPTER_MOCK" ]
172}
173
174ohos_moduletest("account_command_delete_module_mock_test") {
175  branch_protector_ret = "pac_ret"
176
177  sanitize = {
178    cfi = true
179    cfi_cross_dso = true
180    debug = false
181  }
182
183  module_out_path = module_output_path
184
185  include_dirs = [
186    "${ability_runtime_path}/tools/test/systemtest/aa",
187    "${app_account_innerkits_native_path}/include",
188    "${os_account_dfx_path}/hidumper_adapter",
189    "${services_path}/accountmgr/include/bundle_manager_adapter",
190    "${services_path}/accountmgr/include/ability_manager_adapter",
191    "${services_path}/accountmgr/include",
192    "${os_account_dfx_path}/hitrace_adapter",
193    "${services_path}/accountmgr/include/account_iam",
194    "${services_path}/accountmgr/include/appaccount",
195    "${services_path}/accountmgr/include/domain_account",
196    "${services_path}/accountmgr/include/osaccount",
197    "${bundle_framework_path}/interfaces/inner_api/appexecfwk_core/include",
198    "${os_account_path}/interfaces/innerkits/ohosaccount/native/include/",
199  ]
200
201  sources = [
202    "${ability_runtime_path}/tools/test/systemtest/aa/tool_system_test.cpp",
203    "${app_account_services_path}/test/mock/common/ability_manager_adapter_mock.cpp",
204    "${app_account_services_path}/test/mock/common/bundle_manager_adapter.cpp",
205    "${common_path}/log/src/account_log_wrapper.cpp",
206    "${innerkits_native_path}/src/account_info_parcel.cpp",
207    "${innerkits_native_path}/src/account_proxy.cpp",
208    "${innerkits_native_path}/src/ohos_account_kits.cpp",
209    "${innerkits_native_path}/src/ohos_account_kits_impl.cpp",
210    "${os_account_dfx_path}/hidumper_adapter/account_dump_helper.cpp",
211    "${os_account_dfx_path}/hitrace_adapter/hitrace_adapter.cpp",
212    "${services_path}/accountmgr/src/account_iam/account_iam_callback.cpp",
213    "${services_path}/accountmgr/src/account_iam/account_iam_mgr_stub.cpp",
214    "${services_path}/accountmgr/src/account_iam/account_iam_service.cpp",
215    "${services_path}/accountmgr/src/account_iam/inner_account_iam_manager.cpp",
216    "${services_path}/accountmgr/src/appaccount/app_account_control_manager.cpp",
217    "${tools_path}/acm/src/account_command.cpp",
218    "account_command_delete_module_test.cpp",
219    "account_command_util.cpp",
220  ]
221  sources += account_service_sources
222  configs = [
223    "${ability_runtime_path}/interfaces/inner_api/ability_manager:ability_manager_public_config",
224    "${tools_path}/acm:tools_acm_config",
225  ]
226
227  cflags = []
228  if (target_cpu == "arm") {
229    cflags += [ "-DBINDER_IPC_32BIT" ]
230  }
231
232  deps = [
233    "${account_iam_framework_path}:account_iam_innerkits",
234    "${common_path}:libaccount_common",
235    "${domain_account_framework_path}:domain_account_innerkits",
236    "${innerkits_native_path}:libaccountkits",
237    "${os_account_innerkits_native_path}:os_account_innerkits",
238    "//third_party/googletest:gmock_main",
239    "//third_party/googletest:gtest_main",
240  ]
241
242  use_exceptions = true
243
244  external_deps = [
245    "ability_base:want",
246    "ability_runtime:ability_manager",
247    "ability_runtime:app_manager",
248    "ability_runtime:tools_aa_source_set",
249    "ability_runtime:wantagent_innerkits",
250    "access_token:libaccesstoken_sdk",
251    "access_token:libtokenid_sdk",
252    "access_token:libtokensetproc_shared",
253    "bundle_framework:appexecfwk_base",
254    "bundle_framework:appexecfwk_core",
255    "c_utils:utils",
256    "config_policy:configpolicy_util",
257    "hilog:libhilog",
258    "ipc:ipc_single",
259    "mbedtls:mbedtls_shared",
260    "safwk:system_ability_fwk",
261    "samgr:samgr_proxy",
262  ]
263  if (has_huks_part) {
264    external_deps += [ "huks:libhukssdk" ]
265  }
266  cflags_cc = []
267  if (has_user_auth_part) {
268    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
269    external_deps += [ "user_auth_framework:userauth_client" ]
270  }
271  if (has_ces_part) {
272    cflags_cc += [ "-DHAS_CES_PART" ]
273    external_deps += [ "common_event_service:cesfwk_innerkits" ]
274  }
275  if (has_kv_store_part) {
276    external_deps += [ "kv_store:distributeddata_inner" ]
277  }
278  cflags_cc += [ "-DACCOUNT_TEST" ]
279  cflags_cc += [ "-DBUNDLE_ADAPTER_MOCK" ]
280}
281
282ohos_moduletest("account_command_delete_module_test") {
283  branch_protector_ret = "pac_ret"
284
285  sanitize = {
286    cfi = true
287    cfi_cross_dso = true
288    debug = false
289  }
290
291  module_out_path = module_output_path
292
293  include_dirs = [ "${ability_runtime_path}/tools/test/systemtest/aa" ]
294
295  sources = [
296    "${ability_runtime_path}/tools/test/systemtest/aa/tool_system_test.cpp",
297    "${tools_path}/acm/src/account_command.cpp",
298    "account_command_delete_module_test.cpp",
299    "account_command_util.cpp",
300  ]
301
302  configs = [
303    "${ability_runtime_path}/interfaces/inner_api/ability_manager:ability_manager_public_config",
304    "${tools_path}/acm:tools_acm_config",
305  ]
306
307  cflags = []
308  if (target_cpu == "arm") {
309    cflags += [ "-DBINDER_IPC_32BIT" ]
310  }
311
312  deps = [
313    "${common_path}:libaccount_common",
314    "${os_account_innerkits_native_path}:os_account_innerkits",
315    "//third_party/googletest:gtest_main",
316  ]
317
318  external_deps = [
319    "ability_base:base",
320    "ability_runtime:tools_aa_source_set",
321    "c_utils:utils",
322    "hilog:libhilog",
323    "ipc:ipc_single",
324    "os_account:os_account_innerkits",
325  ]
326  cflags_cc = [ "-DACCOUNT_TEST" ]
327}
328
329ohos_moduletest("account_command_dump_module_test") {
330  branch_protector_ret = "pac_ret"
331
332  sanitize = {
333    cfi = true
334    cfi_cross_dso = true
335    debug = false
336  }
337
338  module_out_path = module_output_path
339
340  include_dirs = [ "${ability_runtime_path}/tools/test/systemtest/aa" ]
341
342  sources = [
343    "${ability_runtime_path}/tools/test/systemtest/aa/tool_system_test.cpp",
344    "${tools_path}/acm/src/account_command.cpp",
345    "account_command_dump_module_test.cpp",
346    "account_command_util.cpp",
347  ]
348
349  configs = [
350    "${ability_runtime_path}/interfaces/inner_api/ability_manager:ability_manager_public_config",
351    "${tools_path}/acm:tools_acm_config",
352  ]
353
354  cflags = []
355  if (target_cpu == "arm") {
356    cflags += [ "-DBINDER_IPC_32BIT" ]
357  }
358
359  deps = [
360    "${common_path}:libaccount_common",
361    "${os_account_innerkits_native_path}:os_account_innerkits",
362    "//third_party/googletest:gtest_main",
363  ]
364
365  external_deps = [
366    "ability_base:base",
367    "ability_runtime:tools_aa_source_set",
368    "c_utils:utils",
369    "hilog:libhilog",
370    "ipc:ipc_single",
371    "os_account:os_account_innerkits",
372  ]
373  cflags_cc = [ "-DACCOUNT_TEST" ]
374}
375
376ohos_moduletest("account_command_set_module_test") {
377  branch_protector_ret = "pac_ret"
378
379  sanitize = {
380    cfi = true
381    cfi_cross_dso = true
382    debug = false
383  }
384
385  module_out_path = module_output_path
386
387  include_dirs = [ "${ability_runtime_path}/tools/test/systemtest/aa" ]
388
389  sources = [
390    "${ability_runtime_path}/tools/test/systemtest/aa/tool_system_test.cpp",
391    "${tools_path}/acm/src/account_command.cpp",
392    "account_command_set_module_test.cpp",
393    "account_command_util.cpp",
394  ]
395
396  configs = [
397    "${ability_runtime_path}/interfaces/inner_api/ability_manager:ability_manager_public_config",
398    "${tools_path}/acm:tools_acm_config",
399  ]
400
401  cflags = []
402  if (target_cpu == "arm") {
403    cflags += [ "-DBINDER_IPC_32BIT" ]
404  }
405
406  deps = [
407    "${common_path}:libaccount_common",
408    "${os_account_innerkits_native_path}:os_account_innerkits",
409    "//third_party/googletest:gtest_main",
410  ]
411
412  external_deps = [
413    "ability_base:base",
414    "ability_runtime:tools_aa_source_set",
415    "c_utils:utils",
416    "hilog:libhilog",
417    "ipc:ipc_single",
418    "os_account:os_account_innerkits",
419  ]
420  cflags_cc = [ "-DACCOUNT_TEST" ]
421}
422
423ohos_moduletest("account_command_switch_module_test") {
424  branch_protector_ret = "pac_ret"
425
426  sanitize = {
427    cfi = true
428    cfi_cross_dso = true
429    debug = false
430  }
431
432  module_out_path = module_output_path
433
434  include_dirs = [ "${ability_runtime_path}/tools/test/systemtest/aa" ]
435
436  sources = [
437    "${ability_runtime_path}/tools/test/systemtest/aa/tool_system_test.cpp",
438    "${tools_path}/acm/src/account_command.cpp",
439    "account_command_switch_module_test.cpp",
440    "account_command_util.cpp",
441  ]
442
443  configs = [
444    "${ability_runtime_path}/interfaces/inner_api/ability_manager:ability_manager_public_config",
445    "${tools_path}/acm:tools_acm_config",
446  ]
447
448  cflags = []
449  if (target_cpu == "arm") {
450    cflags += [ "-DBINDER_IPC_32BIT" ]
451  }
452
453  deps = [
454    "${common_path}:libaccount_common",
455    "${os_account_innerkits_native_path}:os_account_innerkits",
456    "//third_party/googletest:gtest_main",
457  ]
458
459  external_deps = [
460    "ability_base:base",
461    "ability_runtime:tools_aa_source_set",
462    "c_utils:utils",
463    "hilog:libhilog",
464    "ipc:ipc_single",
465    "os_account:os_account_innerkits",
466  ]
467  cflags_cc = [ "-DACCOUNT_TEST" ]
468}
469
470group("moduletest") {
471  testonly = true
472  deps = []
473  if (os_account_enable_multiple_os_accounts || use_clang_coverage) {
474    deps += [
475      ":account_command_create_module_mock_test",
476      ":account_command_create_module_test",
477      ":account_command_delete_module_mock_test",
478      ":account_command_delete_module_test",
479      ":account_command_dump_module_test",
480      ":account_command_set_module_test",
481      ":account_command_switch_module_test",
482    ]
483  }
484}
485