• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    cfi = true
21    cfi_cross_dso = true
22    debug = false
23  }
24  module_out_path = "user_file_service/tests"
25
26  sources = [ "medialibrary_file_access_test.cpp" ]
27
28  include_dirs = [
29    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
30    "${user_file_service_path}/interfaces/inner_api/file_access/include",
31    "//third_party/googletest/googlemock/include/gmock",
32    "${access_token_path}/frameworks/accesstoken:accesstoken_communication_adapter_cxx/",
33  ]
34
35  configs = [ "//build/config/compiler:exceptions" ]
36
37  deps = [
38    "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
39    "${ability_runtime_path}/frameworks/native/appkit:app_context",
40    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
41    "//third_party/googletest:gmock_main",
42  ]
43
44  external_deps = [
45    "ability_base:want",
46    "ability_base:zuri",
47    "ability_runtime:ability_context_native",
48    "ability_runtime:ability_manager",
49    "ability_runtime:app_manager",
50    "ability_runtime:runtime",
51    "ability_runtime:wantagent_innerkits",
52    "access_token:libaccesstoken_sdk",
53    "access_token:libnativetoken",
54    "access_token:libtoken_setproc",
55    "c_utils:utils",
56    "ipc:ipc_core",
57    "ipc:ipc_js",
58    "samgr:samgr_proxy",
59  ]
60
61  resource_config_file =
62      "${user_file_service_path}/test/unittest/resources/ohos_test.xml"
63}
64
65ohos_unittest("external_file_access_test") {
66  branch_protector_ret = "pac_ret"
67  sanitize = {
68    cfi = true
69    cfi_cross_dso = true
70    debug = false
71  }
72  module_out_path = "user_file_service/tests"
73
74  sources = [
75    "external_file_access_test.cpp",
76    "external_notify_test.cpp",
77  ]
78
79  include_dirs = [
80    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
81    "//third_party/googletest/googlemock/include/gmock",
82    "${user_file_service_path}/interfaces/inner_api/file_access/include",
83    "${user_file_service_path}/services/native/file_access_service/include",
84  ]
85
86  configs = [ "//build/config/compiler:exceptions" ]
87
88  deps = [
89    "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
90    "${ability_runtime_path}/frameworks/native/appkit:app_context",
91    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
92    "${user_file_service_path}/services:file_access_service",
93    "//third_party/googletest:gmock_main",
94  ]
95
96  external_deps = [
97    "ability_base:want",
98    "ability_base:zuri",
99    "ability_runtime:ability_context_native",
100    "ability_runtime:ability_manager",
101    "ability_runtime:app_manager",
102    "ability_runtime:runtime",
103    "ability_runtime:wantagent_innerkits",
104    "access_token:libaccesstoken_sdk",
105    "access_token:libnativetoken",
106    "access_token:libtoken_setproc",
107    "bundle_framework:appexecfwk_core",
108    "c_utils:utils",
109    "hilog:libhilog",
110    "ipc:ipc_core",
111    "ipc:ipc_js",
112    "samgr:samgr_proxy",
113  ]
114}
115
116ohos_unittest("abnormal_file_access_test") {
117  branch_protector_ret = "pac_ret"
118  sanitize = {
119    cfi = true
120    cfi_cross_dso = true
121    debug = false
122  }
123  module_out_path = "user_file_service/tests"
124
125  sources = [ "abnormal_file_access_test.cpp" ]
126
127  include_dirs = [
128    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
129    "//third_party/googletest/googlemock/include/gmock",
130    "${user_file_service_path}/interfaces/inner_api/file_access/include",
131  ]
132
133  configs = [ "//build/config/compiler:exceptions" ]
134
135  deps = [
136    "${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
137    "${ability_runtime_path}/frameworks/native/appkit:app_context",
138    "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
139    "//third_party/googletest:gmock_main",
140  ]
141
142  external_deps = [
143    "ability_base:want",
144    "ability_base:zuri",
145    "ability_runtime:ability_context_native",
146    "ability_runtime:ability_manager",
147    "ability_runtime:app_manager",
148    "ability_runtime:runtime",
149    "ability_runtime:wantagent_innerkits",
150    "access_token:libaccesstoken_sdk",
151    "access_token:libnativetoken",
152    "access_token:libtoken_setproc",
153    "bundle_framework:appexecfwk_core",
154    "c_utils:utils",
155    "hilog:libhilog",
156    "ipc:ipc_core",
157    "samgr:samgr_proxy",
158  ]
159}
160
161ohos_unittest("file_access_ext_stub_impl_test") {
162  module_out_path = "user_file_service/tests"
163
164  include_dirs = [
165    "${ability_runtime_napi_path}/inner/napi_common",
166    "${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime",
167    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime",
168    "${user_file_service_path}/interfaces/inner_api/file_access/include",
169    "${user_file_service_path}/interfaces/kits/js/src/common",
170    "${user_file_service_path}/utils",
171    "//third_party/googletest/googlemock/include/gmock",
172    "mock",
173  ]
174
175  sources = [
176    "${user_file_service_path}/interfaces/inner_api/file_access/src/file_access_ext_stub_impl.cpp",
177    "file_access_ext_stub_impl_test.cpp",
178  ]
179
180  deps = [ "//third_party/googletest:gmock_main" ]
181
182  external_deps = [
183    "ability_base:zuri",
184    "ability_runtime:app_context",
185    "ability_runtime:extensionkit_native",
186    "ability_runtime:napi_common",
187    "ability_runtime:runtime",
188    "c_utils:utils",
189    "hilog:libhilog",
190    "hitrace:hitrace_meter",
191    "ipc:ipc_core",
192    "napi:ace_napi",
193  ]
194
195  use_exceptions = true
196}
197
198ohos_unittest("file_access_service_proxy_test") {
199  module_out_path = "user_file_service/tests"
200
201  include_dirs = [
202    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
203    "${user_file_service_path}/interfaces/inner_api/file_access/include",
204    "${user_file_service_path}/services/native/file_access_service/include",
205    "${user_file_service_path}/interfaces/kits/js/src/common",
206    "${user_file_service_path}/utils",
207    "//third_party/googletest/googlemock/include/gmock",
208    "mock",
209  ]
210
211  sources = [
212    "${user_file_service_path}/services/native/file_access_service/src/file_access_service_proxy.cpp",
213    "file_access_service_proxy_test.cpp",
214    "mock/message_parcel_mock.cpp",
215    "mock/service_registry_mock.cpp",
216  ]
217
218  deps = [
219    "//third_party/googletest:gmock_main",
220    "//third_party/googletest:gtest_main",
221  ]
222
223  external_deps = [
224    "ability_base:want",
225    "ability_base:zuri",
226    "ability_runtime:ability_manager",
227    "bundle_framework:appexecfwk_core",
228    "c_utils:utils",
229    "hilog:libhilog",
230    "hitrace:hitrace_meter",
231    "image_framework:image",
232    "ipc:ipc_core",
233    "napi:ace_napi",
234    "safwk:system_ability_fwk",
235  ]
236
237  defines = [ "private=public" ]
238
239  use_exceptions = true
240}
241
242ohos_unittest("js_file_access_ext_ability_test") {
243  module_out_path = "user_file_service/tests"
244
245  include_dirs = [
246    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
247    "${commonlibrary_path}/c_utils/base/include",
248    "${file_api_path}/utils/filemgmt_libn/include",
249    "${user_file_service_path}/interfaces/inner_api/file_access/include",
250    "${user_file_service_path}/interfaces/kits/js/src/common",
251    "${user_file_service_path}/services/native/file_access_service/include",
252    "${user_file_service_path}/utils",
253    "//third_party/googletest/googlemock/include/gmock",
254    "mock",
255  ]
256
257  sources = [
258    "${user_file_service_path}/interfaces/inner_api/file_access/src/file_access_ext_stub_impl.cpp",
259    "${user_file_service_path}/interfaces/inner_api/file_access/src/js_file_access_ext_ability.cpp",
260    "${user_file_service_path}/interfaces/inner_api/file_access/src/napi_common_fileaccess.cpp",
261    "js_file_access_ext_ability_test.cpp",
262    "mock/js_native_api_mock.cpp",
263  ]
264
265  deps = [
266    "//third_party/googletest:gmock_main",
267    "//third_party/googletest:gtest_main",
268  ]
269
270  external_deps = [
271    "ability_base:zuri",
272    "ability_runtime:app_context",
273    "ability_runtime:extensionkit_native",
274    "ability_runtime:napi_common",
275    "ability_runtime:runtime",
276    "access_token:libaccesstoken_sdk",
277    "bundle_framework:appexecfwk_core",
278    "c_utils:utils",
279    "hilog:libhilog",
280    "hitrace:hitrace_meter",
281    "init:libbegetutil",
282    "ipc:ipc_core",
283    "napi:ace_napi",
284    "os_account:os_account_innerkits",
285  ]
286
287  defines = [ "private=public" ]
288
289  use_exceptions = true
290}
291
292group("user_file_service_unit_test") {
293  testonly = true
294
295  deps = [
296    ":abnormal_file_access_test",
297    ":external_file_access_test",
298    ":file_access_ext_stub_impl_test",
299    ":file_access_service_proxy_test",
300    ":js_file_access_ext_ability_test",
301  ]
302}
303