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_ability_first_test") {
58  module_out_path = module_output_path
59
60  sources = [ "aa_command_ability_first_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_start_test") {
86  module_out_path = module_output_path
87
88  sources = [ "aa_command_start_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_stop_service_test") {
114  module_out_path = module_output_path
115
116  sources = [ "aa_command_stop_service_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_dump_test") {
142  module_out_path = module_output_path
143
144  sources = [ "aa_command_dump_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_dumpsys_test") {
170  module_out_path = module_output_path
171
172  sources = [ "aa_command_dumpsys_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_stop_test") {
198  module_out_path = module_output_path
199
200  sources = [ "aa_command_force_stop_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_force_timeout_test") {
226  module_out_path = module_output_path
227
228  sources = [ "aa_command_force_timeout_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_test_test") {
254  module_out_path = module_output_path
255
256  sources = [ "aa_command_test_test.cpp" ]
257  sources += tools_aa_mock_sources
258
259  configs = [ ":tools_aa_config_mock" ]
260
261  cflags = []
262  if (target_cpu == "arm") {
263    cflags += [ "-DBINDER_IPC_32BIT" ]
264  }
265
266  deps = [
267    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
268    "${ability_runtime_services_path}/abilitymgr:abilityms",
269    "//third_party/googletest:gmock_main",
270    "//third_party/googletest:gtest_main",
271  ]
272
273  external_deps = [
274    "ability_base:configuration",
275    "bundle_framework:appexecfwk_base",
276    "hilog:libhilog",
277    "ipc:ipc_core",
278  ]
279}
280
281ohos_unittest("aa_command_attach_test") {
282  module_out_path = module_output_path
283
284  sources = [ "aa_command_attach_test.cpp" ]
285
286  configs = [ ":tools_aa_config_mock" ]
287
288  cflags = []
289  if (target_cpu == "arm") {
290    cflags += [ "-DBINDER_IPC_32BIT" ]
291  }
292
293  deps = [
294    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
295    "//third_party/googletest:gtest_main",
296  ]
297
298  external_deps = [
299    "ability_base:configuration",
300    "bundle_framework:appexecfwk_base",
301    "hilog:libhilog",
302    "ipc:ipc_core",
303  ]
304}
305
306print("accessibility_enable = ", accessibility_enable)
307if (accessibility_enable) {
308  ohos_unittest("accessibility_ability_utils_test") {
309    module_out_path = module_output_path
310
311    include_dirs = [ "//third_party/jsoncpp/include" ]
312
313    sources = [
314      "${ability_runtime_path}/tools/aa/src/accessibility_ability_utils.cpp",
315      "accessibility_ability_utils_test.cpp",
316    ]
317
318    cflags = []
319    if (target_cpu == "arm") {
320      cflags += [ "-DBINDER_IPC_32BIT" ]
321    }
322
323    deps = [
324      "${ability_runtime_path}/tools/aa:tools_aa_source_set",
325      "//third_party/googletest:gmock_main",
326    ]
327
328    external_deps = [
329      "access_token:libaccesstoken_sdk",
330      "access_token:libnativetoken",
331      "access_token:libtoken_setproc",
332      "accessibility:accessibility_common",
333      "accessibility:accessibilityclient",
334      "accessibility:accessibilityconfig",
335      "hilog:libhilog",
336    ]
337  }
338}
339group("unittest") {
340  testonly = true
341
342  deps = [
343    ":aa_command_ability_first_test",
344    ":aa_command_attach_test",
345    ":aa_command_dump_test",
346    ":aa_command_dumpsys_test",
347    ":aa_command_force_stop_test",
348    ":aa_command_start_test",
349    ":aa_command_stop_service_test",
350    ":aa_command_test",
351    ":aa_command_test_test",
352  ]
353  if (accessibility_enable) {
354    deps += [ ":accessibility_ability_utils_test" ]
355  }
356  if (ability_command_for_test) {
357    deps += [ ":aa_command_force_timeout_test" ]
358  }
359}
360