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