Loading include/input/VelocityTracker.h +3 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,9 @@ public: ~VelocityTracker(); /** Return true if the axis is supported for velocity tracking, false otherwise. */ static bool isAxisSupported(int32_t axis); // Resets the velocity tracker state. void clear(); Loading libs/input/VelocityTracker.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,10 @@ VelocityTracker::VelocityTracker(const Strategy strategy) VelocityTracker::~VelocityTracker() { } bool VelocityTracker::isAxisSupported(int32_t axis) { return DEFAULT_STRATEGY_BY_AXIS.find(axis) != DEFAULT_STRATEGY_BY_AXIS.end(); } void VelocityTracker::configureStrategy(int32_t axis) { const bool isDifferentialAxis = DIFFERENTIAL_AXES.find(axis) != DIFFERENTIAL_AXES.end(); Loading libs/input/tests/VelocityTracker_test.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -298,6 +298,26 @@ static void computeAndCheckQuadraticEstimate(const std::vector<PlanarMotionEvent } } /* *================== VelocityTracker tests that do not require test motion data ==================== */ TEST(SimpleVelocityTrackerTest, TestSupportedAxis) { // Note that we are testing up to the max possible axis value, plus 3 more values. We are going // beyond the max value to add a bit more protection. "3" is chosen arbitrarily to cover a few // more values beyond the max. for (int32_t axis = 0; axis <= AMOTION_EVENT_MAXIMUM_VALID_AXIS_VALUE + 3; axis++) { switch (axis) { case AMOTION_EVENT_AXIS_X: case AMOTION_EVENT_AXIS_Y: case AMOTION_EVENT_AXIS_SCROLL: EXPECT_TRUE(VelocityTracker::isAxisSupported(axis)) << axis << " is supported"; break; default: EXPECT_FALSE(VelocityTracker::isAxisSupported(axis)) << axis << " is NOT supported"; } } } /* * ================== VelocityTracker tests generated manually ===================================== */ Loading Loading
include/input/VelocityTracker.h +3 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,9 @@ public: ~VelocityTracker(); /** Return true if the axis is supported for velocity tracking, false otherwise. */ static bool isAxisSupported(int32_t axis); // Resets the velocity tracker state. void clear(); Loading
libs/input/VelocityTracker.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,10 @@ VelocityTracker::VelocityTracker(const Strategy strategy) VelocityTracker::~VelocityTracker() { } bool VelocityTracker::isAxisSupported(int32_t axis) { return DEFAULT_STRATEGY_BY_AXIS.find(axis) != DEFAULT_STRATEGY_BY_AXIS.end(); } void VelocityTracker::configureStrategy(int32_t axis) { const bool isDifferentialAxis = DIFFERENTIAL_AXES.find(axis) != DIFFERENTIAL_AXES.end(); Loading
libs/input/tests/VelocityTracker_test.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -298,6 +298,26 @@ static void computeAndCheckQuadraticEstimate(const std::vector<PlanarMotionEvent } } /* *================== VelocityTracker tests that do not require test motion data ==================== */ TEST(SimpleVelocityTrackerTest, TestSupportedAxis) { // Note that we are testing up to the max possible axis value, plus 3 more values. We are going // beyond the max value to add a bit more protection. "3" is chosen arbitrarily to cover a few // more values beyond the max. for (int32_t axis = 0; axis <= AMOTION_EVENT_MAXIMUM_VALID_AXIS_VALUE + 3; axis++) { switch (axis) { case AMOTION_EVENT_AXIS_X: case AMOTION_EVENT_AXIS_Y: case AMOTION_EVENT_AXIS_SCROLL: EXPECT_TRUE(VelocityTracker::isAxisSupported(axis)) << axis << " is supported"; break; default: EXPECT_FALSE(VelocityTracker::isAxisSupported(axis)) << axis << " is NOT supported"; } } } /* * ================== VelocityTracker tests generated manually ===================================== */ Loading