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: