diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2018-12-13 09:39:05 +0100 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2019-01-30 14:35:10 +0000 |
commit | 276b15fa355ce3a2e92b307d340f2367ccac1843 (patch) | |
tree | 3d53bb231244740fe7e91e3a7da34605f72f0fc8 /tests/auto/client/seatv4 | |
parent | d0063d0972b29e9a2d4bdff837e3d4c23ac2e6cc (diff) |
Client tests: Add simple test for keyboard press
Change-Id: Ib28be5277af9145834c7808f993c747e21845616
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'tests/auto/client/seatv4')
-rw-r--r-- | tests/auto/client/seatv4/tst_seatv4.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/auto/client/seatv4/tst_seatv4.cpp b/tests/auto/client/seatv4/tst_seatv4.cpp index b6357a25b..f1e948ee2 100644 --- a/tests/auto/client/seatv4/tst_seatv4.cpp +++ b/tests/auto/client/seatv4/tst_seatv4.cpp @@ -46,7 +46,7 @@ public: removeAll<Seat>(); - uint capabilities = MockCompositor::Seat::capability_pointer; + uint capabilities = Seat::capability_pointer | Seat::capability_keyboard; int version = 4; add<Seat>(capabilities, version); }); @@ -67,6 +67,8 @@ private slots: void simpleAxis(); void invalidPointerEvents(); void scaledCursor(); + + void keyboardKeyPress(); }; void tst_seatv4::cleanup() @@ -287,5 +289,28 @@ void tst_seatv4::scaledCursor() exec([&] { remove(output(1)); }); } +void tst_seatv4::keyboardKeyPress() +{ + class Window : public QRasterWindow { + public: + void keyPressEvent(QKeyEvent *) override { m_pressed = true; } + bool m_pressed = false; + }; + + Window window; + window.resize(64, 64); + window.show(); + QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial); + + uint keyCode = 80; // arbitrarily chosen + exec([&] { + auto *surface = xdgSurface()->m_surface; + keyboard()->sendEnter(surface); + keyboard()->sendKey(client(), keyCode, Keyboard::key_state_pressed); + keyboard()->sendKey(client(), keyCode, Keyboard::key_state_released); + }); + QTRY_VERIFY(window.m_pressed); +} + QCOMPOSITOR_TEST_MAIN(tst_seatv4) #include "tst_seatv4.moc" |