# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/ohos.gni") import("//build/test.gni") import("../multimodalinput_mini.gni") defines = input_default_defines module_output_path = "multimodalinput/mmi_unit_out" mmi_service_path = "${mmi_path}/service" ohos_prebuilt_etc("mmi_device_config.ini") { source = "mmi_device_config.ini" relative_install_dir = "." subsystem_name = "multimodalinput" part_name = "input" } config("libmmi_server_config") { if (is_ohos && is_clang && (target_cpu == "arm" || target_cpu == "arm64") && enhanced_opt) { cflags = [] if (input_feature_enable_pgo && input_feature_product != "default") { cflags += [ "-fprofile-use=" + rebase_path("${input_feature_pgo_path}/libmmi-server.profdata", root_build_dir), "-Wno-error=backend-plugin", "-Wno-profile-instr-out-of-date", "-Wno-profile-instr-unprofiled", ] } if (input_feature_product == "pc" && target_cpu == "arm64") { cflags += [ "-moutline-atomics" ] } } include_dirs = [ "app_state_manager/include", "device_config/include", "device_manager/include", "device_scalability/include", "delegate_task/include", "display_state_manager/include", "event_dispatch/include", "key_event_normalize/include", "event_handler/include", "event_dump/include", "fingersense_wrapper/include", "monitor/include", "interceptor/include", "dfx/include", "libinput_adapter/include", "message_handle/include", "module_loader/include", "window_manager/include", "touch_event_normalize/include", "key_command/include", "subscriber/include", "timer_manager/include", "permission_helper/include", "${mmi_service_path}/connect_manager/include", "${mmi_service_path}/filter/include", "${mmi_service_path}/module_loader/include", "${mmi_service_path}/nap_process/include", "${mmi_service_path}/event_resample/include", "${mmi_path}/interfaces/native/innerkits/proxy/include", "${mmi_path}/interfaces/native/innerkits/event/include", "mouse_event_normalize/include", "${mmi_path}/interfaces/native/innerkits/common/include", "${mmi_path}/util/common/include", "${mmi_path}/util/socket/include", "${mmi_path}/util/network/include", "${mmi_path}/frameworks/proxy/event_handler/include", "//third_party/cJSON", "${preferences_path}/frameworks/native/include", "${graphics_path}/2d_graphics/include", ] if (input_ext_feature_anco) { include_dirs += [ "${mmi_ext_path}/anco_uds_manager/include" ] } if (input_feature_combination_key) { defines += [ "OHOS_BUILD_ENABLE_COMBINATION_KEY" ] } if (resource_schedule_service_enabled) { defines += [ "OHOS_RSS_CLIENT" ] } if (is_emulator) { defines += [ "OHOS_BUILD_EMULATOR" ] } } ohos_rust_shared_ffi("mmi_rust") { sources = [ "rust/src/lib.rs" ] external_deps = [ "hilog:hilog_rust" ] subsystem_name = "multimodalinput" part_name = "input" } ohos_rust_unittest("rust_mmi_test") { module_out_path = module_output_path sources = [ "rust/src/lib.rs" ] deps = [ ":mmi_rust" ] external_deps = [ "hilog:hilog_rust" ] subsystem_name = "multimodalinput" part_name = "input" } ohos_shared_library("libmmi-server") { sources = libmmi_service_sources stack_protector_ret = true sanitize = { cfi = true cfi_cross_dso = true debug = false } sources += [ "window_manager/src/touch_drawing_manager.cpp" ] if (input_feature_keyboard) { sources += [ "key_event_normalize/src/key_event_normalize.cpp", "key_event_normalize/src/key_unicode_transformation.cpp", "subscriber/src/key_subscriber_handler.cpp", ] if (input_feature_combination_key) { sources += [ "key_command/src/key_command_handler.cpp", "key_command/src/setting_datashare.cpp", "key_command/src/setting_observer.cpp", ] } } if (input_feature_switch) { sources += [ "subscriber/src/switch_subscriber_handler.cpp" ] } if (input_feature_mouse || input_feature_touchscreen) { sources += [ "touch_event_normalize/src/touch_event_normalize.cpp" ] if (input_feature_mouse) { sources += [ "mouse_event_normalize/src/mouse_device_state.cpp", "mouse_event_normalize/src/mouse_event_normalize.cpp", "mouse_event_normalize/src/mouse_transform_processor.cpp", "touch_event_normalize/src/gesture_transform_processor.cpp", "touch_event_normalize/src/touchpad_transform_processor.cpp", ] if (input_feature_pointer_drawing) { sources += [ "window_manager/src/pointer_drawing_manager.cpp" ] } else { sources += [ "window_manager/src/i_pointer_drawing_manager.cpp" ] } } if (input_feature_touchscreen) { sources += [ "event_resample/src/event_resample.cpp", "touch_event_normalize/src/tablet_tool_tranform_processor.cpp", "touch_event_normalize/src/touch_transform_processor.cpp", ] } } if (input_feature_joystick) { sources += [ "touch_event_normalize/src/joystick_transform_processor.cpp" ] } if (input_feature_monitor) { sources += [ "monitor/src/event_monitor_handler.cpp" ] } if (input_feature_interceptor) { sources += [ "interceptor/src/event_interceptor_handler.cpp" ] } configs = [ "${mmi_path}:coverage_flags", ":libmmi_server_config", ] deps = [ ":mmi_device_config.ini", ":mmi_rust", "${mmi_path}/etc/mouse_icon:input_mouse_icon", "${mmi_path}/patch/diff_libinput_mmi:libinput-third-mmi", "${mmi_path}/service/connect_manager:mmi_connect_manager_service", "${mmi_path}/service/filter:mmi_event_filter_proxy", "${mmi_path}/util:libmmi-util", "//third_party/cJSON:cjson", ] external_deps = [ "c_utils:utils" ] if (input_feature_pointer_drawing) { external_deps += [ "window_manager:libwm" ] } if (security_component_enable) { external_deps += [ "security_component_manager:libsecurity_component_enhance_sdk" ] } if (resource_schedule_service_enabled) { external_deps += [ "resource_schedule_service:ressched_client" ] } external_deps += [ "ability_base:want", "ability_base:zuri", "ability_runtime:ability_manager", "ability_runtime:abilitykit_native", "ability_runtime:app_manager", "ability_runtime:dataobs_manager", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "data_share:datashare_consumer", "faultloggerd:libbacktrace_local", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "image_framework:image_native", "init:libbegetutil", "ipc:ipc_single", "napi:ace_napi", "preferences:native_preferences", "relational_store:native_rdb", "safwk:system_ability_fwk", "window_manager:libwm", "window_manager:libwsutils", ] if (defined(use_rosen_drawing) && use_rosen_drawing) { defines += [ "USE_ROSEN_DRAWING" ] } part_name = "input" subsystem_name = "multimodalinput" } import("//build/test.gni") module_output_path = "multimodalinput/mmi_unit_out" ohos_unittest("ut-mmi-service-out") { module_out_path = module_output_path include_dirs = [ "${mmi_path}/frameworks/proxy/event_handler", "${mmi_path}/frameworks/proxy/event_handler/include", "${mmi_path}/frameworks/proxy/module_loader", "${mmi_path}/frameworks/proxy/module_loader/include", "${mmi_path}/util/common", "${mmi_path}/util/common/include", "${mmi_path}/util/network", "${mmi_path}/util/network/include", "${mmi_path}/util/socket", "${mmi_path}/util/socket/include", "${mmi_path}/frameworks/proxy/event_handle", "${mmi_path}/frameworks/proxy/event_handle/include", "${mmi_path}/frameworks/proxy/module_loader", "${mmi_path}/frameworks/proxy/module_loader/include", "${mmi_path}/interfaces/native/innerkits/common/include", "${mmi_path}/interfaces/native/innerkits/proxy/include", "${mmi_path}/interfaces/native/innerkits/event/include", "${mmi_path}/service/include", "${mmi_path}/service/device_manager/include", "${mmi_path}/service/device_scalability/include", "${mmi_path}/service/dfx/include", "${mmi_path}/service/event_dump/include", "${mmi_path}/service/event_dispatch/include", "${mmi_path}/service/key_event_normalize/include", "${mmi_path}/service/key_command/include", "${mmi_path}/service/event_handler/include", "${mmi_path}/service/event_dump/include", "${mmi_path}/service/libinput_adapter/include", "${mmi_path}/service/message_handle/include", "${mmi_path}/service/module_loader/include", "${mmi_path}/service/monitor/include", "${mmi_path}/service/mouse_event_normalize/include", "${mmi_path}/service/window_manager/include", "${mmi_path}/test/unittest/common/include", "${mmi_path}/uinput", "$root_out_dir/diff_libinput_mmi/export_include", "//third_party/node/src", ] sources = [ "${mmi_path}/test/unittest/common/src/system_info.cpp", "dfx/test/dfx_hisysevent_test.cpp", "event_dispatch/test/event_dispatch_test.cpp", "event_dump/test/event_dump_test.cpp", "event_handler/test/gesture_handler_test.cpp", "event_handler/test/key_event_value_transformation_test.cpp", "key_command/test/key_command_handler_test.cpp", "module_loader/test/uds_server_test.cpp", "monitor/test/event_monitor_handler_test.cpp", "mouse_event_normalize/test/mouse_device_state_test.cpp", "mouse_event_normalize/test/mouse_event_normalize_test.cpp", "mouse_event_normalize/test/mouse_transform_processor_test.cpp", "subscriber/test/key_subscriber_handler_test.cpp", "touch_event_normalize/test/touch_event_normalize_test.cpp", "touch_event_normalize/test/touchpad_transform_processor_test.cpp", "window_manager/test/input_display_bind_helper_test.cpp", "window_manager/test/input_windows_manager_test.cpp", "window_manager/test/touch_drawing_manager_test.cpp", ] configs = [ "${mmi_path}:coverage_flags", ":libmmi_server_config", ] deps = [ "${mmi_path}/frameworks/proxy:libmmi-client", "${mmi_path}/patch/diff_libinput_mmi:libinput-third-mmi", "${mmi_path}/service:libmmi-server", "${mmi_path}/util:libmmi-util", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] external_deps = [ "c_utils:utils", "graphic_2d:librender_service_client", "hilog:libhilog", "image_framework:image_native", "window_manager:libwm", "window_manager:libwsutils", ] } ohos_unittest("event_resample_test") { module_out_path = module_output_path include_dirs = [ "${mmi_path}/service/event_resample/include" ] sources = [ "event_resample/src/event_resample.cpp", "event_resample/test/event_resample_test.cpp", ] configs = [ ":libmmi_server_config" ] deps = [ "${mmi_path}/patch/diff_libinput_mmi:libinput-third-mmi", "${mmi_path}/service:libmmi-server", "${mmi_path}/util:libmmi-util", "//third_party/cJSON:cjson", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] external_deps = [ "c_utils:utils", "config_policy:configpolicy_util", "hilog:libhilog", "image_framework:image_native", "preferences:native_preferences", "window_manager:libwm", ] } ohos_unittest("TwoFingerLongTouchTest") { module_out_path = module_output_path include_dirs = [ "${mmi_path}/service/key_command/include", "${mmi_path}/service/key_command/test", ] configs = [ ":libmmi_server_config" ] cflags = [ "-DUNIT_TEST" ] sources = [ "key_command/src/key_command_handler.cpp", "key_command/test/ability_manager_client_stub.cpp", "key_command/test/two_finger_long_touch_test.cpp", ] deps = [ "${mmi_path}/patch/diff_libinput_mmi:libinput-third-mmi", "${mmi_path}/service:libmmi-server", "${mmi_path}/util:libmmi-util", "//third_party/cJSON:cjson", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] external_deps = [ "c_utils:utils", "config_policy:configpolicy_util", "data_share:datashare_consumer", "hilog:libhilog", "image_framework:image_native", "preferences:native_preferences", "window_manager:libwm", ] } ohos_unittest("TransformPointTest") { module_out_path = module_output_path configs = [ "${mmi_path}:coverage_flags" ] include_dirs = [ "${mmi_path}/interfaces/native/innerkits/common/include", "${mmi_path}/util/common/include", "${mmi_path}/tools/vuinput/include", ] sources = [ "touch_event_normalize/test/transform_point_test.cpp" ] deps = [ "${mmi_path}/tools/vuinput:libmmi-virtual-device", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] external_deps = [ "c_utils:utils", "hilog:libhilog", ] } group("mmi-service-tests") { testonly = true deps = [ "libinput_adapter/test" ] }