1# Copyright (c) 2021-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/test.gni") 15import("../../../../../os_account.gni") 16 17module_output_path = "os_account/services/app_account" 18 19config("app_account_service_config_mock") { 20 include_dirs = [ 21 "${app_account_services_path}/test/mock/app_account", 22 "${app_account_services_path}/test/mock/common", 23 ] 24} 25 26config("app_account_service_config_unittest") { 27 visibility = [ ":*" ] 28 29 include_dirs = [] 30 31 cflags = [] 32 if (target_cpu == "arm") { 33 cflags += [ "-DBINDER_IPC_32BIT" ] 34 } 35 36 defines = [ 37 "ACCOUNT_LOG_TAG = \"AppAccountUTest\"", 38 "LOG_DOMAIN = 0xD001B00", 39 ] 40} 41 42ohos_unittest("app_account_data_storage_test") { 43 branch_protector_ret = "pac_ret" 44 45 sanitize = { 46 cfi = true 47 cfi_cross_dso = true 48 debug = false 49 } 50 51 module_out_path = module_output_path 52 53 sources = [ 54 "${app_account_services_path}/test/mock/app_account/accesstoken_kit.cpp", 55 "${app_account_services_path}/test/mock/common/bundle_manager_adapter.cpp", 56 "app_account_data_storage_test.cpp", 57 ] 58 59 configs = [ 60 ":app_account_service_config_mock", 61 ":app_account_service_config_unittest", 62 ] 63 64 deps = [ 65 "${app_account_innerkits_native_path}:app_account_innerkits", 66 "${app_account_services_path}:accountmgr", 67 "${app_account_services_path}/src/appaccount:app_account_service_core", 68 "${common_path}:libaccount_common", 69 "//third_party/googletest:gmock_main", 70 "//third_party/googletest:gtest_main", 71 ] 72 73 external_deps = [ 74 "ability_base:want", 75 "ability_runtime:ability_context_native", 76 "ability_runtime:ability_manager", 77 "ability_runtime:abilitykit_native", 78 "ability_runtime:app_context", 79 "ability_runtime:app_manager", 80 "ability_runtime:runtime", 81 "access_token:libaccesstoken_sdk", 82 "access_token:libtokensetproc_shared", 83 "bundle_framework:appexecfwk_base", 84 "bundle_framework:appexecfwk_core", 85 "c_utils:utils", 86 "hilog:libhilog", 87 "ipc:ipc_single", 88 "kv_store:distributeddata_inner", 89 ] 90} 91 92ohos_unittest("app_account_info_test") { 93 branch_protector_ret = "pac_ret" 94 95 sanitize = { 96 cfi = true 97 cfi_cross_dso = true 98 debug = false 99 } 100 101 module_out_path = module_output_path 102 103 sources = [ "app_account_info_test.cpp" ] 104 105 configs = [ ":app_account_service_config_unittest" ] 106 107 deps = [ 108 "${app_account_innerkits_native_path}:app_account_innerkits", 109 "${common_path}:libaccount_common", 110 "//third_party/googletest:gmock_main", 111 "//third_party/googletest:gtest_main", 112 ] 113 114 external_deps = [ 115 "c_utils:utils", 116 "hilog:libhilog", 117 ] 118} 119 120ohos_unittest("app_account_manager_service_test") { 121 branch_protector_ret = "pac_ret" 122 123 sanitize = { 124 cfi = true 125 cfi_cross_dso = true 126 debug = false 127 } 128 129 module_out_path = module_output_path 130 cflags_cc = [] 131 sources = [ 132 "${app_account_services_path}/src/appaccount/app_account_manager_service.cpp", 133 "${app_account_services_path}/test/mock/app_account/accesstoken_kit.cpp", 134 "${app_account_services_path}/test/mock/app_account/mock_inner_app_account_manager.cpp", 135 "${app_account_services_path}/test/mock/common/bundle_manager_adapter.cpp", 136 "app_account_manager_service_test.cpp", 137 ] 138 139 configs = [ 140 ":app_account_service_config_mock", 141 ":app_account_service_config_unittest", 142 ] 143 144 deps = [ 145 "${app_account_innerkits_native_path}:app_account_innerkits", 146 "${app_account_services_path}:accountmgr", 147 "${app_account_services_path}/src/appaccount:app_account_service_core", 148 "${common_path}:libaccount_common", 149 "//third_party/googletest:gmock_main", 150 "//third_party/googletest:gtest_main", 151 ] 152 153 external_deps = [ 154 "ability_base:base", 155 "ability_base:want", 156 "ability_runtime:app_manager", 157 "access_token:libaccesstoken_sdk", 158 "access_token:libtokensetproc_shared", 159 "bundle_framework:appexecfwk_base", 160 "bundle_framework:appexecfwk_core", 161 "c_utils:utils", 162 "hilog:libhilog", 163 "ipc:ipc_single", 164 "kv_store:distributeddata_inner", 165 ] 166 167 if (has_ces_part) { 168 cflags_cc += [ "-DHAS_CES_PART" ] 169 external_deps += [ "common_event_service:cesfwk_innerkits" ] 170 } 171} 172 173ohos_unittest("app_account_stub_test") { 174 branch_protector_ret = "pac_ret" 175 176 sanitize = { 177 cfi = true 178 cfi_cross_dso = true 179 debug = false 180 } 181 182 module_out_path = module_output_path 183 cflags_cc = [] 184 sources = [ 185 "${app_account_services_path}/src/appaccount/app_account_stub.cpp", 186 "app_account_stub_test.cpp", 187 ] 188 189 configs = [ 190 ":app_account_service_config_mock", 191 ":app_account_service_config_unittest", 192 ] 193 194 deps = [ 195 "${app_account_innerkits_native_path}:app_account_innerkits", 196 "${app_account_services_path}:accountmgr", 197 "${app_account_services_path}/src/appaccount:app_account_service_core", 198 "${common_path}:libaccount_common", 199 "//third_party/googletest:gmock_main", 200 "//third_party/googletest:gtest_main", 201 ] 202 203 external_deps = [ 204 "ability_base:base", 205 "ability_base:want", 206 "ability_runtime:app_manager", 207 "access_token:libaccesstoken_sdk", 208 "access_token:libtokensetproc_shared", 209 "bundle_framework:appexecfwk_base", 210 "bundle_framework:appexecfwk_core", 211 "c_utils:utils", 212 "hilog:libhilog", 213 "ipc:ipc_single", 214 "kv_store:distributeddata_inner", 215 ] 216 217 if (has_ces_part) { 218 cflags_cc += [ "-DHAS_CES_PART" ] 219 external_deps += [ "common_event_service:cesfwk_innerkits" ] 220 } 221} 222 223ohos_unittest("app_account_subscribe_info_test") { 224 branch_protector_ret = "pac_ret" 225 226 sanitize = { 227 cfi = true 228 cfi_cross_dso = true 229 debug = false 230 } 231 232 module_out_path = module_output_path 233 234 sources = [ "app_account_subscribe_info_test.cpp" ] 235 236 configs = [ ":app_account_service_config_unittest" ] 237 238 deps = [ 239 "${app_account_innerkits_native_path}:app_account_innerkits", 240 "${common_path}:libaccount_common", 241 "//third_party/googletest:gmock_main", 242 "//third_party/googletest:gtest_main", 243 ] 244 245 external_deps = [ 246 "c_utils:utils", 247 "hilog:libhilog", 248 ] 249} 250 251ohos_unittest("app_account_test") { 252 branch_protector_ret = "pac_ret" 253 254 sanitize = { 255 cfi = true 256 cfi_cross_dso = true 257 debug = false 258 } 259 260 module_out_path = module_output_path 261 262 sources = [ 263 "${app_account_services_path}/test/mock/app_account/mock_app_account_stub.cpp", 264 "app_account_test.cpp", 265 ] 266 267 configs = [ 268 ":app_account_service_config_mock", 269 ":app_account_service_config_unittest", 270 ] 271 272 deps = [ 273 "${app_account_innerkits_native_path}:app_account_innerkits", 274 "${app_account_services_path}:accountmgr", 275 "${app_account_services_path}/src/appaccount:app_account_service_core", 276 "${common_path}:libaccount_common", 277 "//third_party/googletest:gmock_main", 278 "//third_party/googletest:gtest_main", 279 ] 280 281 external_deps = [ 282 "ability_base:want", 283 "c_utils:utils", 284 "hilog:libhilog", 285 "ipc:ipc_single", 286 ] 287} 288 289group("unittest") { 290 testonly = true 291 292 deps = [ 293 ":app_account_data_storage_test", 294 ":app_account_info_test", 295 ":app_account_manager_service_test", 296 ":app_account_stub_test", 297 ":app_account_subscribe_info_test", 298 ":app_account_test", 299 ] 300} 301