1# Copyright (c) 2022-2024 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("//foundation/filemanagement/user_file_service/filemanagement_aafwk.gni") 16 17ohos_unittest("medialibrary_file_access_test") { 18 branch_protector_ret = "pac_ret" 19 sanitize = { 20 integer_overflow = true 21 cfi = true 22 cfi_cross_dso = true 23 debug = false 24 } 25 module_out_path = "user_file_service/tests" 26 27 sources = [ 28 "medialibrary_file_access_test_basic.cpp", 29 "medialibrary_file_access_test_info.cpp", 30 ] 31 32 include_dirs = [ 33 "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", 34 "${user_file_service_path}/interfaces/inner_api/file_access/include", 35 "//third_party/googletest/googlemock/include/gmock", 36 "${access_token_path}/frameworks/accesstoken:accesstoken_communication_adapter_cxx/", 37 ] 38 39 configs = [ "//build/config/compiler:exceptions" ] 40 41 deps = [ 42 "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", 43 "${ability_runtime_path}/frameworks/native/appkit:app_context", 44 "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit", 45 "//third_party/googletest:gmock_main", 46 ] 47 48 external_deps = [ 49 "ability_base:want", 50 "ability_base:zuri", 51 "ability_runtime:ability_context_native", 52 "ability_runtime:ability_manager", 53 "ability_runtime:app_manager", 54 "ability_runtime:runtime", 55 "ability_runtime:wantagent_innerkits", 56 "access_token:libaccesstoken_sdk", 57 "access_token:libnativetoken", 58 "access_token:libtoken_setproc", 59 "c_utils:utils", 60 "ipc:ipc_core", 61 "ipc:rpc", 62 "samgr:samgr_proxy", 63 ] 64 65 resource_config_file = 66 "${user_file_service_path}/test/unittest/resources/ohos_test.xml" 67} 68 69ohos_unittest("external_file_access_basic_test") { 70 branch_protector_ret = "pac_ret" 71 sanitize = { 72 integer_overflow = true 73 cfi = true 74 cfi_cross_dso = true 75 debug = false 76 } 77 module_out_path = "user_file_service/tests" 78 79 sources = [ 80 "external_file_access_test.cpp", 81 "external_file_access_test_basic.cpp", 82 "external_file_access_test_info.cpp", 83 ] 84 85 include_dirs = [ 86 "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", 87 "//third_party/googletest/googlemock/include/gmock", 88 "${user_file_service_path}/interfaces/inner_api/file_access/include", 89 "${user_file_service_path}/services/native/file_access_service/include", 90 ] 91 92 configs = [ "//build/config/compiler:exceptions" ] 93 94 deps = [ 95 "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", 96 "${ability_runtime_path}/frameworks/native/appkit:app_context", 97 "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit", 98 "${user_file_service_path}/services:file_access_service", 99 "//third_party/googletest:gmock_main", 100 ] 101 102 external_deps = [ 103 "ability_base:want", 104 "ability_base:zuri", 105 "ability_runtime:ability_context_native", 106 "ability_runtime:ability_manager", 107 "ability_runtime:app_manager", 108 "ability_runtime:runtime", 109 "ability_runtime:wantagent_innerkits", 110 "access_token:libaccesstoken_sdk", 111 "access_token:libnativetoken", 112 "access_token:libtoken_setproc", 113 "bundle_framework:appexecfwk_core", 114 "c_utils:utils", 115 "hilog:libhilog", 116 "ipc:ipc_core", 117 "ipc:rpc", 118 "samgr:samgr_proxy", 119 ] 120 121 defines = [ "private=public" ] 122} 123 124ohos_unittest("external_file_access_management_test") { 125 branch_protector_ret = "pac_ret" 126 sanitize = { 127 integer_overflow = true 128 cfi = true 129 cfi_cross_dso = true 130 debug = false 131 } 132 module_out_path = "user_file_service/tests" 133 134 sources = [ 135 "external_file_access_test.cpp", 136 "external_file_access_test_management.cpp", 137 "external_file_access_test_operations.cpp", 138 ] 139 140 include_dirs = [ 141 "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", 142 "//third_party/googletest/googlemock/include/gmock", 143 "${user_file_service_path}/interfaces/inner_api/file_access/include", 144 "${user_file_service_path}/services/native/file_access_service/include", 145 ] 146 147 configs = [ "//build/config/compiler:exceptions" ] 148 149 deps = [ 150 "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", 151 "${ability_runtime_path}/frameworks/native/appkit:app_context", 152 "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit", 153 "${user_file_service_path}/services:file_access_service", 154 "//third_party/googletest:gmock_main", 155 ] 156 157 external_deps = [ 158 "ability_base:want", 159 "ability_base:zuri", 160 "ability_runtime:ability_context_native", 161 "ability_runtime:ability_manager", 162 "ability_runtime:app_manager", 163 "ability_runtime:runtime", 164 "ability_runtime:wantagent_innerkits", 165 "access_token:libaccesstoken_sdk", 166 "access_token:libnativetoken", 167 "access_token:libtoken_setproc", 168 "bundle_framework:appexecfwk_core", 169 "c_utils:utils", 170 "hilog:libhilog", 171 "ipc:ipc_core", 172 "ipc:rpc", 173 "samgr:samgr_proxy", 174 ] 175 176 defines = [ "private=public" ] 177} 178 179ohos_unittest("external_file_access_notify_test") { 180 branch_protector_ret = "pac_ret" 181 sanitize = { 182 integer_overflow = true 183 cfi = true 184 cfi_cross_dso = true 185 debug = false 186 } 187 module_out_path = "user_file_service/tests" 188 189 sources = [ "external_notify_test.cpp" ] 190 191 include_dirs = [ 192 "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", 193 "//third_party/googletest/googlemock/include/gmock", 194 "${user_file_service_path}/interfaces/inner_api/file_access/include", 195 "${user_file_service_path}/services/native/file_access_service/include", 196 ] 197 198 configs = [ "//build/config/compiler:exceptions" ] 199 200 deps = [ 201 "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", 202 "${ability_runtime_path}/frameworks/native/appkit:app_context", 203 "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit", 204 "${user_file_service_path}/services:file_access_service", 205 "//third_party/googletest:gmock_main", 206 ] 207 208 external_deps = [ 209 "ability_base:want", 210 "ability_base:zuri", 211 "ability_runtime:ability_context_native", 212 "ability_runtime:ability_manager", 213 "ability_runtime:app_manager", 214 "ability_runtime:runtime", 215 "ability_runtime:wantagent_innerkits", 216 "access_token:libaccesstoken_sdk", 217 "access_token:libnativetoken", 218 "access_token:libtoken_setproc", 219 "bundle_framework:appexecfwk_core", 220 "c_utils:utils", 221 "hilog:libhilog", 222 "ipc:ipc_core", 223 "ipc:rpc", 224 "samgr:samgr_proxy", 225 ] 226} 227 228ohos_unittest("abnormal_file_access_test") { 229 branch_protector_ret = "pac_ret" 230 sanitize = { 231 integer_overflow = true 232 cfi = true 233 cfi_cross_dso = true 234 debug = false 235 } 236 module_out_path = "user_file_service/tests" 237 238 sources = [ "abnormal_file_access_test.cpp" ] 239 240 include_dirs = [ 241 "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", 242 "//third_party/googletest/googlemock/include/gmock", 243 "${user_file_service_path}/interfaces/inner_api/file_access/include", 244 ] 245 246 configs = [ "//build/config/compiler:exceptions" ] 247 248 deps = [ 249 "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native", 250 "${ability_runtime_path}/frameworks/native/appkit:app_context", 251 "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit", 252 "//third_party/googletest:gmock_main", 253 ] 254 255 external_deps = [ 256 "ability_base:want", 257 "ability_base:zuri", 258 "ability_runtime:ability_context_native", 259 "ability_runtime:ability_manager", 260 "ability_runtime:app_manager", 261 "ability_runtime:runtime", 262 "ability_runtime:wantagent_innerkits", 263 "access_token:libaccesstoken_sdk", 264 "access_token:libnativetoken", 265 "access_token:libtoken_setproc", 266 "bundle_framework:appexecfwk_core", 267 "c_utils:utils", 268 "hilog:libhilog", 269 "ipc:ipc_core", 270 "samgr:samgr_proxy", 271 ] 272} 273 274ohos_unittest("file_access_ext_stub_impl_test") { 275 branch_protector_ret = "pac_ret" 276 sanitize = { 277 integer_overflow = true 278 cfi = true 279 cfi_cross_dso = true 280 debug = false 281 blocklist = "${user_file_service_path}/cfi_blocklist.txt" 282 } 283 module_out_path = "user_file_service/tests" 284 285 include_dirs = [ 286 "${ability_runtime_napi_path}/inner/napi_common", 287 "${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime", 288 "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime", 289 "${user_file_service_path}/interfaces/inner_api/file_access/include", 290 "${user_file_service_path}/interfaces/kits/js/src/common", 291 "${user_file_service_path}/utils", 292 "//third_party/googletest/googlemock/include/gmock", 293 "mock", 294 ] 295 296 sources = [ 297 "${user_file_service_path}/interfaces/inner_api/file_access/src/file_access_ext_stub_impl.cpp", 298 "file_access_ext_stub_impl_test.cpp", 299 ] 300 301 deps = [ "//third_party/googletest:gmock_main" ] 302 303 external_deps = [ 304 "ability_base:zuri", 305 "ability_runtime:app_context", 306 "ability_runtime:extensionkit_native", 307 "ability_runtime:napi_common", 308 "ability_runtime:runtime", 309 "c_utils:utils", 310 "hilog:libhilog", 311 "hitrace:hitrace_meter", 312 "ipc:ipc_core", 313 "napi:ace_napi", 314 ] 315 316 use_exceptions = true 317} 318 319ohos_unittest("file_access_service_proxy_test") { 320 branch_protector_ret = "pac_ret" 321 sanitize = { 322 integer_overflow = true 323 cfi = true 324 cfi_cross_dso = true 325 debug = false 326 blocklist = "${user_file_service_path}/cfi_blocklist.txt" 327 } 328 module_out_path = "user_file_service/tests" 329 330 include_dirs = [ 331 "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", 332 "${user_file_service_path}/interfaces/inner_api/file_access/include", 333 "${user_file_service_path}/services/native/file_access_service/include", 334 "${user_file_service_path}/interfaces/kits/js/src/common", 335 "${user_file_service_path}/utils", 336 "//third_party/googletest/googlemock/include/gmock", 337 "mock", 338 ] 339 340 sources = [ 341 "${user_file_service_path}/services/native/file_access_service/src/file_access_service_proxy.cpp", 342 "file_access_service_proxy_test.cpp", 343 "mock/message_parcel_mock.cpp", 344 "mock/service_registry_mock.cpp", 345 ] 346 347 deps = [ 348 "//third_party/googletest:gmock_main", 349 "//third_party/googletest:gtest_main", 350 ] 351 352 external_deps = [ 353 "ability_base:want", 354 "ability_base:zuri", 355 "ability_runtime:ability_manager", 356 "bundle_framework:appexecfwk_core", 357 "c_utils:utils", 358 "hilog:libhilog", 359 "hitrace:hitrace_meter", 360 "image_framework:image", 361 "ipc:ipc_core", 362 "napi:ace_napi", 363 "safwk:system_ability_fwk", 364 ] 365 366 defines = [ "private=public" ] 367 368 use_exceptions = true 369} 370 371ohos_unittest("js_file_access_ext_ability_test") { 372 branch_protector_ret = "pac_ret" 373 sanitize = { 374 integer_overflow = true 375 cfi = true 376 cfi_cross_dso = true 377 debug = false 378 blocklist = "${user_file_service_path}/cfi_blocklist.txt" 379 } 380 module_out_path = "user_file_service/tests" 381 382 include_dirs = [ 383 "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", 384 "${commonlibrary_path}/c_utils/base/include", 385 "${file_api_path}/utils/filemgmt_libn/include", 386 "${user_file_service_path}/interfaces/inner_api/file_access/include", 387 "${user_file_service_path}/interfaces/inner_api/file_access/src", 388 "${user_file_service_path}/interfaces/kits/js/src/common", 389 "${user_file_service_path}/services/native/file_access_service/include", 390 "${user_file_service_path}/utils", 391 "//third_party/googletest/googlemock/include/gmock", 392 "mock", 393 ] 394 395 sources = [ 396 "${user_file_service_path}/interfaces/inner_api/file_access/src/file_access_ext_stub_impl.cpp", 397 "${user_file_service_path}/interfaces/inner_api/file_access/src/napi_common_fileaccess.cpp", 398 "js_file_access_ext_ability_test.cpp", 399 "mock/js_native_api_mock.cpp", 400 ] 401 402 deps = [ 403 "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit", 404 "//third_party/googletest:gmock_main", 405 "//third_party/googletest:gtest_main", 406 ] 407 408 external_deps = [ 409 "ability_base:want", 410 "ability_base:zuri", 411 "ability_runtime:app_context", 412 "ability_runtime:extensionkit_native", 413 "ability_runtime:napi_common", 414 "ability_runtime:runtime", 415 "access_token:libaccesstoken_sdk", 416 "bundle_framework:appexecfwk_core", 417 "c_utils:utils", 418 "hilog:libhilog", 419 "hitrace:hitrace_meter", 420 "init:libbegetutil", 421 "ipc:ipc_core", 422 "napi:ace_napi", 423 "os_account:os_account_innerkits", 424 ] 425 426 defines = [ "private=public" ] 427 428 use_exceptions = true 429} 430 431group("user_file_service_unit_test") { 432 testonly = true 433 434 deps = [ 435 ":abnormal_file_access_test", 436 ":external_file_access_basic_test", 437 ":external_file_access_management_test", 438 ":external_file_access_notify_test", 439 ":file_access_ext_stub_impl_test", 440 ":file_access_service_proxy_test", 441 ":js_file_access_ext_ability_test", 442 ] 443} 444