From 979f2d8a9553e5788f49fc423b7785b47997d143 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Tue, 16 May 2023 14:26:24 -0700 Subject: Add a unit test for TouchpadInputMapper This test will provide RawEvent's to TouchpadInputMapper and will look at the returned events. The main purpose of this CL is to document the existing behaviour of CursorInputMapper and TouchpadInputMapper. The tests highlights that today, dispatcher must handle the case where the touch starts without HOVER_EXIT. That means that the dispatcher logs of "conflicting pointer actions" can be mostly ignored. The goal was to make the tests for the two mappers as similar to each other as possible. A slightly different testing infra is introduced here compared to the one used in InputReader_test. Changes: * Use mocks for interfaces instead of constructed objects This helps figure out which parts are important to mock for a specific test vs which ones are not. When a function is called with a parameters that the mocks aren't expecting, a warning is printed during test run. This helps identify the complete state needed in order for the test to execute. * No longer require InstrumentedInputReader * No longer require a listener. We only check the events that are coming from the 'process' call, which is what the interface for the mapper does. Limitations: * Still require an InputDevice object to be constructed in order to test InputMappers. Ideally, a mapper would only depend on the EventHub state (to read the current value of keys / axes after a reset). Bug: 263319225 Test: m inputflinger_tests && $ANDROID_HOST_OUT/nativetest64/inputflinger_tests/inputflinger_tests --gtest_filter="*HoverAndLeftButtonPress*" Change-Id: I7de0dee7abcf6bcb9d3283e29d9a85de2f331a44 --- include/input/Input.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/input') diff --git a/include/input/Input.h b/include/input/Input.h index fe0c775fd3..527a47741c 100644 --- a/include/input/Input.h +++ b/include/input/Input.h @@ -242,6 +242,19 @@ enum class ToolType { ftl_last = PALM, }; +/** + * The state of the key. This should have 1:1 correspondence with the values of anonymous enum + * defined in input.h + */ +enum class KeyState { + UNKNOWN = AKEY_STATE_UNKNOWN, + UP = AKEY_STATE_UP, + DOWN = AKEY_STATE_DOWN, + VIRTUAL = AKEY_STATE_VIRTUAL, + ftl_first = UNKNOWN, + ftl_last = VIRTUAL, +}; + bool isStylusToolType(ToolType toolType); /* -- cgit v1.2.3-59-g8ed1b