From 500bc9c18c51ed2b414d7a8c54402f1912e8a3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 8 Feb 2016 15:23:06 +0100 Subject: [PATCH] [autotest] Add test case for global shortcuts while screen is locked They shouldn't be triggered if the screen is locked. --- autotests/wayland/lockscreen.cpp | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) 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)