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

Commit 635cb71a authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Fix broken input tests

InputPublisherAndConsumer_test currently segfaults due to
null pointer dereference. This is because 0 is passed instead
of a valid pointer to an allocated int32_t. Also, enforce strict
compiler warnings, include signed comparisons.

Bug: 62033391
Test: m -j libinput_tests_InputEvent_test
libinput_tests_InputChannel_test
libinput_tests_InputPublisherAndConsumer_test
libinput_tests_InputTransport_test libinput_tests_VelocityTracker_test
&& adb push out/target/product/taimen/data/nativetest/libinput_tests/
/data/nativetest/
then run the above tests individually, for example
/data/nativetest/libinput_tests # ./InputPublisherAndConsumer_test
and others in a similar manner

Change-Id: Ia030cdbfa22d2bf7bdf6274a337b059ca3f9a6c3
parent d134b226
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -455,7 +455,6 @@ private:
            int32_t* displayId);

    void updateTouchState(InputMessage& msg);
    bool rewriteMessage(const TouchState& state, InputMessage& msg);
    void resampleTouchState(nsecs_t frameTime, MotionEvent* event,
            const InputMessage *next);

@@ -464,6 +463,7 @@ private:

    status_t sendUnchainedFinishedSignal(uint32_t seq, bool handled);

    static bool rewriteMessage(const TouchState& state, InputMessage& msg);
    static void initializeKeyEvent(KeyEvent* event, const InputMessage* msg);
    static void initializeMotionEvent(MotionEvent* event, const InputMessage* msg);
    static void addSample(MotionEvent* event, const InputMessage* msg);
+1 −1
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@ cc_test {
    ],
    cflags: [
        "-Wall",
        "-Wextra",
        "-Werror",
        "-Wno-error=sign-compare", // to fix later
        "-Wno-unused-variable",
    ],
    shared_libs: [
+4 −4
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ TEST_F(KeyEventTest, Properties) {

    ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, event.getType());
    ASSERT_EQ(2, event.getDeviceId());
    ASSERT_EQ(AINPUT_SOURCE_GAMEPAD, event.getSource());
    ASSERT_EQ(static_cast<int>(AINPUT_SOURCE_GAMEPAD), event.getSource());
    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, event.getAction());
    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, event.getFlags());
    ASSERT_EQ(AKEYCODE_BUTTON_X, event.getKeyCode());
@@ -196,7 +196,7 @@ TEST_F(KeyEventTest, Properties) {

    // Set source.
    event.setSource(AINPUT_SOURCE_JOYSTICK);
    ASSERT_EQ(AINPUT_SOURCE_JOYSTICK, event.getSource());
    ASSERT_EQ(static_cast<int>(AINPUT_SOURCE_JOYSTICK), event.getSource());
}


@@ -300,7 +300,7 @@ void MotionEventTest::assertEqualsEventWithHistory(const MotionEvent* event) {
    // Check properties.
    ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, event->getType());
    ASSERT_EQ(2, event->getDeviceId());
    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, event->getSource());
    ASSERT_EQ(static_cast<int>(AINPUT_SOURCE_TOUCHSCREEN), event->getSource());
    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, event->getAction());
    ASSERT_EQ(AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED, event->getFlags());
    ASSERT_EQ(AMOTION_EVENT_EDGE_FLAG_TOP, event->getEdgeFlags());
@@ -432,7 +432,7 @@ TEST_F(MotionEventTest, Properties) {

    // Set source.
    event.setSource(AINPUT_SOURCE_JOYSTICK);
    ASSERT_EQ(AINPUT_SOURCE_JOYSTICK, event.getSource());
    ASSERT_EQ(static_cast<int>(AINPUT_SOURCE_JOYSTICK), event.getSource());

    // Set action.
    event.setAction(AMOTION_EVENT_ACTION_CANCEL);
+4 −3
Original line number Diff line number Diff line
@@ -89,8 +89,9 @@ void InputPublisherAndConsumerTest::PublishAndConsumeKeyEvent() {

    uint32_t consumeSeq;
    InputEvent* event;
    int32_t displayId;
    status = mConsumer->consume(&mEventFactory, true /*consumeBatches*/, -1, &consumeSeq, &event,
            0);
            &displayId);
    ASSERT_EQ(OK, status)
            << "consumer consume should return OK";

@@ -133,7 +134,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent() {
    const uint32_t seq = 15;
    const int32_t deviceId = 1;
    const int32_t source = AINPUT_SOURCE_TOUCHSCREEN;
    const int32_t displayId = 0;
    int32_t displayId = 0;
    const int32_t action = AMOTION_EVENT_ACTION_MOVE;
    const int32_t actionButton = 0;
    const int32_t flags = AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED;
@@ -176,7 +177,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent() {
    uint32_t consumeSeq;
    InputEvent* event;
    status = mConsumer->consume(&mEventFactory, true /*consumeBatches*/, -1, &consumeSeq, &event,
            0);
            &displayId);
    ASSERT_EQ(OK, status)
            << "consumer consume should return OK";

+2 −3
Original line number Diff line number Diff line
@@ -1993,10 +1993,10 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
            const PointerCoords* usingCoords = motionEntry->pointerCoords;

            // Set the X and Y offset depending on the input source.
            float xOffset, yOffset, scaleFactor;
            float xOffset, yOffset;
            if ((motionEntry->source & AINPUT_SOURCE_CLASS_POINTER)
                    && !(dispatchEntry->targetFlags & InputTarget::FLAG_ZERO_COORDS)) {
                scaleFactor = dispatchEntry->scaleFactor;
                float scaleFactor = dispatchEntry->scaleFactor;
                xOffset = dispatchEntry->xOffset * scaleFactor;
                yOffset = dispatchEntry->yOffset * scaleFactor;
                if (scaleFactor != 1.0f) {
@@ -2009,7 +2009,6 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
            } else {
                xOffset = 0.0f;
                yOffset = 0.0f;
                scaleFactor = 1.0f;

                // We don't want the dispatch target to know.
                if (dispatchEntry->targetFlags & InputTarget::FLAG_ZERO_COORDS) {
Loading