1# Copyright (c) 2021 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 14base_root = "../../../.." 15import("$base_root/arkcompiler/ets_frontend/es2panda/es2abc_config.gni") 16import("$base_root/build/ohos.gni") 17 18source_root = "$base_root/test/testfwk/arkxtest/uitest" 19 20config("uitest_common_configs") { 21 cflags = [ 22 "-Wfloat-equal", 23 "-Wformat=2", 24 "-Wshadow", 25 ] 26} 27 28ohos_static_library("uitest_core") { 29 use_exceptions = true 30 configs = [ ":uitest_common_configs" ] 31 sources = [ 32 "${source_root}/core/dump_handler.cpp", 33 "${source_root}/core/frontend_api_handler.cpp", 34 "${source_root}/core/rect_algorithm.cpp", 35 "${source_root}/core/select_strategy.cpp", 36 "${source_root}/core/ui_action.cpp", 37 "${source_root}/core/ui_driver.cpp", 38 "${source_root}/core/ui_model.cpp", 39 "${source_root}/core/widget_operator.cpp", 40 "${source_root}/core/widget_selector.cpp", 41 "${source_root}/core/window_operator.cpp", 42 ] 43 external_deps = [ 44 "hilog:libhilog", 45 "json:nlohmann_json_static", 46 ] 47 defines = [ 48 "__OHOS__=1", 49 "LOG_TAG=\"UiTestKit_Base\"", 50 ] 51 52 subsystem_name = "testfwk" 53 part_name = "arkxtest" 54} 55 56ohos_static_library("uitest_input") { 57 use_exceptions = true 58 configs = [ ":uitest_common_configs" ] 59 sources = [ "${source_root}/input/ui_input.cpp" ] 60 deps = [ ":uitest_core" ] 61 defines = [ 62 "__OHOS__=1", 63 "LOG_TAG=\"UiTestKit_Input\"", 64 ] 65 include_dirs = [ "${source_root}/core" ] 66 external_deps = [ 67 "hilog:libhilog", 68 "json:nlohmann_json_static", 69 ] 70 subsystem_name = "testfwk" 71 part_name = "arkxtest" 72} 73 74ohos_static_library("uitest_record") { 75 use_exceptions = true 76 configs = [ ":uitest_common_configs" ] 77 sources = [ 78 "${source_root}/record/external_calls.cpp", 79 "${source_root}/record/find_widget.cpp", 80 "${source_root}/record/keyevent_tracker.cpp", 81 "${source_root}/record/least_square_impl.cpp", 82 "${source_root}/record/matrix3.cpp", 83 "${source_root}/record/pointer_info.cpp", 84 "${source_root}/record/pointer_tracker.cpp", 85 "${source_root}/record/ui_record.cpp", 86 "${source_root}/record/velocity_tracker.cpp", 87 ] 88 deps = [ ":uitest_core" ] 89 defines = [ 90 "__OHOS__=1", 91 "LOG_TAG=\"UiTestKit_Base\"", 92 ] 93 include_dirs = [ "${source_root}/core" ] 94 external_deps = [ 95 "ability_base:want", 96 "ability_runtime:ability_manager", 97 "hilog:libhilog", 98 "input:libmmi-client", 99 "ipc:ipc_single", 100 ] 101 102 subsystem_name = "testfwk" 103 part_name = "arkxtest" 104} 105common_external_deps = [ 106 "c_utils:utils", 107 "hilog:libhilog", 108] 109 110ohos_static_library("uitest_ipc") { 111 configs = [ ":uitest_common_configs" ] 112 sources = [ "${source_root}/connection/ipc_transactor.cpp" ] 113 include_dirs = [ "${source_root}/core" ] 114 deps = [ "${source_root}/../testserver/src:test_server_client" ] 115 external_deps = [ 116 "ability_base:want", 117 "common_event_service:cesfwk_innerkits", 118 "ipc:ipc_core", 119 "json:nlohmann_json_static", 120 "samgr:samgr_proxy", 121 ] 122 123 external_deps += common_external_deps 124 125 subsystem_name = "testfwk" 126 part_name = "arkxtest" 127 128 defines = [ 129 "__OHOS__=1", 130 "LOG_TAG=\"UiTestKit_Conn\"", 131 ] 132} 133 134ohos_static_library("uitest_addon") { 135 configs = [ ":uitest_common_configs" ] 136 sources = [ 137 "${source_root}/addon/extension_executor.cpp", 138 "${source_root}/addon/screen_copy.cpp", 139 ] 140 include_dirs = [ 141 "${source_root}/core", 142 "${source_root}/record", 143 ] 144 deps = [ 145 ":uitest_core", 146 "//third_party/libjpeg-turbo:turbojpeg_static", 147 ] 148 external_deps = [ 149 "graphic_2d:librender_service_base", 150 "image_framework:image_native", 151 "input:libmmi-client", 152 "ipc:ipc_single", 153 "json:nlohmann_json_static", 154 "window_manager:libdm", 155 "window_manager:libwm", 156 ] 157 external_deps += common_external_deps 158 159 subsystem_name = "testfwk" 160 part_name = "arkxtest" 161 162 defines = [ 163 "__OHOS__=1", 164 "LOG_TAG=\"UiTestKit_Addon\"", 165 ] 166} 167 168ohos_executable("uitest_server") { 169 configs = [ ":uitest_common_configs" ] 170 sources = [ 171 "${source_root}/server/element_node_iterator_impl.cpp", 172 "${source_root}/server/server_main.cpp", 173 "${source_root}/server/system_ui_controller.cpp", 174 ] 175 include_dirs = [ 176 "${source_root}/core", 177 "${source_root}/connection", 178 "${source_root}/record", 179 "${source_root}/addon", 180 "${source_root}/input", 181 ] 182 183 # static link the uitest_core as server end 184 deps = [ 185 ":uitest_addon", 186 ":uitest_core", 187 ":uitest_input", 188 ":uitest_ipc", 189 ":uitest_record", 190 "${source_root}/../testserver/src:test_server_client", 191 ] 192 193 #dependencies for screencap 194 deps += [ 195 "$base_root/foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", 196 "//third_party/libpng:libpng", 197 ] 198 external_deps = [ 199 "ability_runtime:ability_manager", 200 "accessibility:accessibility_common", 201 "accessibility:accessibleability", 202 "image_framework:image_native", 203 "input:libmmi-client", 204 "ipc:ipc_single", 205 "window_manager:libdm", 206 "window_manager:libwm", 207 ] 208 209 subsystem_name = "testfwk" 210 part_name = "arkxtest" 211 output_name = "uitest" 212 install_enable = true 213 external_deps += common_external_deps 214 defines = [ 215 "__OHOS__=1", 216 "LOG_TAG=\"UiTestKit_Server\"", 217 ] 218 219 if (defined(global_parts_info) && 220 defined(global_parts_info.hiviewdfx_hidumper)) { 221 external_deps += [ 222 "hidumper:hidumper_client", 223 "samgr:samgr_proxy", 224 ] 225 defines += [ "HIDUMPER_ENABLED" ] 226 } 227} 228 229es2abc_gen_abc("gen_uitest_exporter_abc") { 230 src_js = rebase_path("${source_root}/napi/uitest_exporter.js") 231 dst_file = rebase_path(target_out_dir + "/uitest_exporter.abc") 232 in_puts = [ "${source_root}/napi/uitest_exporter.js" ] 233 out_puts = [ target_out_dir + "/uitest_exporter.abc" ] 234 extra_args = [ "--module" ] 235} 236 237gen_js_obj("uitest_exporter_js") { 238 input = "${source_root}/napi/uitest_exporter.js" 239 output = target_out_dir + "/uitest_exporter.o" 240} 241 242gen_js_obj("uitest_exporter_abc") { 243 input = get_label_info(":gen_exporter_abc", "target_out_dir") + 244 "/uitest_exporter.abc" 245 output = target_out_dir + "/uitest_exporter_abc.o" 246 dep = ":gen_uitest_exporter_abc" 247} 248 249ohos_shared_library("uitest_client") { 250 configs = [ ":uitest_common_configs" ] 251 sources = [ 252 "${source_root}/napi/ui_event_observer_napi.cpp", 253 "${source_root}/napi/uitest_napi.cpp", 254 ] 255 include_dirs = [ 256 "${source_root}/core", 257 "${source_root}/connection", 258 ] 259 deps = [ 260 ":uitest_exporter_abc", 261 ":uitest_exporter_js", 262 ":uitest_ipc", 263 "${source_root}/../testserver/src:test_server_client", 264 ] 265 subsystem_name = "testfwk" 266 part_name = "arkxtest" 267 output_name = "uitest" 268 external_deps = common_external_deps 269 external_deps += [ 270 "ability_base:want", 271 "image_framework:image_native", 272 "ipc:ipc_single", 273 "libuv:uv", 274 "napi:ace_napi", 275 ] 276 relative_install_dir = "module" 277 defines = [ 278 "__OHOS__=1", 279 "LOG_TAG=\"UiTestKit_Client\"", 280 ] 281} 282 283ohos_unittest("uitest_core_unittest") { 284 sources = [ 285 "${source_root}/test/common_utilities_test.cpp", 286 "${source_root}/test/frontend_api_handler_test.cpp", 287 "${source_root}/test/rect_algorithm_test.cpp", 288 "${source_root}/test/select_strategy_test.cpp", 289 "${source_root}/test/ui_action_test.cpp", 290 "${source_root}/test/ui_driver_test.cpp", 291 "${source_root}/test/ui_model_test.cpp", 292 "${source_root}/test/widget_operator_test.cpp", 293 "${source_root}/test/widget_selector_test.cpp", 294 ] 295 deps = [ 296 ":uitest_core", 297 "//third_party/googletest:gtest_main", 298 ] 299 external_deps = [ 300 "hilog:libhilog", 301 "json:nlohmann_json_static", 302 ] 303 include_dirs = [ "${source_root}/core" ] 304 cflags = [ "-g" ] 305 cflags_cc = [ "-g" ] 306 use_exceptions = true 307 module_out_path = "uitestkit/unittest" 308 testonly = true 309 subsystem_name = "testfwk" 310 part_name = "arkxtest" 311} 312 313ohos_unittest("uitest_ipc_unittest") { 314 sources = [ "${source_root}/test/ipc_transactor_test.cpp" ] 315 deps = [ 316 ":uitest_ipc", 317 "//third_party/googletest:gtest_main", 318 ] 319 include_dirs = [ 320 "${source_root}/connection", 321 "${source_root}/core", 322 ] 323 external_deps = [ 324 "ability_base:base", 325 "ability_base:want", 326 "hilog:libhilog", 327 ] 328 cflags = [ "-g" ] 329 cflags_cc = [ "-g" ] 330 module_out_path = "uitestkit/unittest" 331 testonly = true 332 subsystem_name = "testfwk" 333 part_name = "arkxtest" 334} 335 336ohos_unittest("uitest_extension_unittest") { 337 sources = [ "${source_root}/test/extension_test.cpp" ] 338 deps = [ 339 ":uitest_addon", 340 ":uitest_core", 341 ] 342 include_dirs = [ 343 "${source_root}/addon", 344 "${source_root}/core", 345 ] 346 external_deps = [ 347 "hilog:libhilog", 348 "json:nlohmann_json_static", 349 ] 350 cflags = [ "-g" ] 351 cflags_cc = [ "-g" ] 352 module_out_path = "uitestkit/unittest" 353 testonly = true 354 subsystem_name = "testfwk" 355 part_name = "arkxtest" 356} 357 358ohos_shared_library("uitest_dummy_extension") { 359 sources = [ "${source_root}/test/dummy_extension.cpp" ] 360 include_dirs = [ "${source_root}/addon" ] 361 testonly = true 362 subsystem_name = "testfwk" 363 part_name = "arkxtest" 364} 365 366group("uitestkit") { 367 deps = [ 368 ":cj_ui_test_ffi", 369 ":uitest_client", 370 ":uitest_server", 371 ] 372} 373 374group("uitestkit_test") { 375 testonly = true 376 deps = [ 377 ":uitest_core_unittest", 378 ":uitest_dummy_extension", 379 ":uitest_extension_unittest", 380 ":uitest_ipc_unittest", 381 ] 382} 383 384ohos_shared_library("cj_ui_test_ffi") { 385 cflags = [ 386 "-Wfloat-equal", 387 "-Wformat=2", 388 "-Wshadow", 389 ] 390 391 defines = [ 392 "__OHOS__=1", 393 "LOG_TAG=\"UiTestKit_Client\"", 394 ] 395 396 sources = [ 397 "${source_root}/cj/ui_event_observer_impl.cpp", 398 "${source_root}/cj/uitest_ffi.cpp", 399 ] 400 401 include_dirs = [ 402 "${source_root}/core", 403 "${source_root}/connection", 404 ] 405 406 if (product_name == "ohos-sdk") { 407 defines += [ "PREVIEWER" ] 408 sources = [ "${source_root}/cj/uitest_mock.cpp" ] 409 } 410 411 deps = [ 412 ":uitest_ipc", 413 "${source_root}/../testserver/src:test_server_client", 414 ] 415 416 external_deps = common_external_deps 417 external_deps += [ 418 "ability_base:want", 419 "image_framework:image_native", 420 "ipc:ipc_single", 421 "json:nlohmann_json_static", 422 "napi:cj_bind_ffi", 423 "napi:cj_bind_native", 424 "samgr:samgr_proxy", 425 ] 426 427 relative_install_dir = "platformsdk" 428 subsystem_name = "testfwk" 429 part_name = "arkxtest" 430} 431