Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 597edb3e authored by Yeabkal Wubshit's avatar Yeabkal Wubshit Committed by Android (Google) Code Review
Browse files

Merge "Create Native VelocityTracker#isAxisSupported Function"

parents 7a18134f eca273cd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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();

+4 −0
Original line number Diff line number Diff line
@@ -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();

+20 −0
Original line number Diff line number Diff line
@@ -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 =====================================
 */