|
27 | 27 | #include <com_android_input_flags.h> |
28 | 28 | #include <gmock/gmock.h> |
29 | 29 | #include <gtest/gtest.h> |
| 30 | +#include <input/AccelerationCurve.h> |
30 | 31 | #include <input/DisplayViewport.h> |
31 | 32 | #include <input/InputEventLabels.h> |
32 | 33 | #include <linux/input-event-codes.h> |
@@ -1028,6 +1029,34 @@ TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdNoAssociatedViewport) { |
1028 | 1029 | WithCoords(0.0f, 0.0f))))); |
1029 | 1030 | } |
1030 | 1031 |
|
| 1032 | +TEST_F(CursorInputMapperUnitTest, PointerAccelerationDisabled) { |
| 1033 | + mReaderConfiguration.mousePointerAccelerationEnabled = false; |
| 1034 | + mReaderConfiguration.mousePointerSpeed = 3; |
| 1035 | + mPropertyMap.addProperty("cursor.mode", "pointer"); |
| 1036 | + createMapper(); |
| 1037 | + |
| 1038 | + std::list<NotifyArgs> reconfigureArgs; |
| 1039 | + |
| 1040 | + reconfigureArgs += mMapper->reconfigure(ARBITRARY_TIME, mReaderConfiguration, |
| 1041 | + InputReaderConfiguration::Change::POINTER_SPEED); |
| 1042 | + |
| 1043 | + std::vector<AccelerationCurveSegment> curve = |
| 1044 | + createFlatAccelerationCurve(mReaderConfiguration.mousePointerSpeed); |
| 1045 | + double baseGain = curve[0].baseGain; |
| 1046 | + |
| 1047 | + std::list<NotifyArgs> motionArgs; |
| 1048 | + motionArgs += process(ARBITRARY_TIME, EV_REL, REL_X, 10); |
| 1049 | + motionArgs += process(ARBITRARY_TIME, EV_REL, REL_Y, 20); |
| 1050 | + motionArgs += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0); |
| 1051 | + |
| 1052 | + const float expectedRelX = 10 * baseGain; |
| 1053 | + const float expectedRelY = 20 * baseGain; |
| 1054 | + ASSERT_THAT(motionArgs, |
| 1055 | + ElementsAre(VariantWith<NotifyMotionArgs>( |
| 1056 | + AllOf(WithMotionAction(HOVER_MOVE), |
| 1057 | + WithRelativeMotion(expectedRelX, expectedRelY))))); |
| 1058 | +} |
| 1059 | + |
1031 | 1060 | TEST_F(CursorInputMapperUnitTest, ConfigureAccelerationWithAssociatedViewport) { |
1032 | 1061 | mPropertyMap.addProperty("cursor.mode", "pointer"); |
1033 | 1062 | DisplayViewport primaryViewport = createPrimaryViewport(ui::Rotation::Rotation0); |
|
0 commit comments