1# Copyright (c) 2021-2023 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/ohos.gni") 15import("//build/test.gni") 16import("../multimodalinput_mini.gni") 17 18defines = input_default_defines 19module_output_path = "multimodalinput/mmi_unit_out" 20mmi_service_path = "${mmi_path}/service" 21 22ohos_prebuilt_etc("mmi_device_config.ini") { 23 source = "mmi_device_config.ini" 24 relative_install_dir = "." 25 subsystem_name = "multimodalinput" 26 part_name = "input" 27} 28 29config("libmmi_server_config") { 30 if (is_ohos && is_clang && (target_cpu == "arm" || target_cpu == "arm64") && 31 enhanced_opt) { 32 cflags = [] 33 if (input_feature_enable_pgo && input_feature_product != "default") { 34 cflags += [ 35 "-fprofile-use=" + 36 rebase_path("${input_feature_pgo_path}/libmmi-server.profdata", 37 root_build_dir), 38 "-Wno-error=backend-plugin", 39 "-Wno-profile-instr-out-of-date", 40 "-Wno-profile-instr-unprofiled", 41 ] 42 } 43 if (input_feature_product == "pc" && target_cpu == "arm64") { 44 cflags += [ "-moutline-atomics" ] 45 } 46 } 47 include_dirs = [ 48 "app_state_manager/include", 49 "device_config/include", 50 "device_manager/include", 51 "device_scalability/include", 52 "delegate_task/include", 53 "display_state_manager/include", 54 "event_dispatch/include", 55 "key_event_normalize/include", 56 "event_handler/include", 57 "event_dump/include", 58 "fingersense_wrapper/include", 59 "monitor/include", 60 "interceptor/include", 61 "dfx/include", 62 "libinput_adapter/include", 63 "message_handle/include", 64 "module_loader/include", 65 "window_manager/include", 66 "touch_event_normalize/include", 67 "key_command/include", 68 "subscriber/include", 69 "timer_manager/include", 70 "permission_helper/include", 71 "${mmi_service_path}/connect_manager/include", 72 "${mmi_service_path}/filter/include", 73 "${mmi_service_path}/module_loader/include", 74 "${mmi_service_path}/nap_process/include", 75 "${mmi_service_path}/event_resample/include", 76 "${mmi_path}/interfaces/native/innerkits/proxy/include", 77 "${mmi_path}/interfaces/native/innerkits/event/include", 78 "mouse_event_normalize/include", 79 "${mmi_path}/interfaces/native/innerkits/common/include", 80 "${mmi_path}/util/common/include", 81 "${mmi_path}/util/socket/include", 82 "${mmi_path}/util/network/include", 83 "${mmi_path}/frameworks/proxy/event_handler/include", 84 "//third_party/cJSON", 85 "${preferences_path}/frameworks/native/include", 86 "${graphics_path}/2d_graphics/include", 87 ] 88 89 if (input_ext_feature_anco) { 90 include_dirs += [ "${mmi_ext_path}/anco_uds_manager/include" ] 91 } 92 93 if (input_feature_combination_key) { 94 defines += [ "OHOS_BUILD_ENABLE_COMBINATION_KEY" ] 95 } 96 97 if (resource_schedule_service_enabled) { 98 defines += [ "OHOS_RSS_CLIENT" ] 99 } 100 101 if (is_emulator) { 102 defines += [ "OHOS_BUILD_EMULATOR" ] 103 } 104} 105 106ohos_rust_shared_ffi("mmi_rust") { 107 sources = [ "rust/src/lib.rs" ] 108 external_deps = [ "hilog:hilog_rust" ] 109 subsystem_name = "multimodalinput" 110 part_name = "input" 111} 112 113ohos_rust_unittest("rust_mmi_test") { 114 module_out_path = module_output_path 115 sources = [ "rust/src/lib.rs" ] 116 deps = [ ":mmi_rust" ] 117 external_deps = [ "hilog:hilog_rust" ] 118 subsystem_name = "multimodalinput" 119 part_name = "input" 120} 121 122ohos_shared_library("libmmi-server") { 123 sources = libmmi_service_sources 124 stack_protector_ret = true 125 sanitize = { 126 cfi = true 127 cfi_cross_dso = true 128 debug = false 129 } 130 sources += [ "window_manager/src/touch_drawing_manager.cpp" ] 131 132 if (input_feature_keyboard) { 133 sources += [ 134 "key_event_normalize/src/key_event_normalize.cpp", 135 "key_event_normalize/src/key_unicode_transformation.cpp", 136 "subscriber/src/key_subscriber_handler.cpp", 137 ] 138 if (input_feature_combination_key) { 139 sources += [ 140 "key_command/src/key_command_handler.cpp", 141 "key_command/src/setting_datashare.cpp", 142 "key_command/src/setting_observer.cpp", 143 ] 144 } 145 } 146 147 if (input_feature_switch) { 148 sources += [ "subscriber/src/switch_subscriber_handler.cpp" ] 149 } 150 151 if (input_feature_mouse || input_feature_touchscreen) { 152 sources += [ "touch_event_normalize/src/touch_event_normalize.cpp" ] 153 if (input_feature_mouse) { 154 sources += [ 155 "mouse_event_normalize/src/mouse_device_state.cpp", 156 "mouse_event_normalize/src/mouse_event_normalize.cpp", 157 "mouse_event_normalize/src/mouse_transform_processor.cpp", 158 "touch_event_normalize/src/gesture_transform_processor.cpp", 159 "touch_event_normalize/src/touchpad_transform_processor.cpp", 160 ] 161 if (input_feature_pointer_drawing) { 162 sources += [ "window_manager/src/pointer_drawing_manager.cpp" ] 163 } else { 164 sources += [ "window_manager/src/i_pointer_drawing_manager.cpp" ] 165 } 166 } 167 if (input_feature_touchscreen) { 168 sources += [ 169 "event_resample/src/event_resample.cpp", 170 "touch_event_normalize/src/tablet_tool_tranform_processor.cpp", 171 "touch_event_normalize/src/touch_transform_processor.cpp", 172 ] 173 } 174 } 175 if (input_feature_joystick) { 176 sources += [ "touch_event_normalize/src/joystick_transform_processor.cpp" ] 177 } 178 if (input_feature_monitor) { 179 sources += [ "monitor/src/event_monitor_handler.cpp" ] 180 } 181 if (input_feature_interceptor) { 182 sources += [ "interceptor/src/event_interceptor_handler.cpp" ] 183 } 184 185 configs = [ 186 "${mmi_path}:coverage_flags", 187 ":libmmi_server_config", 188 ] 189 190 deps = [ 191 ":mmi_device_config.ini", 192 ":mmi_rust", 193 "${mmi_path}/etc/mouse_icon:input_mouse_icon", 194 "${mmi_path}/patch/diff_libinput_mmi:libinput-third-mmi", 195 "${mmi_path}/service/connect_manager:mmi_connect_manager_service", 196 "${mmi_path}/service/filter:mmi_event_filter_proxy", 197 "${mmi_path}/util:libmmi-util", 198 "//third_party/cJSON:cjson", 199 ] 200 201 external_deps = [ "c_utils:utils" ] 202 if (input_feature_pointer_drawing) { 203 external_deps += [ "window_manager:libwm" ] 204 } 205 206 if (security_component_enable) { 207 external_deps += 208 [ "security_component_manager:libsecurity_component_enhance_sdk" ] 209 } 210 211 if (resource_schedule_service_enabled) { 212 external_deps += [ "resource_schedule_service:ressched_client" ] 213 } 214 215 external_deps += [ 216 "ability_base:want", 217 "ability_base:zuri", 218 "ability_runtime:ability_manager", 219 "ability_runtime:abilitykit_native", 220 "ability_runtime:app_manager", 221 "ability_runtime:dataobs_manager", 222 "access_token:libaccesstoken_sdk", 223 "access_token:libtokenid_sdk", 224 "common_event_service:cesfwk_innerkits", 225 "config_policy:configpolicy_util", 226 "data_share:datashare_consumer", 227 "faultloggerd:libbacktrace_local", 228 "graphic_2d:2d_graphics", 229 "graphic_2d:librender_service_client", 230 "hicollie:libhicollie", 231 "hilog:libhilog", 232 "hisysevent:libhisysevent", 233 "hitrace:hitrace_meter", 234 "image_framework:image_native", 235 "init:libbegetutil", 236 "ipc:ipc_single", 237 "napi:ace_napi", 238 "preferences:native_preferences", 239 "relational_store:native_rdb", 240 "safwk:system_ability_fwk", 241 "window_manager:libwm", 242 "window_manager:libwsutils", 243 ] 244 245 if (defined(use_rosen_drawing) && use_rosen_drawing) { 246 defines += [ "USE_ROSEN_DRAWING" ] 247 } 248 249 part_name = "input" 250 subsystem_name = "multimodalinput" 251} 252 253import("//build/test.gni") 254module_output_path = "multimodalinput/mmi_unit_out" 255 256ohos_unittest("ut-mmi-service-out") { 257 module_out_path = module_output_path 258 include_dirs = [ 259 "${mmi_path}/frameworks/proxy/event_handler", 260 "${mmi_path}/frameworks/proxy/event_handler/include", 261 "${mmi_path}/frameworks/proxy/module_loader", 262 "${mmi_path}/frameworks/proxy/module_loader/include", 263 "${mmi_path}/util/common", 264 "${mmi_path}/util/common/include", 265 "${mmi_path}/util/network", 266 "${mmi_path}/util/network/include", 267 "${mmi_path}/util/socket", 268 "${mmi_path}/util/socket/include", 269 "${mmi_path}/frameworks/proxy/event_handle", 270 "${mmi_path}/frameworks/proxy/event_handle/include", 271 "${mmi_path}/frameworks/proxy/module_loader", 272 "${mmi_path}/frameworks/proxy/module_loader/include", 273 "${mmi_path}/interfaces/native/innerkits/common/include", 274 "${mmi_path}/interfaces/native/innerkits/proxy/include", 275 "${mmi_path}/interfaces/native/innerkits/event/include", 276 "${mmi_path}/service/include", 277 "${mmi_path}/service/device_manager/include", 278 "${mmi_path}/service/device_scalability/include", 279 "${mmi_path}/service/dfx/include", 280 "${mmi_path}/service/event_dump/include", 281 "${mmi_path}/service/event_dispatch/include", 282 "${mmi_path}/service/key_event_normalize/include", 283 "${mmi_path}/service/key_command/include", 284 "${mmi_path}/service/event_handler/include", 285 "${mmi_path}/service/event_dump/include", 286 "${mmi_path}/service/libinput_adapter/include", 287 "${mmi_path}/service/message_handle/include", 288 "${mmi_path}/service/module_loader/include", 289 "${mmi_path}/service/monitor/include", 290 "${mmi_path}/service/mouse_event_normalize/include", 291 "${mmi_path}/service/window_manager/include", 292 "${mmi_path}/test/unittest/common/include", 293 "${mmi_path}/uinput", 294 "$root_out_dir/diff_libinput_mmi/export_include", 295 "//third_party/node/src", 296 ] 297 298 sources = [ 299 "${mmi_path}/test/unittest/common/src/system_info.cpp", 300 "dfx/test/dfx_hisysevent_test.cpp", 301 "event_dispatch/test/event_dispatch_test.cpp", 302 "event_dump/test/event_dump_test.cpp", 303 "event_handler/test/gesture_handler_test.cpp", 304 "event_handler/test/key_event_value_transformation_test.cpp", 305 "key_command/test/key_command_handler_test.cpp", 306 "module_loader/test/uds_server_test.cpp", 307 "monitor/test/event_monitor_handler_test.cpp", 308 "mouse_event_normalize/test/mouse_device_state_test.cpp", 309 "mouse_event_normalize/test/mouse_event_normalize_test.cpp", 310 "mouse_event_normalize/test/mouse_transform_processor_test.cpp", 311 "subscriber/test/key_subscriber_handler_test.cpp", 312 "touch_event_normalize/test/touch_event_normalize_test.cpp", 313 "touch_event_normalize/test/touchpad_transform_processor_test.cpp", 314 "window_manager/test/input_display_bind_helper_test.cpp", 315 "window_manager/test/input_windows_manager_test.cpp", 316 "window_manager/test/touch_drawing_manager_test.cpp", 317 ] 318 319 configs = [ 320 "${mmi_path}:coverage_flags", 321 ":libmmi_server_config", 322 ] 323 324 deps = [ 325 "${mmi_path}/frameworks/proxy:libmmi-client", 326 "${mmi_path}/patch/diff_libinput_mmi:libinput-third-mmi", 327 "${mmi_path}/service:libmmi-server", 328 "${mmi_path}/util:libmmi-util", 329 "//third_party/googletest:gmock_main", 330 "//third_party/googletest:gtest_main", 331 ] 332 333 external_deps = [ 334 "c_utils:utils", 335 "graphic_2d:librender_service_client", 336 "hilog:libhilog", 337 "image_framework:image_native", 338 "window_manager:libwm", 339 "window_manager:libwsutils", 340 ] 341} 342 343ohos_unittest("event_resample_test") { 344 module_out_path = module_output_path 345 include_dirs = [ "${mmi_path}/service/event_resample/include" ] 346 347 sources = [ 348 "event_resample/src/event_resample.cpp", 349 "event_resample/test/event_resample_test.cpp", 350 ] 351 352 configs = [ ":libmmi_server_config" ] 353 354 deps = [ 355 "${mmi_path}/patch/diff_libinput_mmi:libinput-third-mmi", 356 "${mmi_path}/service:libmmi-server", 357 "${mmi_path}/util:libmmi-util", 358 "//third_party/cJSON:cjson", 359 "//third_party/googletest:gmock_main", 360 "//third_party/googletest:gtest_main", 361 ] 362 363 external_deps = [ 364 "c_utils:utils", 365 "config_policy:configpolicy_util", 366 "hilog:libhilog", 367 "image_framework:image_native", 368 "preferences:native_preferences", 369 "window_manager:libwm", 370 ] 371} 372 373ohos_unittest("TwoFingerLongTouchTest") { 374 module_out_path = module_output_path 375 include_dirs = [ 376 "${mmi_path}/service/key_command/include", 377 "${mmi_path}/service/key_command/test", 378 ] 379 380 configs = [ ":libmmi_server_config" ] 381 382 cflags = [ "-DUNIT_TEST" ] 383 384 sources = [ 385 "key_command/src/key_command_handler.cpp", 386 "key_command/test/ability_manager_client_stub.cpp", 387 "key_command/test/two_finger_long_touch_test.cpp", 388 ] 389 390 deps = [ 391 "${mmi_path}/patch/diff_libinput_mmi:libinput-third-mmi", 392 "${mmi_path}/service:libmmi-server", 393 "${mmi_path}/util:libmmi-util", 394 "//third_party/cJSON:cjson", 395 "//third_party/googletest:gmock_main", 396 "//third_party/googletest:gtest_main", 397 ] 398 399 external_deps = [ 400 "c_utils:utils", 401 "config_policy:configpolicy_util", 402 "data_share:datashare_consumer", 403 "hilog:libhilog", 404 "image_framework:image_native", 405 "preferences:native_preferences", 406 "window_manager:libwm", 407 ] 408} 409 410ohos_unittest("TransformPointTest") { 411 module_out_path = module_output_path 412 413 configs = [ "${mmi_path}:coverage_flags" ] 414 include_dirs = [ 415 "${mmi_path}/interfaces/native/innerkits/common/include", 416 "${mmi_path}/util/common/include", 417 "${mmi_path}/tools/vuinput/include", 418 ] 419 420 sources = [ "touch_event_normalize/test/transform_point_test.cpp" ] 421 422 deps = [ 423 "${mmi_path}/tools/vuinput:libmmi-virtual-device", 424 "//third_party/googletest:gmock_main", 425 "//third_party/googletest:gtest_main", 426 ] 427 428 external_deps = [ 429 "c_utils:utils", 430 "hilog:libhilog", 431 ] 432} 433 434group("mmi-service-tests") { 435 testonly = true 436 deps = [ "libinput_adapter/test" ] 437} 438