• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2025 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/os_account"
18
19ohos_moduletest("account_command_module_mock_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 = [
31    "${app_account_innerkits_native_path}/include",
32    "${os_account_dfx_path}/hidumper_adapter",
33    "${services_path}/accountmgr/include/bundle_manager_adapter",
34    "${services_path}/accountmgr/include/ability_manager_adapter",
35    "${services_path}/accountmgr/include",
36    "${os_account_dfx_path}/hitrace_adapter",
37    "${services_path}/accountmgr/include/account_iam",
38    "${services_path}/accountmgr/include/appaccount",
39    "${services_path}/accountmgr/include/domain_account",
40    "${services_path}/accountmgr/include/osaccount",
41    "${os_account_path}/interfaces/innerkits/ohosaccount/native/include/",
42  ]
43
44  sources = [
45    "${app_account_services_path}/test/mock/common/ability_manager_adapter_mock.cpp",
46    "${app_account_services_path}/test/mock/common/bundle_manager_adapter.cpp",
47    "${common_path}/log/src/account_log_wrapper.cpp",
48    "${innerkits_native_path}/src/ohos_account_kits.cpp",
49    "${innerkits_native_path}/src/ohos_account_kits_impl.cpp",
50    "${os_account_dfx_path}/hidumper_adapter/account_dump_helper.cpp",
51    "${os_account_dfx_path}/hitrace_adapter/hitrace_adapter.cpp",
52    "${services_path}/accountmgr/src/account_iam/account_iam_callback.cpp",
53    "${services_path}/accountmgr/src/account_iam/account_iam_service.cpp",
54    "${services_path}/accountmgr/src/account_iam/inner_account_iam_manager.cpp",
55    "${services_path}/accountmgr/src/appaccount/app_account_control_manager.cpp",
56    "${tools_path}/acm/src/account_command.cpp",
57    "account_command_create_module_test.cpp",
58    "account_command_delete_module_test.cpp",
59    "account_command_util.cpp",
60  ]
61  sources += account_service_sources
62  configs = [
63    "${tools_path}/acm:tools_acm_config",
64    "${app_account_innerkits_native_path}:app_account_interface_public_config",
65  ]
66
67  cflags = []
68  if (target_cpu == "arm") {
69    cflags += [ "-DBINDER_IPC_32BIT" ]
70  }
71
72  deps = [
73    "${account_iam_framework_path}:account_iam_stub",
74    "${account_iam_framework_path}:account_iam_innerkits",
75    "${account_test_common}:account_test_common_source_set",
76    "${common_path}:libaccount_common",
77    "${domain_account_framework_path}:domain_account_innerkits",
78    "${domain_account_framework_path}:domain_account_stub",
79    "${innerkits_native_path}:account_stub",
80    "${innerkits_native_path}:libaccountkits",
81    "${os_account_innerkits_native_path}:os_account_event_proxy",
82    "${os_account_innerkits_native_path}:os_account_innerkits",
83    "${os_account_innerkits_native_path}:os_account_state_reply_callback_proxy",
84    "${os_account_innerkits_native_path}:os_account_state_reply_callback_stub",
85    "${os_account_innerkits_native_path}:os_account_stub",
86  ]
87
88  use_exceptions = true
89
90  external_deps = [
91    "ability_base:want",
92    "ability_runtime:ability_manager",
93    "ability_runtime:app_manager",
94    "ability_runtime:tools_aa_source_set",
95    "ability_runtime:wantagent_innerkits",
96    "access_token:libaccesstoken_sdk",
97    "access_token:libtokenid_sdk",
98    "access_token:libtokensetproc_shared",
99    "bundle_framework:appexecfwk_base",
100    "bundle_framework:appexecfwk_core",
101    "cJSON:cjson",
102    "c_utils:utils",
103    "config_policy:configpolicy_util",
104    "googletest:gmock_main",
105    "googletest:gtest_main",
106    "hilog:libhilog",
107    "ipc:ipc_single",
108    "openssl:libcrypto_shared",
109    "safwk:system_ability_fwk",
110    "samgr:samgr_proxy",
111  ]
112  cflags_cc = []
113  if (use_libfuzzer) {
114    cflags_cc += [ "-DFUZZ_TEST" ]
115  }
116  if (has_storage_service_part) {
117    external_deps += [ "storage_service:storage_manager_sa_proxy" ]
118  }
119  if (os_account_support_lock_os_account) {
120    cflags_cc += [ "-DSUPPORT_LOCK_OS_ACCOUNT" ]
121  }
122  if (os_account_distributed_feature) {
123    cflags_cc += [ "-DENABLE_FILE_WATCHER" ]
124    sources +=
125        [ "${services_path}/accountmgr/src/account_file_watcher_manager.cpp" ]
126    if (has_huks_part) {
127      external_deps += [ "huks:libhukssdk" ]
128      cflags_cc += [ "-DHAS_HUKS_PART" ]
129    }
130  }
131  if (has_user_auth_part) {
132    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
133    external_deps += [ "user_auth_framework:userauth_client" ]
134  }
135  if (has_ces_part) {
136    cflags_cc += [ "-DHAS_CES_PART" ]
137    external_deps += [ "common_event_service:cesfwk_innerkits" ]
138  }
139  if (has_kv_store_part) {
140    external_deps += [ "kv_store:distributeddata_inner" ]
141  }
142  cflags_cc += [ "-DACCOUNT_TEST" ]
143  cflags_cc += [ "-DBUNDLE_ADAPTER_MOCK" ]
144  if (os_account_support_domain_accounts) {
145    cflags_cc += [ "-DSUPPORT_DOMAIN_ACCOUNTS" ]
146    deps += [ "${domain_account_framework_path}:domain_account_plugin_proxy" ]
147  }
148}
149
150ohos_moduletest("account_command_module_test") {
151  branch_protector_ret = "pac_ret"
152
153  sanitize = {
154    cfi = true
155    cfi_cross_dso = true
156    debug = false
157  }
158
159  module_out_path = module_output_path
160
161  sources = [
162    "${tools_path}/acm/src/account_command.cpp",
163    "account_command_create_module_test.cpp",
164    "account_command_delete_module_test.cpp",
165    "account_command_dump_module_test.cpp",
166    "account_command_set_module_test.cpp",
167    "account_command_switch_module_test.cpp",
168    "account_command_util.cpp",
169  ]
170
171  configs = [ "${tools_path}/acm:tools_acm_config" ]
172
173  cflags = []
174  if (target_cpu == "arm") {
175    cflags += [ "-DBINDER_IPC_32BIT" ]
176  }
177
178  deps = [
179    "${account_test_common}:account_test_common_source_set",
180    "${common_path}:libaccount_common",
181    "${os_account_innerkits_native_path}:os_account_innerkits",
182  ]
183
184  external_deps = [
185    "ability_base:base",
186    "ability_runtime:ability_manager",
187    "ability_runtime:tools_aa_source_set",
188    "c_utils:utils",
189    "googletest:gmock_main",
190    "googletest:gtest_main",
191    "hilog:libhilog",
192    "ipc:ipc_single",
193  ]
194  cflags_cc = [ "-DACCOUNT_TEST" ]
195  if (os_account_distributed_feature) {
196    cflags_cc += [ "-DENABLE_FILE_WATCHER" ]
197  }
198}
199
200group("moduletest") {
201  testonly = true
202  deps = []
203  if (os_account_enable_multiple_os_accounts || use_clang_coverage) {
204    deps += [
205      ":account_command_module_mock_test",
206      ":account_command_module_test",
207    ]
208  }
209}
210