summaryrefslogtreecommitdiffstats
path: root/tests/auto/client/seatv5/tst_seatv5.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-08-23 09:25:56 +0200
committerJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-08-27 12:35:33 +0200
commitb6703d94d833c73dbe7fd252c4b61db455f5c2f5 (patch)
tree9a4adc7ee9f1a1b6ef165ee8189d56439bcc4e4f /tests/auto/client/seatv5/tst_seatv5.cpp
parent4400d48cb6e8ab1b8676e198d4882b7a52310935 (diff)
Client tests: Add test for a simple wl_touch tap
Change-Id: I35aec950da0ac0d10cf1fa0c4bc1f56ba232cf89 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'tests/auto/client/seatv5/tst_seatv5.cpp')
-rw-r--r--tests/auto/client/seatv5/tst_seatv5.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/client/seatv5/tst_seatv5.cpp b/tests/auto/client/seatv5/tst_seatv5.cpp
index c2b1b0e4b..76a68b86f 100644
--- a/tests/auto/client/seatv5/tst_seatv5.cpp
+++ b/tests/auto/client/seatv5/tst_seatv5.cpp
@@ -67,6 +67,7 @@ private slots:
// Touch tests
void createsTouch();
+ void singleTap();
};
void tst_seatv5::bindsToSeat()
@@ -387,5 +388,64 @@ void tst_seatv5::createsTouch()
QCOMPOSITOR_TRY_COMPARE(touch()->resourceMap().first()->version(), 5);
}
+class TouchWindow : public QRasterWindow {
+public:
+ TouchWindow()
+ {
+ resize(64, 64);
+ show();
+ }
+ void touchEvent(QTouchEvent *event) override
+ {
+ QRasterWindow::touchEvent(event);
+ m_events.append(Event{event});
+ }
+ struct Event // Because I didn't find a convenient way to copy it entirely
+ {
+ explicit Event() = default;
+ explicit Event(const QTouchEvent *event)
+ : type(event->type())
+ , touchPointStates(event->touchPointStates())
+ , touchPoints(event->touchPoints())
+ {
+ }
+ const QEvent::Type type{};
+ const Qt::TouchPointStates touchPointStates{};
+ const QList<QTouchEvent::TouchPoint> touchPoints;
+ };
+ QVector<Event> m_events;
+};
+
+void tst_seatv5::singleTap()
+{
+ TouchWindow window;
+ QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
+
+ exec([=] {
+ auto *t = touch();
+ auto *c = client();
+ t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
+ 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(), 1);
+ QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-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.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
+ }
+}
+
QCOMPOSITOR_TEST_MAIN(tst_seatv5)
#include "tst_seatv5.moc"