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/frameworks/os_account"
18
19config("os_account_frameworks_config_unittest") {
20  visibility = [ ":*" ]
21
22  include_dirs = [
23    "${innerkits_path}/include",
24    "${innerkits_native_path}/include",
25  ]
26
27  cflags = []
28  if (target_cpu == "arm") {
29    cflags += [ "-DBINDER_IPC_32BIT" ]
30  }
31
32  defines = [
33    "ACCOUNT_LOG_TAG = \"OsAccountMTestFwk\"",
34    "LOG_DOMAIN = 0xD001B00",
35  ]
36}
37
38ohos_moduletest("os_account_frameworks_module_test") {
39  branch_protector_ret = "pac_ret"
40
41  sanitize = {
42    cfi = true
43    cfi_cross_dso = true
44    debug = false
45    blocklist = "${os_account_path}/cfi_blocklist.txt"
46  }
47
48  module_out_path = module_output_path
49
50  sources = [
51    "${innerkits_native_path}/src/account_info_parcel.cpp",
52    "${innerkits_native_path}/src/account_proxy.cpp",
53    "os_account_manager_module_test.cpp",
54  ]
55  configs = [ ":os_account_frameworks_config_unittest" ]
56
57  deps = [
58    "${common_path}:libaccount_common",
59    "${os_account_innerkits_native_path}:os_account_innerkits",
60    "//third_party/googletest:gmock_main",
61    "//third_party/googletest:gtest_main",
62  ]
63
64  external_deps = [
65    "ability_base:want",
66    "access_token:libaccesstoken_sdk",
67    "access_token:libtokensetproc_shared",
68    "c_utils:utils",
69    "hilog:libhilog",
70    "init:libbegetutil",
71    "ipc:ipc_single",
72    "safwk:system_ability_fwk",
73    "samgr:samgr_proxy",
74  ]
75  cflags_cc = []
76  if (os_account_multiple_active_accounts) {
77    cflags_cc += [ "-DENABLE_MULTIPLE_ACTIVE_ACCOUNTS" ]
78  }
79  if (os_account_enable_multiple_os_accounts || use_clang_coverage) {
80    cflags_cc += [ "-DENABLE_MULTIPLE_OS_ACCOUNTS" ]
81  }
82  if (os_account_support_deactivate_main_os_account) {
83    cflags_cc += [ "-DSUPPORT_STOP_MAIN_OS_ACCOUNT" ]
84  }
85  if (has_user_auth_part) {
86    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
87    external_deps += [ "user_auth_framework:userauth_client" ]
88  }
89  if (has_ces_part) {
90    cflags_cc += [ "-DHAS_CES_PART" ]
91    external_deps += [ "common_event_service:cesfwk_innerkits" ]
92  }
93  cflags_cc += [ "-DACCOUNT_TEST" ]
94}
95
96ohos_moduletest("os_account_frameworks_module_mock_test") {
97  branch_protector_ret = "pac_ret"
98
99  sanitize = {
100    cfi = true
101    cfi_cross_dso = true
102    debug = false
103    blocklist = "${os_account_path}/cfi_blocklist.txt"
104  }
105
106  module_out_path = module_output_path
107  include_dirs = [
108    "${app_account_innerkits_native_path}/include",
109    "${os_account_dfx_path}/hidumper_adapter",
110    "${services_path}/accountmgr/include/bundle_manager_adapter",
111    "${services_path}/accountmgr/include/ability_manager_adapter",
112    "${services_path}/accountmgr/include",
113    "${os_account_dfx_path}/hitrace_adapter",
114    "${services_path}/accountmgr/include/account_iam",
115    "${services_path}/accountmgr/include/appaccount",
116    "${services_path}/accountmgr/include/domain_account",
117    "${services_path}/accountmgr/include/osaccount",
118    "${bundle_framework_path}/interfaces/inner_api/appexecfwk_core/include",
119    "${os_account_path}/interfaces/innerkits/ohosaccount/native/include/",
120  ]
121  sources = [
122    "${app_account_services_path}/test/mock/common/ability_manager_adapter_mock.cpp",
123    "${app_account_services_path}/test/mock/common/bundle_manager_adapter.cpp",
124    "${common_path}/log/src/account_log_wrapper.cpp",
125    "${innerkits_native_path}/src/account_info_parcel.cpp",
126    "${innerkits_native_path}/src/account_proxy.cpp",
127    "${innerkits_native_path}/src/ohos_account_kits.cpp",
128    "${innerkits_native_path}/src/ohos_account_kits_impl.cpp",
129    "${os_account_dfx_path}/hidumper_adapter/account_dump_helper.cpp",
130    "${os_account_dfx_path}/hitrace_adapter/hitrace_adapter.cpp",
131    "${services_path}/accountmgr/src/account_iam/account_iam_callback.cpp",
132    "${services_path}/accountmgr/src/account_iam/account_iam_mgr_stub.cpp",
133    "${services_path}/accountmgr/src/account_iam/account_iam_service.cpp",
134    "${services_path}/accountmgr/src/account_iam/inner_account_iam_manager.cpp",
135    "${services_path}/accountmgr/src/appaccount/app_account_control_manager.cpp",
136    "os_account_manager_module_test.cpp",
137  ]
138  sources += account_service_sources
139  configs = [ ":os_account_frameworks_config_unittest" ]
140
141  deps = [
142    "${account_iam_framework_path}:account_iam_innerkits",
143    "${common_path}:libaccount_common",
144    "${domain_account_framework_path}:domain_account_innerkits",
145    "${innerkits_native_path}:libaccountkits",
146    "${os_account_innerkits_native_path}:os_account_innerkits",
147    "//third_party/googletest:gmock_main",
148    "//third_party/googletest:gtest_main",
149  ]
150
151  use_exceptions = true
152
153  external_deps = [
154    "ability_base:base",
155    "ability_base:want",
156    "ability_runtime:ability_manager",
157    "ability_runtime:app_manager",
158    "ability_runtime:wantagent_innerkits",
159    "access_token:libaccesstoken_sdk",
160    "access_token:libtokenid_sdk",
161    "access_token:libtokensetproc_shared",
162    "bundle_framework:appexecfwk_base",
163    "bundle_framework:appexecfwk_core",
164    "c_utils:utils",
165    "config_policy:configpolicy_util",
166    "hilog:libhilog",
167    "init:libbegetutil",
168    "ipc:ipc_single",
169    "mbedtls:mbedtls_shared",
170    "safwk:system_ability_fwk",
171    "samgr:samgr_proxy",
172  ]
173  if (has_huks_part) {
174    external_deps += [ "huks:libhukssdk" ]
175  }
176  cflags_cc = []
177  if (os_account_multiple_active_accounts) {
178    cflags_cc += [ "-DENABLE_MULTIPLE_ACTIVE_ACCOUNTS" ]
179  }
180  if (has_user_auth_part) {
181    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
182    external_deps += [ "user_auth_framework:userauth_client" ]
183  }
184  if (has_ces_part) {
185    cflags_cc += [ "-DHAS_CES_PART" ]
186    external_deps += [ "common_event_service:cesfwk_innerkits" ]
187  }
188  if (has_kv_store_part) {
189    external_deps += [ "kv_store:distributeddata_inner" ]
190  }
191  cflags_cc += [ "-DACCOUNT_TEST" ]
192  cflags_cc += [ "-DBUNDLE_ADAPTER_MOCK" ]
193  cflags_cc += [ "-DENABLE_MULTIPLE_OS_ACCOUNTS" ]
194  if (os_account_support_deactivate_main_os_account) {
195    cflags_cc += [ "-DSUPPORT_STOP_MAIN_OS_ACCOUNT" ]
196  }
197  part_name = "os_account"
198}
199
200ohos_moduletest("os_account_manager_no_bms_mock_test") {
201  branch_protector_ret = "pac_ret"
202
203  sanitize = {
204    cfi = true
205    cfi_cross_dso = true
206    debug = false
207  }
208
209  module_out_path = module_output_path
210  include_dirs = [
211    "${app_account_innerkits_native_path}/include",
212    "${os_account_dfx_path}/hidumper_adapter",
213    "${services_path}/accountmgr/include/bundle_manager_adapter",
214    "${services_path}/accountmgr/include/ability_manager_adapter",
215    "${services_path}/accountmgr/include",
216    "${os_account_dfx_path}/hitrace_adapter",
217    "${services_path}/accountmgr/include/account_iam",
218    "${services_path}/accountmgr/include/appaccount",
219    "${services_path}/accountmgr/include/domain_account",
220    "${services_path}/accountmgr/include/osaccount",
221    "${bundle_framework_path}/interfaces/inner_api/appexecfwk_core/include",
222    "${os_account_path}/interfaces/innerkits/ohosaccount/native/include/",
223  ]
224  sources = [
225    "${app_account_services_path}/test/mock/common/ability_manager_adapter_mock.cpp",
226    "${common_path}/log/src/account_log_wrapper.cpp",
227    "${innerkits_native_path}/src/account_info_parcel.cpp",
228    "${innerkits_native_path}/src/account_proxy.cpp",
229    "${innerkits_native_path}/src/ohos_account_kits.cpp",
230    "${innerkits_native_path}/src/ohos_account_kits_impl.cpp",
231    "${os_account_dfx_path}/hidumper_adapter/account_dump_helper.cpp",
232    "${os_account_dfx_path}/hitrace_adapter/hitrace_adapter.cpp",
233    "${services_path}/accountmgr/src/account_iam/account_iam_callback.cpp",
234    "${services_path}/accountmgr/src/account_iam/account_iam_mgr_stub.cpp",
235    "${services_path}/accountmgr/src/account_iam/account_iam_service.cpp",
236    "${services_path}/accountmgr/src/account_iam/inner_account_iam_manager.cpp",
237    "${services_path}/accountmgr/src/appaccount/app_account_control_manager.cpp",
238    "${services_path}/accountmgr/src/bundle_manager_adapter/bundle_manager_adapter.cpp",
239    "os_account_manager_no_bms_mock_test.cpp",
240  ]
241  sources += account_service_sources
242  configs = [ ":os_account_frameworks_config_unittest" ]
243
244  deps = [
245    "${account_iam_framework_path}:account_iam_innerkits",
246    "${common_path}:libaccount_common",
247    "${domain_account_framework_path}:domain_account_innerkits",
248    "${innerkits_native_path}:libaccountkits",
249    "${os_account_innerkits_native_path}:os_account_innerkits",
250    "//third_party/googletest:gmock_main",
251    "//third_party/googletest:gtest_main",
252  ]
253
254  use_exceptions = true
255
256  external_deps = [
257    "ability_base:want",
258    "ability_runtime:ability_manager",
259    "ability_runtime:app_manager",
260    "ability_runtime:wantagent_innerkits",
261    "access_token:libaccesstoken_sdk",
262    "access_token:libtokenid_sdk",
263    "access_token:libtokensetproc_shared",
264    "bundle_framework:appexecfwk_base",
265    "bundle_framework:appexecfwk_core",
266    "c_utils:utils",
267    "config_policy:configpolicy_util",
268    "hilog:libhilog",
269    "init:libbegetutil",
270    "ipc:ipc_single",
271    "mbedtls:mbedtls_shared",
272    "safwk:system_ability_fwk",
273    "samgr:samgr_proxy",
274  ]
275  if (has_huks_part) {
276    external_deps += [ "huks:libhukssdk" ]
277  }
278  cflags_cc = []
279  if (has_user_auth_part) {
280    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
281    external_deps += [ "user_auth_framework:userauth_client" ]
282  }
283  if (has_ces_part) {
284    cflags_cc += [ "-DHAS_CES_PART" ]
285    external_deps += [ "common_event_service:cesfwk_innerkits" ]
286  }
287  if (has_kv_store_part) {
288    external_deps += [ "kv_store:distributeddata_inner" ]
289  }
290  cflags_cc += [ "-DACCOUNT_TEST" ]
291  cflags_cc += [ "-DBUNDLE_ADAPTER_MOCK" ]
292  cflags_cc += [ "-DENABLE_MULTIPLE_OS_ACCOUNTS" ]
293  if (os_account_support_deactivate_main_os_account) {
294    cflags_cc += [ "-DSUPPORT_STOP_MAIN_OS_ACCOUNT" ]
295  }
296  part_name = "os_account"
297}
298
299group("moduletest") {
300  testonly = true
301
302  deps = [
303    ":os_account_frameworks_module_mock_test",
304    ":os_account_frameworks_module_test",
305  ]
306}
307