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 "${account_test_common}:account_test_common_source_set", 59 "${common_path}:libaccount_common", 60 "${os_account_innerkits_native_path}:os_account_innerkits", 61 "//third_party/googletest:gmock_main", 62 "//third_party/googletest:gtest_main", 63 ] 64 65 external_deps = [ 66 "ability_base:want", 67 "access_token:libaccesstoken_sdk", 68 "access_token:libtokensetproc_shared", 69 "c_utils:utils", 70 "hilog:libhilog", 71 "init:libbegetutil", 72 "ipc:ipc_single", 73 "safwk:system_ability_fwk", 74 "samgr:samgr_proxy", 75 ] 76 cflags_cc = [] 77 if (os_account_multiple_active_accounts) { 78 cflags_cc += [ "-DENABLE_MULTIPLE_ACTIVE_ACCOUNTS" ] 79 } 80 if (os_account_enable_multiple_os_accounts || use_clang_coverage) { 81 cflags_cc += [ "-DENABLE_MULTIPLE_OS_ACCOUNTS" ] 82 } 83 if (os_account_support_deactivate_main_os_account) { 84 cflags_cc += [ "-DSUPPORT_STOP_MAIN_OS_ACCOUNT" ] 85 } 86 if (has_user_auth_part) { 87 cflags_cc += [ "-DHAS_USER_AUTH_PART" ] 88 external_deps += [ "user_auth_framework:userauth_client" ] 89 } 90 if (has_ces_part) { 91 cflags_cc += [ "-DHAS_CES_PART" ] 92 external_deps += [ "common_event_service:cesfwk_innerkits" ] 93 } 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 "${account_test_common}:account_test_common_source_set", 144 "${common_path}:libaccount_common", 145 "${domain_account_framework_path}:domain_account_innerkits", 146 "${innerkits_native_path}:libaccountkits", 147 "${os_account_innerkits_native_path}:os_account_innerkits", 148 "//third_party/googletest:gmock_main", 149 "//third_party/googletest:gtest_main", 150 ] 151 152 use_exceptions = true 153 154 external_deps = [ 155 "ability_base:base", 156 "ability_base:want", 157 "ability_runtime:ability_manager", 158 "ability_runtime:app_manager", 159 "ability_runtime:wantagent_innerkits", 160 "access_token:libaccesstoken_sdk", 161 "access_token:libtokenid_sdk", 162 "access_token:libtokensetproc_shared", 163 "bundle_framework:appexecfwk_base", 164 "bundle_framework:appexecfwk_core", 165 "c_utils:utils", 166 "config_policy:configpolicy_util", 167 "hilog:libhilog", 168 "init:libbegetutil", 169 "ipc:ipc_single", 170 "mbedtls:mbedtls_shared", 171 "safwk:system_ability_fwk", 172 "samgr:samgr_proxy", 173 ] 174 if (has_huks_part) { 175 external_deps += [ "huks:libhukssdk" ] 176 } 177 cflags_cc = [] 178 if (os_account_multiple_active_accounts) { 179 cflags_cc += [ "-DENABLE_MULTIPLE_ACTIVE_ACCOUNTS" ] 180 } 181 if (has_user_auth_part) { 182 cflags_cc += [ "-DHAS_USER_AUTH_PART" ] 183 external_deps += [ "user_auth_framework:userauth_client" ] 184 } 185 if (has_ces_part) { 186 cflags_cc += [ "-DHAS_CES_PART" ] 187 external_deps += [ "common_event_service:cesfwk_innerkits" ] 188 } 189 if (has_kv_store_part) { 190 external_deps += [ "kv_store:distributeddata_inner" ] 191 } 192 cflags_cc += [ "-DACCOUNT_TEST" ] 193 cflags_cc += [ "-DBUNDLE_ADAPTER_MOCK" ] 194 cflags_cc += [ "-DENABLE_MULTIPLE_OS_ACCOUNTS" ] 195 if (os_account_support_deactivate_main_os_account) { 196 cflags_cc += [ "-DSUPPORT_STOP_MAIN_OS_ACCOUNT" ] 197 } 198 part_name = "os_account" 199} 200 201ohos_moduletest("os_account_manager_no_bms_mock_test") { 202 branch_protector_ret = "pac_ret" 203 204 sanitize = { 205 cfi = true 206 cfi_cross_dso = true 207 debug = false 208 } 209 210 module_out_path = module_output_path 211 include_dirs = [ 212 "${app_account_innerkits_native_path}/include", 213 "${os_account_dfx_path}/hidumper_adapter", 214 "${services_path}/accountmgr/include/bundle_manager_adapter", 215 "${services_path}/accountmgr/include/ability_manager_adapter", 216 "${services_path}/accountmgr/include", 217 "${os_account_dfx_path}/hitrace_adapter", 218 "${services_path}/accountmgr/include/account_iam", 219 "${services_path}/accountmgr/include/appaccount", 220 "${services_path}/accountmgr/include/domain_account", 221 "${services_path}/accountmgr/include/osaccount", 222 "${bundle_framework_path}/interfaces/inner_api/appexecfwk_core/include", 223 "${os_account_path}/interfaces/innerkits/ohosaccount/native/include/", 224 ] 225 sources = [ 226 "${app_account_services_path}/test/mock/common/ability_manager_adapter_mock.cpp", 227 "${common_path}/log/src/account_log_wrapper.cpp", 228 "${innerkits_native_path}/src/account_info_parcel.cpp", 229 "${innerkits_native_path}/src/account_proxy.cpp", 230 "${innerkits_native_path}/src/ohos_account_kits.cpp", 231 "${innerkits_native_path}/src/ohos_account_kits_impl.cpp", 232 "${os_account_dfx_path}/hidumper_adapter/account_dump_helper.cpp", 233 "${os_account_dfx_path}/hitrace_adapter/hitrace_adapter.cpp", 234 "${services_path}/accountmgr/src/account_iam/account_iam_callback.cpp", 235 "${services_path}/accountmgr/src/account_iam/account_iam_mgr_stub.cpp", 236 "${services_path}/accountmgr/src/account_iam/account_iam_service.cpp", 237 "${services_path}/accountmgr/src/account_iam/inner_account_iam_manager.cpp", 238 "${services_path}/accountmgr/src/appaccount/app_account_control_manager.cpp", 239 "${services_path}/accountmgr/src/bundle_manager_adapter/bundle_manager_adapter.cpp", 240 "os_account_manager_no_bms_mock_test.cpp", 241 ] 242 sources += account_service_sources 243 configs = [ ":os_account_frameworks_config_unittest" ] 244 245 deps = [ 246 "${account_iam_framework_path}:account_iam_innerkits", 247 "${common_path}:libaccount_common", 248 "${domain_account_framework_path}:domain_account_innerkits", 249 "${innerkits_native_path}:libaccountkits", 250 "${os_account_innerkits_native_path}:os_account_innerkits", 251 "//third_party/googletest:gmock_main", 252 "//third_party/googletest:gtest_main", 253 ] 254 255 use_exceptions = true 256 257 external_deps = [ 258 "ability_base:want", 259 "ability_runtime:ability_manager", 260 "ability_runtime:app_manager", 261 "ability_runtime:wantagent_innerkits", 262 "access_token:libaccesstoken_sdk", 263 "access_token:libtokenid_sdk", 264 "access_token:libtokensetproc_shared", 265 "bundle_framework:appexecfwk_base", 266 "bundle_framework:appexecfwk_core", 267 "c_utils:utils", 268 "config_policy:configpolicy_util", 269 "hilog:libhilog", 270 "init:libbegetutil", 271 "ipc:ipc_single", 272 "mbedtls:mbedtls_shared", 273 "safwk:system_ability_fwk", 274 "samgr:samgr_proxy", 275 ] 276 if (has_huks_part) { 277 external_deps += [ "huks:libhukssdk" ] 278 } 279 cflags_cc = [] 280 if (has_user_auth_part) { 281 cflags_cc += [ "-DHAS_USER_AUTH_PART" ] 282 external_deps += [ "user_auth_framework:userauth_client" ] 283 } 284 if (has_ces_part) { 285 cflags_cc += [ "-DHAS_CES_PART" ] 286 external_deps += [ "common_event_service:cesfwk_innerkits" ] 287 } 288 if (has_kv_store_part) { 289 external_deps += [ "kv_store:distributeddata_inner" ] 290 } 291 cflags_cc += [ "-DACCOUNT_TEST" ] 292 cflags_cc += [ "-DBUNDLE_ADAPTER_MOCK" ] 293 cflags_cc += [ "-DENABLE_MULTIPLE_OS_ACCOUNTS" ] 294 if (os_account_support_deactivate_main_os_account) { 295 cflags_cc += [ "-DSUPPORT_STOP_MAIN_OS_ACCOUNT" ] 296 } 297 part_name = "os_account" 298} 299 300ohos_moduletest("os_account_subscribe_test") { 301 branch_protector_ret = "pac_ret" 302 sanitize = { 303 cfi = true 304 cfi_cross_dso = true 305 debug = false 306 blocklist = "${os_account_path}/cfi_blocklist.txt" 307 } 308 module_out_path = module_output_path 309 sources = [ "os_account_subscribe_test.cpp" ] 310 configs = [ ":os_account_frameworks_config_unittest" ] 311 deps = [ 312 "${account_test_common}:account_test_common_source_set", 313 "${common_path}:libaccount_common", 314 "${os_account_innerkits_native_path}:os_account_innerkits", 315 ] 316 external_deps = [ 317 "googletest:gmock_main", 318 "googletest:gtest_main", 319 "hilog:libhilog", 320 ] 321 cflags_cc = [ "-DACCOUNT_TEST" ] 322 if (os_account_support_deactivate_main_os_account) { 323 cflags_cc += [ "-DSUPPORT_STOP_MAIN_OS_ACCOUNT" ] 324 } 325} 326 327group("moduletest") { 328 testonly = true 329 330 deps = [ 331 ":os_account_frameworks_module_mock_test", 332 ":os_account_frameworks_module_test", 333 ] 334} 335