diff --git a/autotests/wayland/lockscreen.cpp b/autotests/wayland/lockscreen.cpp index 60629fe4e1..5498c0ef2a 100644 --- a/autotests/wayland/lockscreen.cpp +++ b/autotests/wayland/lockscreen.cpp @@ -65,6 +65,7 @@ private Q_SLOTS: void testPointerShortcut(); void testAxisShortcut_data(); void testAxisShortcut(); + void testKeyboardShortcut(); private: void unlock(); @@ -630,6 +631,46 @@ void LockScreenTest::testAxisShortcut() #undef PERFORM } +void LockScreenTest::testKeyboardShortcut() +{ + using namespace KWayland::Client; + QScopedPointer action(new QAction(nullptr)); + QSignalSpy actionSpy(action.data(), &QAction::triggered); + QVERIFY(actionSpy.isValid()); + input()->registerShortcut(Qt::CTRL + Qt::META + Qt::ALT + Qt::Key_Space, action.data()); + + // try to trigger the shortcut + quint32 timestamp = 1; + KEYPRESS(KEY_LEFTCTRL); + KEYPRESS(KEY_LEFTMETA); + KEYPRESS(KEY_LEFTALT); + KEYPRESS(KEY_SPACE); + QCoreApplication::instance()->processEvents(); + QCOMPARE(actionSpy.count(), 1); + KEYRELEASE(KEY_SPACE); + QCoreApplication::instance()->processEvents(); + QCOMPARE(actionSpy.count(), 1); + + LOCK + KEYPRESS(KEY_SPACE); + QCoreApplication::instance()->processEvents(); + QCOMPARE(actionSpy.count(), 1); + KEYRELEASE(KEY_SPACE); + QCoreApplication::instance()->processEvents(); + QCOMPARE(actionSpy.count(), 1); + + UNLOCK + KEYPRESS(KEY_SPACE); + QCoreApplication::instance()->processEvents(); + QCOMPARE(actionSpy.count(), 2); + KEYRELEASE(KEY_SPACE); + QCoreApplication::instance()->processEvents(); + QCOMPARE(actionSpy.count(), 2); + KEYRELEASE(KEY_LEFTCTRL); + KEYRELEASE(KEY_LEFTMETA); + KEYRELEASE(KEY_LEFTALT); +} + } WAYLANTEST_MAIN(KWin::LockScreenTest)