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("//foundation/ability/ability_runtime/ability_runtime.gni")
16
17module_output_path = "ability_tools/tools"
18
19config("tools_aa_config_mock") {
20  include_dirs = [
21    "${ability_runtime_path}/tools/test/mock",
22    "//third_party/googletest/googlemock/include",
23  ]
24}
25
26tools_aa_mock_sources =
27    [ "${ability_runtime_path}/tools/test/mock/mock_ability_manager_stub.cpp" ]
28
29ohos_unittest("aa_command_test") {
30  module_out_path = module_output_path
31
32  sources = [ "aa_command_test.cpp" ]
33  sources += tools_aa_mock_sources
34
35  configs = [ ":tools_aa_config_mock" ]
36
37  cflags = []
38  if (target_cpu == "arm") {
39    cflags += [ "-DBINDER_IPC_32BIT" ]
40  }
41
42  deps = [
43    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
44    "${ability_runtime_services_path}/abilitymgr:abilityms",
45    "//third_party/googletest:gmock_main",
46    "//third_party/googletest:gtest_main",
47  ]
48
49  external_deps = [
50    "ability_base:configuration",
51    "bundle_framework:appexecfwk_base",
52    "hilog:libhilog",
53    "ipc:ipc_core",
54  ]
55}
56
57ohos_unittest("aa_command_start_test") {
58  module_out_path = module_output_path
59
60  sources = [ "aa_command_start_test.cpp" ]
61  sources += tools_aa_mock_sources
62
63  configs = [ ":tools_aa_config_mock" ]
64
65  cflags = []
66  if (target_cpu == "arm") {
67    cflags += [ "-DBINDER_IPC_32BIT" ]
68  }
69
70  deps = [
71    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
72    "${ability_runtime_services_path}/abilitymgr:abilityms",
73    "//third_party/googletest:gmock_main",
74    "//third_party/googletest:gtest_main",
75  ]
76
77  external_deps = [
78    "ability_base:configuration",
79    "bundle_framework:appexecfwk_base",
80    "hilog:libhilog",
81    "ipc:ipc_core",
82  ]
83}
84
85ohos_unittest("aa_command_stop_service_test") {
86  module_out_path = module_output_path
87
88  sources = [ "aa_command_stop_service_test.cpp" ]
89  sources += tools_aa_mock_sources
90
91  configs = [ ":tools_aa_config_mock" ]
92
93  cflags = []
94  if (target_cpu == "arm") {
95    cflags += [ "-DBINDER_IPC_32BIT" ]
96  }
97
98  deps = [
99    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
100    "${ability_runtime_services_path}/abilitymgr:abilityms",
101    "//third_party/googletest:gmock_main",
102    "//third_party/googletest:gtest_main",
103  ]
104
105  external_deps = [
106    "ability_base:configuration",
107    "bundle_framework:appexecfwk_base",
108    "hilog:libhilog",
109    "ipc:ipc_core",
110  ]
111}
112
113ohos_unittest("aa_command_dump_test") {
114  module_out_path = module_output_path
115
116  sources = [ "aa_command_dump_test.cpp" ]
117  sources += tools_aa_mock_sources
118
119  configs = [ ":tools_aa_config_mock" ]
120
121  cflags = []
122  if (target_cpu == "arm") {
123    cflags += [ "-DBINDER_IPC_32BIT" ]
124  }
125
126  deps = [
127    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
128    "${ability_runtime_services_path}/abilitymgr:abilityms",
129    "//third_party/googletest:gmock_main",
130    "//third_party/googletest:gtest_main",
131  ]
132
133  external_deps = [
134    "ability_base:configuration",
135    "bundle_framework:appexecfwk_base",
136    "hilog:libhilog",
137    "ipc:ipc_core",
138  ]
139}
140
141ohos_unittest("aa_command_dumpsys_test") {
142  module_out_path = module_output_path
143
144  sources = [ "aa_command_dumpsys_test.cpp" ]
145  sources += tools_aa_mock_sources
146
147  configs = [ ":tools_aa_config_mock" ]
148
149  cflags = []
150  if (target_cpu == "arm") {
151    cflags += [ "-DBINDER_IPC_32BIT" ]
152  }
153
154  deps = [
155    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
156    "${ability_runtime_services_path}/abilitymgr:abilityms",
157    "//third_party/googletest:gmock_main",
158    "//third_party/googletest:gtest_main",
159  ]
160
161  external_deps = [
162    "ability_base:configuration",
163    "bundle_framework:appexecfwk_base",
164    "hilog:libhilog",
165    "ipc:ipc_core",
166  ]
167}
168
169ohos_unittest("aa_command_force_stop_test") {
170  module_out_path = module_output_path
171
172  sources = [ "aa_command_force_stop_test.cpp" ]
173  sources += tools_aa_mock_sources
174
175  configs = [ ":tools_aa_config_mock" ]
176
177  cflags = []
178  if (target_cpu == "arm") {
179    cflags += [ "-DBINDER_IPC_32BIT" ]
180  }
181
182  deps = [
183    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
184    "${ability_runtime_services_path}/abilitymgr:abilityms",
185    "//third_party/googletest:gmock_main",
186    "//third_party/googletest:gtest_main",
187  ]
188
189  external_deps = [
190    "ability_base:configuration",
191    "bundle_framework:appexecfwk_base",
192    "hilog:libhilog",
193    "ipc:ipc_core",
194  ]
195}
196
197ohos_unittest("aa_command_force_timeout_test") {
198  module_out_path = module_output_path
199
200  sources = [ "aa_command_force_timeout_test.cpp" ]
201  sources += tools_aa_mock_sources
202
203  configs = [ ":tools_aa_config_mock" ]
204
205  cflags = []
206  if (target_cpu == "arm") {
207    cflags += [ "-DBINDER_IPC_32BIT" ]
208  }
209
210  deps = [
211    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
212    "${ability_runtime_services_path}/abilitymgr:abilityms",
213    "//third_party/googletest:gmock_main",
214    "//third_party/googletest:gtest_main",
215  ]
216
217  external_deps = [
218    "ability_base:configuration",
219    "bundle_framework:appexecfwk_base",
220    "hilog:libhilog",
221    "ipc:ipc_core",
222  ]
223}
224
225ohos_unittest("aa_command_test_test") {
226  module_out_path = module_output_path
227
228  sources = [ "aa_command_test_test.cpp" ]
229  sources += tools_aa_mock_sources
230
231  configs = [ ":tools_aa_config_mock" ]
232
233  cflags = []
234  if (target_cpu == "arm") {
235    cflags += [ "-DBINDER_IPC_32BIT" ]
236  }
237
238  deps = [
239    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
240    "${ability_runtime_services_path}/abilitymgr:abilityms",
241    "//third_party/googletest:gmock_main",
242    "//third_party/googletest:gtest_main",
243  ]
244
245  external_deps = [
246    "ability_base:configuration",
247    "bundle_framework:appexecfwk_base",
248    "hilog:libhilog",
249    "ipc:ipc_core",
250  ]
251}
252
253ohos_unittest("aa_command_attach_test") {
254  module_out_path = module_output_path
255
256  sources = [ "aa_command_attach_test.cpp" ]
257
258  configs = [ ":tools_aa_config_mock" ]
259
260  cflags = []
261  if (target_cpu == "arm") {
262    cflags += [ "-DBINDER_IPC_32BIT" ]
263  }
264
265  deps = [
266    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
267    "//third_party/googletest:gtest_main",
268  ]
269
270  external_deps = [
271    "ability_base:configuration",
272    "bundle_framework:appexecfwk_base",
273    "hilog:libhilog",
274    "ipc:ipc_core",
275  ]
276}
277
278print("accessibility_enable = ", accessibility_enable)
279if (accessibility_enable) {
280  ohos_unittest("accessibility_ability_utils_test") {
281    module_out_path = module_output_path
282
283    include_dirs = [ "//third_party/jsoncpp/include" ]
284
285    sources = [
286      "${ability_runtime_path}/tools/aa/src/accessibility_ability_utils.cpp",
287      "accessibility_ability_utils_test.cpp",
288    ]
289
290    cflags = []
291    if (target_cpu == "arm") {
292      cflags += [ "-DBINDER_IPC_32BIT" ]
293    }
294
295    deps = [
296      "${ability_runtime_path}/tools/aa:tools_aa_source_set",
297      "//third_party/googletest:gmock_main",
298    ]
299
300    external_deps = [
301      "access_token:libaccesstoken_sdk",
302      "access_token:libnativetoken",
303      "access_token:libtoken_setproc",
304      "accessibility:accessibility_common",
305      "accessibility:accessibilityclient",
306      "accessibility:accessibilityconfig",
307      "hilog:libhilog",
308    ]
309  }
310}
311group("unittest") {
312  testonly = true
313
314  deps = [
315    ":aa_command_attach_test",
316    ":aa_command_dump_test",
317    ":aa_command_dumpsys_test",
318    ":aa_command_force_stop_test",
319    ":aa_command_start_test",
320    ":aa_command_stop_service_test",
321    ":aa_command_test",
322    ":aa_command_test_test",
323  ]
324  if (accessibility_enable) {
325    deps += [ ":accessibility_ability_utils_test" ]
326  }
327  if (ability_command_for_test) {
328    deps += [ ":aa_command_force_timeout_test" ]
329  }
330}
331