From ca50a247282016c9f63e59bcdfc267354351dfc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 16 Aug 2016 10:23:37 +0200 Subject: [PATCH] [autotests/integration] Add ScreenLockerWatcher to the Test::lockScreen and ::unlockScreen This extends the test helper for locking the screen and unlocking the screen to also wait for the ScreenLockerWatcher to have that state. This is going to fail on build.kde.org as we don't have EGL there and the greeter crashes. This needs an extension to fake that we have a screen lock window. --- autotests/integration/test_helpers.cpp | 35 ++++++++++++++++++++++++-- screenlockerwatcher.h | 2 +- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/autotests/integration/test_helpers.cpp b/autotests/integration/test_helpers.cpp index 7686b43945..e30405a449 100644 --- a/autotests/integration/test_helpers.cpp +++ b/autotests/integration/test_helpers.cpp @@ -19,6 +19,7 @@ along with this program. If not, see . *********************************************************************/ #include "kwin_wayland_test.h" #include "shell_client.h" +#include "screenlockerwatcher.h" #include "wayland_server.h" #include @@ -378,7 +379,22 @@ bool lockScreen() if (lockStateChangedSpy.count() != 1) { return false; } - return waylandServer()->isScreenLocked(); + if (!waylandServer()->isScreenLocked()) { + return false; + } + if (!ScreenLockerWatcher::self()->isLocked()) { + QSignalSpy lockedSpy(ScreenLockerWatcher::self(), &ScreenLockerWatcher::locked); + if (!lockedSpy.isValid()) { + return false; + } + if (!lockedSpy.wait()) { + return false; + } + if (!ScreenLockerWatcher::self()->isLocked()) { + return false; + } + } + return true; } bool unlockScreen() @@ -399,7 +415,22 @@ bool unlockScreen() if (waylandServer()->isScreenLocked()) { lockStateChangedSpy.wait(); } - return !waylandServer()->isScreenLocked(); + if (waylandServer()->isScreenLocked()) { + return true; + } + if (ScreenLockerWatcher::self()->isLocked()) { + QSignalSpy lockedSpy(ScreenLockerWatcher::self(), &ScreenLockerWatcher::locked); + if (!lockedSpy.isValid()) { + return false; + } + if (!lockedSpy.wait()) { + return false; + } + if (ScreenLockerWatcher::self()->isLocked()) { + return false; + } + } + return true; } } diff --git a/screenlockerwatcher.h b/screenlockerwatcher.h index fa4d636a6a..99bc503447 100644 --- a/screenlockerwatcher.h +++ b/screenlockerwatcher.h @@ -31,7 +31,7 @@ class QDBusPendingCallWatcher; namespace KWin { -class ScreenLockerWatcher : public QObject +class KWIN_EXPORT ScreenLockerWatcher : public QObject { Q_OBJECT public: