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 14import("//arkcompiler/ets_frontend/ts2panda/ts2abc_config.gni") 15import("//build/ohos.gni") 16 17source_root = "//test/testfwk/arkxtest/uitest" 18 19config("uitest_common_configs") { 20 include_dirs = [ 21 "//third_party/json/single_include/nlohmann", 22 "//foundation/mutimodalinput/input/interfaces", 23 ] 24 cflags = [ 25 "-Wfloat-equal", 26 "-Wformat=2", 27 "-Wshadow", 28 ] 29} 30 31ohos_static_library("uitest_core") { 32 use_exceptions = true 33 configs = [ ":uitest_common_configs" ] 34 sources = [ 35 "${source_root}/core/frontend_api_handler.cpp", 36 "${source_root}/core/rect_algorithm.cpp", 37 "${source_root}/core/ui_action.cpp", 38 "${source_root}/core/ui_controller.cpp", 39 "${source_root}/core/ui_driver.cpp", 40 "${source_root}/core/ui_model.cpp", 41 "${source_root}/core/widget_matcher.cpp", 42 "${source_root}/core/widget_operator.cpp", 43 "${source_root}/core/widget_selector.cpp", 44 "${source_root}/core/window_operator.cpp", 45 ] 46 external_deps = [ "hiviewdfx_hilog_native:libhilog" ] 47 defines = [ 48 "__OHOS__=1", 49 "LOG_TAG=\"UiTestKit_Base\"", 50 ] 51} 52 53ohos_static_library("uitest_record") { 54 use_exceptions = true 55 configs = [ ":uitest_common_configs" ] 56 sources = [ 57 "${source_root}/record/find_widget.cpp", 58 "${source_root}/record/least_square_impl.cpp", 59 "${source_root}/record/matrix3.cpp", 60 "${source_root}/record/matrix4.cpp", 61 "${source_root}/record/ui_record.cpp", 62 "${source_root}/record/velocity_tracker.cpp", 63 ] 64 deps = [ ":uitest_core" ] 65 defines = [ 66 "__OHOS__=1", 67 "LOG_TAG=\"UiTestKit_Base\"", 68 ] 69 include_dirs = [ "${source_root}/core" ] 70 external_deps = [ 71 "ability_base:want", 72 "ability_runtime:ability_manager", 73 "hiviewdfx_hilog_native:libhilog", 74 "input:libmmi-client", 75 ] 76} 77common_external_deps = [ 78 "c_utils:utils", 79 "hiviewdfx_hilog_native:libhilog", 80] 81 82ohos_static_library("uitest_ipc") { 83 configs = [ ":uitest_common_configs" ] 84 sources = [ "${source_root}/connection/ipc_transactor.cpp" ] 85 include_dirs = [ "${source_root}/core" ] 86 external_deps = [ 87 "ability_base:want", 88 "common_event_service:cesfwk_innerkits", 89 "ipc:ipc_core", 90 ] 91 external_deps += common_external_deps 92 93 defines = [ 94 "__OHOS__=1", 95 "LOG_TAG=\"UiTestKit_Conn\"", 96 ] 97} 98 99ohos_executable("uitest_server") { 100 configs = [ ":uitest_common_configs" ] 101 sources = [ 102 "${source_root}/server/server_main.cpp", 103 "${source_root}/server/system_ui_controller.cpp", 104 ] 105 include_dirs = [ 106 "${source_root}/core", 107 "${source_root}/connection", 108 "${source_root}/record", 109 ] 110 111 # static link the uitest_core as server end 112 deps = [ 113 ":uitest_core", 114 ":uitest_ipc", 115 ":uitest_record", 116 ] 117 118 #dependencies for screencap 119 deps += [ 120 "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", 121 "//third_party/libpng:libpng", 122 ] 123 external_deps = [ 124 "accessibility:accessibleability", 125 "input:libmmi-client", 126 "multimedia_image_framework:image_native", 127 "window_manager:libdm", 128 "window_manager:libwm", 129 ] 130 131 subsystem_name = "test" 132 part_name = "arkXtest" 133 output_name = "uitest" 134 install_enable = true 135 external_deps += common_external_deps 136 defines = [ 137 "__OHOS__=1", 138 "LOG_TAG=\"UiTestKit_Server\"", 139 ] 140} 141 142ts2abc_gen_abc("gen_uitest_exporter_abc") { 143 src_js = rebase_path("${source_root}/napi/uitest_exporter.js") 144 dst_file = rebase_path(target_out_dir + "/uitest_exporter.abc") 145 in_puts = [ "${source_root}/napi/uitest_exporter.js" ] 146 out_puts = [ target_out_dir + "/uitest_exporter.abc" ] 147 extra_args = [ "--module" ] 148} 149 150gen_js_obj("uitest_exporter_js") { 151 input = "${source_root}/napi/uitest_exporter.js" 152 output = target_out_dir + "/uitest_exporter.o" 153} 154 155gen_js_obj("uitest_exporter_abc") { 156 input = get_label_info(":gen_exporter_abc", "target_out_dir") + 157 "/uitest_exporter.abc" 158 output = target_out_dir + "/uitest_exporter_abc.o" 159 dep = ":gen_uitest_exporter_abc" 160} 161 162ohos_shared_library("uitest_client") { 163 configs = [ ":uitest_common_configs" ] 164 sources = [ "${source_root}/napi/uitest_napi.cpp" ] 165 include_dirs = [ 166 "${source_root}/core", 167 "${source_root}/connection", 168 ] 169 deps = [ 170 ":uitest_exporter_abc", 171 ":uitest_exporter_js", 172 ":uitest_ipc", 173 ] 174 subsystem_name = "test" 175 part_name = "arkXtest" 176 output_name = "uitest" 177 external_deps = common_external_deps 178 external_deps += [ "napi:ace_napi" ] 179 relative_install_dir = "module" 180 defines = [ 181 "__OHOS__=1", 182 "LOG_TAG=\"UiTestKit_Client\"", 183 ] 184} 185 186ohos_unittest("uitest_core_unittest") { 187 sources = [ 188 "${source_root}/test/common_utilities_test.cpp", 189 "${source_root}/test/frontend_api_handler_test.cpp", 190 "${source_root}/test/rect_algorithm_test.cpp", 191 "${source_root}/test/ui_action_test.cpp", 192 "${source_root}/test/ui_controller_test.cpp", 193 "${source_root}/test/ui_driver_test.cpp", 194 "${source_root}/test/ui_model_test.cpp", 195 "${source_root}/test/widget_matcher_test.cpp", 196 "${source_root}/test/widget_operator_test.cpp", 197 "${source_root}/test/widget_selector_test.cpp", 198 ] 199 deps = [ 200 ":uitest_core", 201 "//third_party/googletest:gtest_main", 202 ] 203 include_dirs = [ 204 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 205 "//third_party/json/single_include/nlohmann", 206 "${source_root}/core", 207 ] 208 cflags = [ "-g" ] 209 cflags_cc = [ "-g" ] 210 use_exceptions = true 211 module_out_path = "uitestkit/unittest" 212 testonly = true 213 subsystem_name = "test" 214 part_name = "arkXtest" 215} 216 217ohos_unittest("uitest_ipc_unittest") { 218 sources = [ "${source_root}/test/ipc_transactor_test.cpp" ] 219 deps = [ 220 ":uitest_ipc", 221 "//third_party/googletest:gtest_main", 222 ] 223 include_dirs = [ 224 "${source_root}/connection", 225 "${source_root}/core", 226 "//third_party/json/single_include/nlohmann", 227 ] 228 cflags = [ "-g" ] 229 cflags_cc = [ "-g" ] 230 module_out_path = "uitestkit/unittest" 231 testonly = true 232 subsystem_name = "test" 233 part_name = "arkXtest" 234} 235 236group("uitestkit") { 237 deps = [ 238 ":uitest_client", 239 ":uitest_server", 240 ] 241} 242 243group("uitestkit_test") { 244 testonly = true 245 deps = [ 246 ":uitest_core_unittest", 247 ":uitest_ipc_unittest", 248 ] 249} 250