Client tests: Add simple test for mouse click

Change-Id: I2eb9bf8aa03e8df61a26d26da061f4030d8de0be
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2018-12-13 09:05:51 +01:00 committed by Johan Helsing
parent 98b7643fdd
commit ed34fa051d

View File

@ -62,6 +62,7 @@ private slots:
void createsPointer();
void setsCursorOnEnter();
void usesEnterSerial();
void mousePress();
void simpleAxis_data();
void simpleAxis();
void invalidPointerEvents();
@ -114,6 +115,28 @@ void tst_seatv4::usesEnterSerial()
QCOMPARE(setCursorSpy.takeFirst().at(0).toUInt(), enterSerial);
}
void tst_seatv4::mousePress()
{
class Window : public QRasterWindow {
public:
void mousePressEvent(QMouseEvent *) override { m_pressed = true; }
bool m_pressed = false;
};
Window window;
window.resize(64, 64);
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([&] {
auto *surface = xdgSurface()->m_surface;
pointer()->sendEnter(surface, {32, 32});
pointer()->sendButton(client(), BTN_LEFT, 1);
pointer()->sendButton(client(), BTN_LEFT, 0);
});
QTRY_VERIFY(window.m_pressed);
}
void tst_seatv4::simpleAxis_data()
{
QTest::addColumn<uint>("axis");