• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022-2025 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    "${access_token_path}/frameworks/accesstoken:accesstoken_communication_adapter_cxx/",
36  ]
37
38  configs = [ "//build/config/compiler:exceptions" ]
39
40  deps = [
41    "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
42    "${ability_runtime_path}/frameworks/native/appkit:app_context",
43    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
44  ]
45
46  external_deps = [
47    "ability_base:want",
48    "ability_base:zuri",
49    "ability_runtime:ability_context_native",
50    "ability_runtime:ability_manager",
51    "ability_runtime:app_manager",
52    "ability_runtime:runtime",
53    "ability_runtime:wantagent_innerkits",
54    "access_token:libaccesstoken_sdk",
55    "access_token:libnativetoken",
56    "access_token:libtoken_setproc",
57    "c_utils:utils",
58    "googletest:gmock_main",
59    "googletest:gtest_main",
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    "${user_file_service_path}/interfaces/inner_api/file_access/include",
88    "${user_file_service_path}/services/native/file_access_service/include",
89  ]
90
91  configs = [ "//build/config/compiler:exceptions" ]
92
93  deps = [
94    "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
95    "${ability_runtime_path}/frameworks/native/appkit:app_context",
96    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_ext_base_include",
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    "${user_file_service_path}/services:file_access_service_base_source",
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    "googletest:gmock_main",
116    "googletest:gtest_main",
117    "hilog:libhilog",
118    "ipc:ipc_core",
119    "ipc:rpc",
120    "samgr:samgr_proxy",
121  ]
122
123  defines = [ "private=public" ]
124}
125
126ohos_unittest("external_file_access_management_test") {
127  branch_protector_ret = "pac_ret"
128  sanitize = {
129    integer_overflow = true
130    cfi = true
131    cfi_cross_dso = true
132    debug = false
133  }
134  module_out_path = "user_file_service/tests"
135
136  sources = [
137    "external_file_access_test.cpp",
138    "external_file_access_test_management.cpp",
139    "external_file_access_test_operations.cpp",
140  ]
141
142  include_dirs = [
143    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
144    "${user_file_service_path}/interfaces/inner_api/file_access/include",
145    "${user_file_service_path}/services/native/file_access_service/include",
146  ]
147
148  configs = [ "//build/config/compiler:exceptions" ]
149
150  deps = [
151    "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
152    "${ability_runtime_path}/frameworks/native/appkit:app_context",
153    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_ext_base_include",
154    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
155    "${user_file_service_path}/services:file_access_service",
156    "${user_file_service_path}/services:file_access_service_base_source",
157  ]
158
159  external_deps = [
160    "ability_base:want",
161    "ability_base:zuri",
162    "ability_runtime:ability_context_native",
163    "ability_runtime:ability_manager",
164    "ability_runtime:app_manager",
165    "ability_runtime:runtime",
166    "ability_runtime:wantagent_innerkits",
167    "access_token:libaccesstoken_sdk",
168    "access_token:libnativetoken",
169    "access_token:libtoken_setproc",
170    "bundle_framework:appexecfwk_core",
171    "c_utils:utils",
172    "googletest:gmock_main",
173    "googletest:gtest_main",
174    "hilog:libhilog",
175    "ipc:ipc_core",
176    "ipc:rpc",
177    "samgr:samgr_proxy",
178  ]
179
180  defines = [ "private=public" ]
181}
182
183ohos_unittest("external_file_access_notify_test") {
184  branch_protector_ret = "pac_ret"
185  sanitize = {
186    integer_overflow = true
187    cfi = true
188    cfi_cross_dso = true
189    debug = false
190  }
191  module_out_path = "user_file_service/tests"
192
193  sources = [ "external_notify_test.cpp" ]
194
195  include_dirs = [
196    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
197    "${user_file_service_path}/interfaces/inner_api/file_access/include",
198    "${user_file_service_path}/services/native/file_access_service/include",
199  ]
200
201  configs = [ "//build/config/compiler:exceptions" ]
202
203  deps = [
204    "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
205    "${ability_runtime_path}/frameworks/native/appkit:app_context",
206    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_ext_base_include",
207    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
208    "${user_file_service_path}/services:file_access_service",
209    "${user_file_service_path}/services:file_access_service_base_source",
210  ]
211
212  external_deps = [
213    "ability_base:want",
214    "ability_base:zuri",
215    "ability_runtime:ability_context_native",
216    "ability_runtime:ability_manager",
217    "ability_runtime:app_manager",
218    "ability_runtime:runtime",
219    "ability_runtime:wantagent_innerkits",
220    "access_token:libaccesstoken_sdk",
221    "access_token:libnativetoken",
222    "access_token:libtoken_setproc",
223    "bundle_framework:appexecfwk_core",
224    "c_utils:utils",
225    "googletest:gmock_main",
226    "googletest:gtest_main",
227    "hilog:libhilog",
228    "ipc:ipc_core",
229    "ipc:rpc",
230    "samgr:samgr_proxy",
231  ]
232}
233
234ohos_unittest("abnormal_file_access_test") {
235  branch_protector_ret = "pac_ret"
236  sanitize = {
237    integer_overflow = true
238    cfi = true
239    cfi_cross_dso = true
240    debug = false
241  }
242  module_out_path = "user_file_service/tests"
243
244  sources = [
245    "${user_file_service_path}/interfaces/inner_api/file_access/src/uri_ext.cpp",
246    "abnormal_file_access_test.cpp",
247  ]
248
249  include_dirs = [
250    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
251    "${user_file_service_path}/interfaces/inner_api/file_access/include",
252  ]
253
254  configs = [ "//build/config/compiler:exceptions" ]
255
256  deps = [
257    "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
258    "${ability_runtime_path}/frameworks/native/appkit:app_context",
259    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_ext_base_include",
260    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
261    "${user_file_service_path}/services:file_access_service_base_source",
262  ]
263
264  external_deps = [
265    "ability_base:want",
266    "ability_base:zuri",
267    "ability_runtime:ability_context_native",
268    "ability_runtime:ability_manager",
269    "ability_runtime:app_manager",
270    "ability_runtime:runtime",
271    "ability_runtime:wantagent_innerkits",
272    "access_token:libaccesstoken_sdk",
273    "access_token:libnativetoken",
274    "access_token:libtoken_setproc",
275    "bundle_framework:appexecfwk_core",
276    "c_utils:utils",
277    "googletest:gmock_main",
278    "googletest:gtest_main",
279    "hilog:libhilog",
280    "ipc:ipc_core",
281    "samgr:samgr_proxy",
282  ]
283}
284
285ohos_unittest("file_access_ext_stub_impl_test") {
286  branch_protector_ret = "pac_ret"
287  sanitize = {
288    integer_overflow = true
289    cfi = true
290    cfi_cross_dso = true
291    debug = false
292    blocklist = "${user_file_service_path}/cfi_blocklist.txt"
293  }
294  module_out_path = "user_file_service/tests"
295
296  include_dirs = [
297    "${ability_runtime_napi_path}/inner/napi_common",
298    "${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime",
299    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime",
300    "${user_file_service_path}/interfaces/inner_api/file_access/include",
301    "${user_file_service_path}/interfaces/kits/js/src/common",
302    "${user_file_service_path}/utils",
303    "mock",
304  ]
305
306  sources = [
307    "${user_file_service_path}/interfaces/inner_api/file_access/src/file_access_ext_stub_impl.cpp",
308    "${user_file_service_path}/interfaces/inner_api/file_access/src/uri_ext.cpp",
309    "file_access_ext_stub_impl_test.cpp",
310  ]
311
312  deps = [ "${user_file_service_path}/interfaces/inner_api/file_access:file_access_ext_base_include" ]
313
314  external_deps = [
315    "ability_base:zuri",
316    "ability_runtime:app_context",
317    "ability_runtime:extensionkit_native",
318    "ability_runtime:napi_common",
319    "ability_runtime:runtime",
320    "access_token:libaccesstoken_sdk",
321    "access_token:libnativetoken",
322    "access_token:libtoken_setproc",
323    "c_utils:utils",
324    "googletest:gmock_main",
325    "googletest:gtest_main",
326    "hilog:libhilog",
327    "hitrace:hitrace_meter",
328    "ipc:ipc_core",
329    "napi:ace_napi",
330  ]
331
332  use_exceptions = true
333}
334
335ohos_unittest("js_file_access_ext_ability_test") {
336  branch_protector_ret = "pac_ret"
337  sanitize = {
338    integer_overflow = true
339    cfi = true
340    cfi_cross_dso = true
341    debug = false
342    blocklist = "${user_file_service_path}/cfi_blocklist.txt"
343  }
344  module_out_path = "user_file_service/tests"
345
346  include_dirs = [
347    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
348    "${commonlibrary_path}/c_utils/base/include",
349    "${file_api_path}/utils/filemgmt_libn/include",
350    "${user_file_service_path}/interfaces/inner_api/file_access/include",
351    "${user_file_service_path}/interfaces/inner_api/file_access/src",
352    "${user_file_service_path}/interfaces/kits/js/src/common",
353    "${user_file_service_path}/services/native/file_access_service/include",
354    "${user_file_service_path}/utils",
355    "mock",
356  ]
357
358  sources = [
359    "${user_file_service_path}/interfaces/inner_api/file_access/src/file_access_ext_stub_impl.cpp",
360    "${user_file_service_path}/interfaces/inner_api/file_access/src/napi_common_fileaccess.cpp",
361    "${user_file_service_path}/interfaces/inner_api/file_access/src/uri_ext.cpp",
362    "js_file_access_ext_ability_test.cpp",
363    "mock/js_native_api_mock.cpp",
364  ]
365
366  deps = [
367    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_ext_base_include",
368    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
369    "${user_file_service_path}/services:file_access_service_base_include",
370  ]
371
372  external_deps = [
373    "ability_base:want",
374    "ability_base:zuri",
375    "ability_runtime:app_context",
376    "ability_runtime:extensionkit_native",
377    "ability_runtime:napi_common",
378    "ability_runtime:runtime",
379    "access_token:libaccesstoken_sdk",
380    "bundle_framework:appexecfwk_core",
381    "c_utils:utils",
382    "googletest:gmock_main",
383    "googletest:gtest_main",
384    "hilog:libhilog",
385    "hitrace:hitrace_meter",
386    "init:libbegetutil",
387    "ipc:ipc_core",
388    "napi:ace_napi",
389    "os_account:os_account_innerkits",
390  ]
391
392  defines = [ "private=public" ]
393
394  use_exceptions = true
395}
396
397group("user_file_service_unit_test") {
398  testonly = true
399
400  deps = [
401    ":abnormal_file_access_test",
402    ":external_file_access_basic_test",
403    ":external_file_access_management_test",
404    ":external_file_access_notify_test",
405    ":file_access_ext_stub_impl_test",
406    ":js_file_access_ext_ability_test",
407  ]
408}
409