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