Changeset View
Changeset View
Standalone View
Standalone View
autotests/libinput/touch_event_test.cpp
Show All 34 Lines | |||||
35 | private Q_SLOTS: | 35 | private Q_SLOTS: | ||
36 | void init(); | 36 | void init(); | ||
37 | void cleanup(); | 37 | void cleanup(); | ||
38 | 38 | | |||
39 | void testType_data(); | 39 | void testType_data(); | ||
40 | void testType(); | 40 | void testType(); | ||
41 | void testAbsoluteMotion_data(); | 41 | void testAbsoluteMotion_data(); | ||
42 | void testAbsoluteMotion(); | 42 | void testAbsoluteMotion(); | ||
43 | void testNoAssignedSlot(); | ||||
43 | 44 | | |||
44 | private: | 45 | private: | ||
45 | libinput_device *m_nativeDevice = nullptr; | 46 | libinput_device *m_nativeDevice = nullptr; | ||
46 | Device *m_device = nullptr; | 47 | Device *m_device = nullptr; | ||
47 | }; | 48 | }; | ||
48 | 49 | | |||
49 | void TestLibinputTouchEvent::init() | 50 | void TestLibinputTouchEvent::init() | ||
50 | { | 51 | { | ||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 111 | { | |||
121 | auto te = dynamic_cast<TouchEvent*>(event.data()); | 122 | auto te = dynamic_cast<TouchEvent*>(event.data()); | ||
122 | QVERIFY(te); | 123 | QVERIFY(te); | ||
123 | QCOMPARE(te->type(), type); | 124 | QCOMPARE(te->type(), type); | ||
124 | QCOMPARE(te->time(), 500u); | 125 | QCOMPARE(te->time(), 500u); | ||
125 | QCOMPARE(te->absolutePos(), QPointF(6.25, 6.9)); | 126 | QCOMPARE(te->absolutePos(), QPointF(6.25, 6.9)); | ||
126 | QCOMPARE(te->absolutePos(QSize(1280, 1024)), QPointF(640, 512)); | 127 | QCOMPARE(te->absolutePos(QSize(1280, 1024)), QPointF(640, 512)); | ||
127 | } | 128 | } | ||
128 | 129 | | |||
130 | void TestLibinputTouchEvent::testNoAssignedSlot() | ||||
131 | { | ||||
132 | // this test verifies that touch events without an assigned slot get id == 0 | ||||
133 | libinput_event_touch *touchEvent = new libinput_event_touch; | ||||
134 | touchEvent->type = LIBINPUT_EVENT_TOUCH_UP; | ||||
135 | touchEvent->device = m_nativeDevice; | ||||
136 | // touch events without an assigned slot have slot == -1 | ||||
137 | touchEvent->slot = -1; | ||||
138 | | ||||
139 | QScopedPointer<Event> event(Event::create(touchEvent)); | ||||
140 | QVERIFY(dynamic_cast<TouchEvent*>(event.data())); | ||||
141 | QCOMPARE(dynamic_cast<TouchEvent*>(event.data())->id(), 0); | ||||
142 | } | ||||
143 | | ||||
129 | QTEST_GUILESS_MAIN(TestLibinputTouchEvent) | 144 | QTEST_GUILESS_MAIN(TestLibinputTouchEvent) | ||
130 | #include "touch_event_test.moc" | 145 | #include "touch_event_test.moc" |