Add client test for multi touch motion
Make sure touchPoint order doesn't change even though the compositor event order does. Task-number: QTBUG-77014 Change-Id: If6b8a930344836ca52cc12fe7f29c8ac863d81ba Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
36663a187d
commit
13055e46e3
@ -69,6 +69,7 @@ private slots:
|
||||
void createsTouch();
|
||||
void singleTap();
|
||||
void singleTapFloat();
|
||||
void multiTouch();
|
||||
};
|
||||
|
||||
void tst_seatv5::bindsToSeat()
|
||||
@ -463,5 +464,77 @@ void tst_seatv5::singleTapFloat()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_seatv5::multiTouch()
|
||||
{
|
||||
TouchWindow window;
|
||||
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
||||
|
||||
exec([=] {
|
||||
auto *t = touch();
|
||||
auto *c = client();
|
||||
|
||||
t->sendDown(xdgToplevel()->surface(), {32, 32}, 0);
|
||||
t->sendDown(xdgToplevel()->surface(), {48, 48}, 1);
|
||||
t->sendFrame(c);
|
||||
|
||||
// Compositor event order should not change the order of the QTouchEvent::touchPoints()
|
||||
// See QTBUG-77014
|
||||
t->sendMotion(c, {49, 48}, 1);
|
||||
t->sendMotion(c, {33, 32}, 0);
|
||||
t->sendFrame(c);
|
||||
|
||||
t->sendUp(c, 0);
|
||||
t->sendFrame(c);
|
||||
|
||||
t->sendUp(c, 1);
|
||||
t->sendFrame(c);
|
||||
});
|
||||
|
||||
QTRY_VERIFY(!window.m_events.empty());
|
||||
{
|
||||
auto e = window.m_events.takeFirst();
|
||||
QCOMPARE(e.type, QEvent::TouchBegin);
|
||||
QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointPressed);
|
||||
QCOMPARE(e.touchPoints.length(), 2);
|
||||
|
||||
QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointPressed);
|
||||
QCOMPARE(e.touchPoints[0].pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
|
||||
|
||||
QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointPressed);
|
||||
QCOMPARE(e.touchPoints[1].pos(), QPointF(48-window.frameMargins().left(), 48-window.frameMargins().top()));
|
||||
}
|
||||
{
|
||||
auto e = window.m_events.takeFirst();
|
||||
QCOMPARE(e.type, QEvent::TouchUpdate);
|
||||
QCOMPARE(e.touchPoints.length(), 2);
|
||||
|
||||
QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointMoved);
|
||||
QCOMPARE(e.touchPoints[0].pos(), QPointF(33-window.frameMargins().left(), 32-window.frameMargins().top()));
|
||||
|
||||
QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointMoved);
|
||||
QCOMPARE(e.touchPoints[1].pos(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top()));
|
||||
}
|
||||
{
|
||||
auto e = window.m_events.takeFirst();
|
||||
QCOMPARE(e.type, QEvent::TouchUpdate);
|
||||
QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointReleased | Qt::TouchPointState::TouchPointStationary);
|
||||
QCOMPARE(e.touchPoints.length(), 2);
|
||||
|
||||
QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointReleased);
|
||||
QCOMPARE(e.touchPoints[0].pos(), QPointF(33-window.frameMargins().left(), 32-window.frameMargins().top()));
|
||||
|
||||
QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointStationary);
|
||||
QCOMPARE(e.touchPoints[1].pos(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top()));
|
||||
}
|
||||
{
|
||||
auto e = window.m_events.takeFirst();
|
||||
QCOMPARE(e.type, QEvent::TouchEnd);
|
||||
QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointReleased);
|
||||
QCOMPARE(e.touchPoints.length(), 1);
|
||||
QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointReleased);
|
||||
QCOMPARE(e.touchPoints[0].pos(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top()));
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPOSITOR_TEST_MAIN(tst_seatv5)
|
||||
#include "tst_seatv5.moc"
|
||||
|
@ -424,6 +424,18 @@ uint Touch::sendUp(wl_client *client, int id)
|
||||
return serial;
|
||||
}
|
||||
|
||||
void Touch::sendMotion(wl_client *client, const QPointF &position, int id)
|
||||
{
|
||||
wl_fixed_t x = wl_fixed_from_double(position.x());
|
||||
wl_fixed_t y = wl_fixed_from_double(position.y());
|
||||
|
||||
auto time = m_seat->m_compositor->currentTimeMilliseconds();
|
||||
|
||||
const auto touchResources = resourceMap().values(client);
|
||||
for (auto *r : touchResources)
|
||||
wl_touch::send_motion(r->handle, time, id, x, y);
|
||||
}
|
||||
|
||||
void Touch::sendFrame(wl_client *client)
|
||||
{
|
||||
const auto touchResources = resourceMap().values(client);
|
||||
|
@ -318,6 +318,7 @@ public:
|
||||
explicit Touch(Seat *seat) : m_seat(seat) {}
|
||||
uint sendDown(Surface *surface, const QPointF &position, int id);
|
||||
uint sendUp(wl_client *client, int id);
|
||||
void sendMotion(wl_client *client, const QPointF &position, int id);
|
||||
void sendFrame(wl_client *client);
|
||||
|
||||
Seat *m_seat = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user