Commit ca50a247 authored by Martin Flöser's avatar Martin Flöser
Browse files

[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.
parent 697ea3ae
......@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "kwin_wayland_test.h"
#include "shell_client.h"
#include "screenlockerwatcher.h"
#include "wayland_server.h"
#include <KWayland/Client/compositor.h>
......@@ -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;
}
}
......
......@@ -31,7 +31,7 @@ class QDBusPendingCallWatcher;
namespace KWin
{
class ScreenLockerWatcher : public QObject
class KWIN_EXPORT ScreenLockerWatcher : public QObject
{
Q_OBJECT
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment