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/ohos.gni")
15import("//build/test.gni")
16import("../../../../../os_account.gni")
17
18module_output_path = "os_account/services/domain_account"
19
20config("domain_account_service_config_unittest") {
21  visibility = [ ":*" ]
22
23  include_dirs = []
24
25  cflags = []
26  if (target_cpu == "arm") {
27    cflags += [ "-DBINDER_IPC_32BIT" ]
28  }
29
30  defines = [
31    "ACCOUNT_LOG_TAG = \"DomainAccountFwk\"",
32    "LOG_DOMAIN = 0xD001B00",
33  ]
34}
35
36config("domain_account_amgr_mock_config") {
37  include_dirs = [
38    "${domain_account_framework_path}/include",
39    "${domain_account_interfaces_native_path}/include",
40    "${os_account_dfx_path}/hitrace_adapter",
41    "${services_path}/accountmgr/include",
42    "${services_path}/accountmgr/include/account_iam",
43    "${services_path}/accountmgr/include/domain_account",
44    "${services_path}/accountmgr/include/ability_manager_adapter",
45    "${services_path}/accountmgr/test/unittest/domain_account/mock",
46    "${common_path}/log/include",
47    "${domain_account_framework_path}/test/moduletest/include",
48    "${common_path}/perf_stat/include",
49    "${innerkits_common}/include",
50    "${innerkits_path}/include",
51  ]
52}
53
54ohos_unittest("DomainAccountInnerServiceCovTest") {
55  branch_protector_ret = "pac_ret"
56
57  sanitize = {
58    cfi = true
59    cfi_cross_dso = true
60    debug = false
61    blocklist = "${os_account_path}/cfi_blocklist.txt"
62  }
63
64  cflags_cc = []
65  module_out_path = module_output_path
66
67  sources = [
68    "${domain_account_framework_path}/test/moduletest/src/mock_domain_plugin.cpp",
69    "${os_account_dfx_path}/hitrace_adapter/hitrace_adapter.cpp",
70    "${services_path}/accountmgr/src/account_event_provider.cpp",
71    "${services_path}/accountmgr/src/domain_account/domain_account_plugin_death_recipient.cpp",
72    "${services_path}/accountmgr/src/domain_account/domain_has_domain_info_callback.cpp",
73    "${services_path}/accountmgr/src/domain_account/inner_domain_account_manager.cpp",
74    "${services_path}/accountmgr/src/domain_account/status_listener_death_recipient.cpp",
75    "${services_path}/accountmgr/src/domain_account/status_listener_manager.cpp",
76    "${services_path}/accountmgr/test/unittest/domain_account/mock/mock_domain_account_callback_stub.cpp",
77    "${services_path}/accountmgr/test/unittest/domain_account/mock/mock_inner_os_account_manager.cpp",
78    "${services_path}/accountmgr/test/unittest/domain_account/mock/mock_musl.cpp",
79    "domain_account_manager_inner_service_test.cpp",
80  ]
81  configs = [
82    ":domain_account_amgr_mock_config",
83    "${services_path}/accountmgr/test:accountmgr_test_config",
84    "${services_path}/accountmgr/:ability_manager_config",
85  ]
86
87  deps = [
88    "${account_iam_framework_path}:account_iam_innerkits",
89    "${common_path}:libaccount_common",
90    "${domain_account_framework_path}:domain_account_innerkits",
91    "${os_account_innerkits_native_path}:os_account_innerkits",
92    "${services_path}/accountmgr:accountmgr",
93    "//third_party/googletest:gmock_main",
94    "//third_party/googletest:gtest_main",
95  ]
96
97  external_deps = [
98    "ability_base:base",
99    "ability_base:want",
100    "ability_runtime:wantagent_innerkits",
101    "access_token:libaccesstoken_sdk",
102    "c_utils:utils",
103    "hilog:libhilog",
104    "ipc:ipc_single",
105    "json:nlohmann_json_static",
106    "kv_store:distributeddata_inner",
107    "samgr:samgr_proxy",
108  ]
109  if (has_ces_part) {
110    cflags_cc += [ "-DHAS_CES_PART" ]
111    external_deps += [ "common_event_service:cesfwk_innerkits" ]
112  }
113  if (has_hiviewdfx_hisysevent_part) {
114    cflags_cc += [ "-DHAS_HISYSEVENT_PART" ]
115    external_deps += [ "hisysevent:libhisysevent" ]
116  }
117  if (has_user_auth_part) {
118    cflags_cc += [ "-DHAS_USER_AUTH_PART" ]
119    external_deps += [ "user_auth_framework:userauth_client" ]
120  }
121  if (has_hiviewdfx_hitrace_part) {
122    external_deps += [ "hitrace:hitrace_meter" ]
123    cflags_cc += [ "-DHAS_HITRACE_PART" ]
124  }
125
126  part_name = "os_account"
127}
128
129ohos_unittest("domain_account_plugin_proxy_test") {
130  branch_protector_ret = "pac_ret"
131
132  sanitize = {
133    cfi = true
134    cfi_cross_dso = true
135    debug = false
136  }
137
138  module_out_path = module_output_path
139
140  include_dirs = [ "${domain_account_interfaces_native_path}/include" ]
141  sources = [
142    "${services_path}/accountmgr/src/domain_account/domain_account_plugin_proxy.cpp",
143    "${services_path}/accountmgr/src/domain_account/domain_has_domain_info_callback.cpp",
144    "domain_account_plugin_proxy_test.cpp",
145  ]
146  configs = [ ":domain_account_service_config_unittest" ]
147
148  deps = [
149    "${common_path}:libaccount_common",
150    "${domain_account_framework_path}:domain_account_innerkits",
151    "${services_path}/accountmgr:accountmgr",
152    "//third_party/googletest:gmock_main",
153    "//third_party/googletest:gtest_main",
154  ]
155
156  external_deps = [
157    "ability_base:want",
158    "c_utils:utils",
159    "hilog:libhilog",
160    "ipc:ipc_single",
161    "os_account:os_account_innerkits",
162  ]
163}
164
165group("unittest") {
166  testonly = true
167
168  deps = [
169    ":DomainAccountInnerServiceCovTest",
170    ":domain_account_plugin_proxy_test",
171  ]
172}
173