From f2f9aea11eb5038dc8b86498ecc942c2b40ad580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 18 Jan 2017 20:24:17 +0100 Subject: [PATCH] [autotests] Fix LockScreenTest::testKeyboardShortcut 32f4e115e2c68b75a5eea86e0a582388d5abadb9 broke the test. To my surprise there was a test using the kwin internal shortcut handling instead of using KGlobalAccel. This change adjusts the test to go through KGlobalAccel for testing the global shortcut. --- autotests/integration/lockscreen.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/autotests/integration/lockscreen.cpp b/autotests/integration/lockscreen.cpp index 0f645fdb41..1460c9736d 100644 --- a/autotests/integration/lockscreen.cpp +++ b/autotests/integration/lockscreen.cpp @@ -43,6 +43,8 @@ along with this program. If not, see . //screenlocker #include +#include + #include Q_DECLARE_METATYPE(Qt::Orientation) @@ -680,7 +682,11 @@ void LockScreenTest::testKeyboardShortcut() 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()); + action->setProperty("componentName", QStringLiteral(KWIN_NAME)); + action->setObjectName("LockScreenTest::testKeyboardShortcut"); + KGlobalAccel::self()->setDefaultShortcut(action.data(), QList{Qt::CTRL + Qt::META + Qt::ALT + Qt::Key_Space}); + KGlobalAccel::self()->setShortcut(action.data(), QList{Qt::CTRL + Qt::META + Qt::ALT + Qt::Key_Space}, + KGlobalAccel::NoAutoloading); // try to trigger the shortcut quint32 timestamp = 1; @@ -688,26 +694,26 @@ void LockScreenTest::testKeyboardShortcut() KEYPRESS(KEY_LEFTMETA); KEYPRESS(KEY_LEFTALT); KEYPRESS(KEY_SPACE); - QCoreApplication::instance()->processEvents(); + QVERIFY(actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); KEYRELEASE(KEY_SPACE); - QCoreApplication::instance()->processEvents(); + QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); LOCK KEYPRESS(KEY_SPACE); - QCoreApplication::instance()->processEvents(); + QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); KEYRELEASE(KEY_SPACE); - QCoreApplication::instance()->processEvents(); + QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); UNLOCK KEYPRESS(KEY_SPACE); - QCoreApplication::instance()->processEvents(); + QVERIFY(actionSpy.wait()); QCOMPARE(actionSpy.count(), 2); KEYRELEASE(KEY_SPACE); - QCoreApplication::instance()->processEvents(); + QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 2); KEYRELEASE(KEY_LEFTCTRL); KEYRELEASE(KEY_LEFTMETA);