InputMapper refactor: CursorInputMapper
Add a factory method for CursorInputMapper(s) to be configured on
initilisation
Test: m checkinput && atest libinput_tests inputflinger_tests
Bug: 256009910
Change-Id: Id789ff890b7e147de16c07a9dcd095a21eba43f9
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 5645f4c..c34dcac 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -3875,21 +3875,21 @@
TEST_F(CursorInputMapperTest, WhenModeIsPointer_GetSources_ReturnsMouse) {
addConfigurationProperty("cursor.mode", "pointer");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper.getSources());
}
TEST_F(CursorInputMapperTest, WhenModeIsNavigation_GetSources_ReturnsTrackball) {
addConfigurationProperty("cursor.mode", "navigation");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
ASSERT_EQ(AINPUT_SOURCE_TRACKBALL, mapper.getSources());
}
TEST_F(CursorInputMapperTest, WhenModeIsPointer_PopulateDeviceInfo_ReturnsRangeFromPointerController) {
addConfigurationProperty("cursor.mode", "pointer");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
InputDeviceInfo info;
mapper.populateDeviceInfo(info);
@@ -3919,7 +3919,7 @@
TEST_F(CursorInputMapperTest, WhenModeIsNavigation_PopulateDeviceInfo_ReturnsScaledRange) {
addConfigurationProperty("cursor.mode", "navigation");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
InputDeviceInfo info;
mapper.populateDeviceInfo(info);
@@ -3937,7 +3937,7 @@
TEST_F(CursorInputMapperTest, Process_ShouldSetAllFieldsAndIncludeGlobalMetaState) {
addConfigurationProperty("cursor.mode", "navigation");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
mReader->getContext()->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
@@ -4025,7 +4025,7 @@
TEST_F(CursorInputMapperTest, Process_ShouldHandleIndependentXYUpdates) {
addConfigurationProperty("cursor.mode", "navigation");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
NotifyMotionArgs args;
@@ -4049,7 +4049,7 @@
TEST_F(CursorInputMapperTest, Process_ShouldHandleIndependentButtonUpdates) {
addConfigurationProperty("cursor.mode", "navigation");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
NotifyMotionArgs args;
@@ -4078,7 +4078,7 @@
TEST_F(CursorInputMapperTest, Process_ShouldHandleCombinedXYAndButtonUpdates) {
addConfigurationProperty("cursor.mode", "navigation");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
NotifyMotionArgs args;
@@ -4127,7 +4127,7 @@
// InputReader works in the un-rotated coordinate space, so orientation-aware devices do not
// need to be rotated.
addConfigurationProperty("cursor.orientationAware", "1");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
prepareDisplay(ui::ROTATION_90);
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, 0, 1, 0, 1));
@@ -4145,7 +4145,7 @@
addConfigurationProperty("cursor.mode", "navigation");
// Since InputReader works in the un-rotated coordinate space, only devices that are not
// orientation-aware are affected by display rotation.
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
clearViewports();
prepareDisplay(ui::ROTATION_0);
@@ -4194,7 +4194,7 @@
TEST_F(CursorInputMapperTest, Process_ShouldHandleAllButtons) {
addConfigurationProperty("cursor.mode", "pointer");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
mFakePointerController->setPosition(100, 200);
@@ -4448,7 +4448,7 @@
TEST_F(CursorInputMapperTest, Process_WhenModeIsPointer_ShouldMoveThePointerAround) {
addConfigurationProperty("cursor.mode", "pointer");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
mFakePointerController->setPosition(100, 200);
@@ -4469,7 +4469,7 @@
TEST_F(CursorInputMapperTest, Process_PointerCapture) {
addConfigurationProperty("cursor.mode", "pointer");
mFakePolicy->setPointerCapture(true);
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
NotifyDeviceResetArgs resetArgs;
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
@@ -4561,7 +4561,7 @@
const VelocityControlParameters testParams(/*scale=*/5.f, /*low threshold=*/0.f,
/*high threshold=*/100.f, /*acceleration=*/10.f);
mFakePolicy->setVelocityControlParams(testParams);
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
NotifyDeviceResetArgs resetArgs;
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
@@ -4602,7 +4602,7 @@
TEST_F(CursorInputMapperTest, PointerCaptureDisablesOrientationChanges) {
addConfigurationProperty("cursor.mode", "pointer");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
NotifyDeviceResetArgs resetArgs;
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
@@ -4643,7 +4643,7 @@
}
TEST_F(CursorInputMapperTest, ConfigureDisplayId_NoAssociatedViewport) {
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
// Set up the default display.
prepareDisplay(ui::ROTATION_90);
@@ -4669,7 +4669,7 @@
}
TEST_F(CursorInputMapperTest, ConfigureDisplayId_WithAssociatedViewport) {
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
// Set up the default display.
prepareDisplay(ui::ROTATION_90);
@@ -4695,7 +4695,7 @@
}
TEST_F(CursorInputMapperTest, ConfigureDisplayId_IgnoresEventsForMismatchedPointerDisplay) {
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
// Set up the default display as the display on which the pointer should be shown.
prepareDisplay(ui::ROTATION_90);
@@ -4728,7 +4728,7 @@
TEST_F(BluetoothCursorInputMapperTest, TimestampSmoothening) {
addConfigurationProperty("cursor.mode", "pointer");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
nsecs_t kernelEventTime = ARBITRARY_TIME;
nsecs_t expectedEventTime = ARBITRARY_TIME;
@@ -4755,7 +4755,7 @@
TEST_F(BluetoothCursorInputMapperTest, TimestampSmootheningIsCapped) {
addConfigurationProperty("cursor.mode", "pointer");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
nsecs_t expectedEventTime = ARBITRARY_TIME;
process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_X, 1);
@@ -4792,7 +4792,7 @@
TEST_F(BluetoothCursorInputMapperTest, TimestampSmootheningNotUsed) {
addConfigurationProperty("cursor.mode", "pointer");
- CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
+ CursorInputMapper& mapper = constructAndAddMapper<CursorInputMapper>();
nsecs_t kernelEventTime = ARBITRARY_TIME;
nsecs_t expectedEventTime = ARBITRARY_TIME;