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