1# Copyright (c) 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
19ability_delegator_mock_sources =
20    [ "${ability_runtime_path}/tools/test/mock/mock_ability_manager_stub.cpp" ]
21
22config("tools_ability_delegator_config") {
23  include_dirs = [
24    "${ability_runtime_path}/tools/test/mock",
25    "//third_party/googletest/googlemock/include",
26    "${ability_runtime_path}/tools/aa/include",
27  ]
28}
29
30ohos_unittest("ability_command_test") {
31  module_out_path = module_output_path
32
33  configs = [ ":tools_ability_delegator_config" ]
34
35  sources = [ "ability_command_test.cpp" ]
36  sources += ability_delegator_mock_sources
37
38  deps = [
39    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
40    "${ability_runtime_services_path}/abilitymgr:abilityms",
41    "//third_party/googletest:gmock_main",
42    "//third_party/googletest:gtest_main",
43  ]
44
45  external_deps = [
46    "ability_base:configuration",
47    "bundle_framework:appexecfwk_base",
48    "hilog:libhilog",
49    "ipc:ipc_core",
50  ]
51}
52
53ohos_unittest("test_observer_test") {
54  module_out_path = module_output_path
55
56  configs = [ ":tools_ability_delegator_config" ]
57
58  sources = [ "test_observer_test.cpp" ]
59  sources += ability_delegator_mock_sources
60
61  deps = [
62    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
63    "${ability_runtime_services_path}/abilitymgr:abilityms",
64    "//third_party/googletest:gmock_main",
65    "//third_party/googletest:gtest_main",
66  ]
67
68  external_deps = [
69    "ability_base:configuration",
70    "bundle_framework:appexecfwk_base",
71    "hilog:libhilog",
72    "ipc:ipc_core",
73  ]
74}
75
76ohos_unittest("test_observer_proxy_test") {
77  module_out_path = module_output_path
78
79  sources = [ "test_observer_proxy_test.cpp" ]
80
81  deps = [
82    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
83    "//third_party/googletest:gmock_main",
84    "//third_party/googletest:gtest_main",
85  ]
86
87  external_deps = [
88    "hilog:libhilog",
89    "ipc:ipc_core",
90  ]
91}
92
93ohos_unittest("test_observer_stub_test") {
94  module_out_path = module_output_path
95
96  sources = [
97    "mock_test_observer_stub.cpp",
98    "test_observer_stub_test.cpp",
99  ]
100
101  deps = [
102    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
103    "//third_party/googletest:gmock_main",
104    "//third_party/googletest:gtest_main",
105  ]
106
107  external_deps = [
108    "hilog:libhilog",
109    "ipc:ipc_core",
110  ]
111}
112
113ohos_unittest("shell_command_result_test") {
114  module_out_path = module_output_path
115
116  sources = [ "shell_command_result_test.cpp" ]
117
118  configs = [ ":tools_ability_delegator_config" ]
119
120  deps = [
121    "${ability_runtime_path}/tools/aa:tools_aa_source_set",
122    "//third_party/googletest:gmock_main",
123    "//third_party/googletest:gtest_main",
124  ]
125
126  external_deps = [
127    "ability_base:configuration",
128    "bundle_framework:appexecfwk_base",
129    "hilog:libhilog",
130    "ipc:ipc_core",
131  ]
132}
133
134print("accessibility_enable = ", accessibility_enable)
135if (accessibility_enable) {
136  ohos_unittest("shell_command_executor_test") {
137    module_out_path = module_output_path
138
139    sources = [ "shell_command_executor_test.cpp" ]
140
141    configs = [ ":tools_ability_delegator_config" ]
142
143    deps = [
144      "${ability_runtime_path}/tools/aa:tools_aa_source_set",
145      "//third_party/googletest:gmock_main",
146      "//third_party/googletest:gtest_main",
147    ]
148
149    external_deps = [
150      "ability_base:configuration",
151      "accessibility:accessibility_common",
152      "accessibility:accessibilityclient",
153      "accessibility:accessibilityconfig",
154      "bundle_framework:appexecfwk_base",
155      "hilog:libhilog",
156      "ipc:ipc_core",
157    ]
158  }
159  ohos_unittest("accessibility_ability_command_test") {
160    module_out_path = module_output_path
161
162    symlink_target_name = [ "ability_tool" ]
163
164    include_dirs =
165        [ "${access_token_path}/interfaces/innerkits/token_setproc/include/" ]
166
167    configs = [ ":tools_ability_delegator_config" ]
168
169    sources = [
170      "${ability_runtime_path}/tools/aa/src/accessibility_ability_command.cpp",
171      "${ability_runtime_path}/tools/aa/src/accessibility_ability_utils.cpp",
172      "accessibility_ability_command_first_test.cpp",
173      "accessibility_ability_command_second_test.cpp",
174      "mock_accessibility_config.cpp",
175    ]
176
177    deps = [
178      "${ability_runtime_path}/tools/aa:tools_aa_source_set",
179      "//third_party/googletest:gtest_main",
180    ]
181
182    external_deps = [
183      "ability_base:configuration",
184      "access_token:libaccesstoken_sdk",
185      "access_token:libnativetoken",
186      "access_token:libtoken_setproc",
187      "accessibility:accessibility_common",
188      "accessibility:accessibilityclient",
189      "accessibility:accessibilityconfig",
190      "bundle_framework:appexecfwk_base",
191      "hilog:libhilog",
192      "ipc:ipc_core",
193    ]
194  }
195}
196group("unittest") {
197  testonly = true
198
199  deps = [
200    ":ability_command_test",
201    ":shell_command_result_test",
202    ":test_observer_proxy_test",
203    ":test_observer_stub_test",
204    ":test_observer_test",
205  ]
206  if (accessibility_enable) {
207    deps += [
208      ":accessibility_ability_command_test",
209      ":shell_command_executor_test",
210    ]
211  }
212}
213