diff --git a/autotests/wayland/lockscreen.cpp b/autotests/wayland/lockscreen.cpp index 5498c0ef2a..4d40bb25a8 100644 --- a/autotests/wayland/lockscreen.cpp +++ b/autotests/wayland/lockscreen.cpp @@ -31,6 +31,7 @@ along with this program. If not, see . #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ private Q_SLOTS: void testPointer(); void testPointerButton(); void testPointerAxis(); + void testKeyboard(); void testScreenEdge(); void testEffects(); void testEffectsKeyboard(); @@ -404,6 +406,61 @@ void LockScreenTest::testPointerAxis() QVERIFY(axisChangedSpy.wait()); } +void LockScreenTest::testKeyboard() +{ + using namespace KWayland::Client; + + QScopedPointer keyboard(m_seat->createKeyboard()); + QVERIFY(!keyboard.isNull()); + QSignalSpy enteredSpy(keyboard.data(), &Keyboard::entered); + QVERIFY(enteredSpy.isValid()); + QSignalSpy leftSpy(keyboard.data(), &Keyboard::left); + QVERIFY(leftSpy.isValid()); + QSignalSpy keyChangedSpy(keyboard.data(), &Keyboard::keyChanged); + QVERIFY(keyChangedSpy.isValid()); + + AbstractClient *c = showWindow(); + QVERIFY(c); + QVERIFY(enteredSpy.wait()); + QTRY_COMPARE(enteredSpy.count(), 1); + + quint32 timestamp = 1; + KEYPRESS(KEY_A); + QVERIFY(keyChangedSpy.wait()); + QCOMPARE(keyChangedSpy.count(), 1); + QCOMPARE(keyChangedSpy.at(0).at(0).value(), quint32(KEY_A)); + QCOMPARE(keyChangedSpy.at(0).at(1).value(), Keyboard::KeyState::Pressed); + QCOMPARE(keyChangedSpy.at(0).at(2).value(), quint32(1)); + KEYRELEASE(KEY_A); + QVERIFY(keyChangedSpy.wait()); + QCOMPARE(keyChangedSpy.count(), 2); + QCOMPARE(keyChangedSpy.at(1).at(0).value(), quint32(KEY_A)); + QCOMPARE(keyChangedSpy.at(1).at(1).value(), Keyboard::KeyState::Released); + QCOMPARE(keyChangedSpy.at(1).at(2).value(), quint32(2)); + + LOCK + KEYPRESS(KEY_B); + KEYRELEASE(KEY_B); + QVERIFY(leftSpy.wait()); + QCOMPARE(leftSpy.count(), 1); + QCOMPARE(keyChangedSpy.count(), 2); + + UNLOCK + KEYPRESS(KEY_C); + QVERIFY(keyChangedSpy.wait()); + QCOMPARE(keyChangedSpy.count(), 3); + KEYRELEASE(KEY_C); + QVERIFY(keyChangedSpy.wait()); + QCOMPARE(keyChangedSpy.count(), 4); + QCOMPARE(enteredSpy.count(), 2); + QCOMPARE(keyChangedSpy.at(2).at(0).value(), quint32(KEY_C)); + QCOMPARE(keyChangedSpy.at(3).at(0).value(), quint32(KEY_C)); + QCOMPARE(keyChangedSpy.at(2).at(2).value(), quint32(5)); + QCOMPARE(keyChangedSpy.at(3).at(2).value(), quint32(6)); + QCOMPARE(keyChangedSpy.at(2).at(1).value(), Keyboard::KeyState::Pressed); + QCOMPARE(keyChangedSpy.at(3).at(1).value(), Keyboard::KeyState::Released); +} + void LockScreenTest::testScreenEdge() { QSignalSpy screenEdgeSpy(ScreenEdges::self(), &ScreenEdges::approaching);