[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.
This commit is contained in:
Martin Gräßlin 2016-08-16 10:23:37 +02:00
parent 697ea3ae00
commit ca50a24728
2 changed files with 34 additions and 3 deletions

View file

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/ *********************************************************************/
#include "kwin_wayland_test.h" #include "kwin_wayland_test.h"
#include "shell_client.h" #include "shell_client.h"
#include "screenlockerwatcher.h"
#include "wayland_server.h" #include "wayland_server.h"
#include <KWayland/Client/compositor.h> #include <KWayland/Client/compositor.h>
@ -378,7 +379,22 @@ bool lockScreen()
if (lockStateChangedSpy.count() != 1) { if (lockStateChangedSpy.count() != 1) {
return false; 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() bool unlockScreen()
@ -399,7 +415,22 @@ bool unlockScreen()
if (waylandServer()->isScreenLocked()) { if (waylandServer()->isScreenLocked()) {
lockStateChangedSpy.wait(); 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;
} }
} }

View file

@ -31,7 +31,7 @@ class QDBusPendingCallWatcher;
namespace KWin namespace KWin
{ {
class ScreenLockerWatcher : public QObject class KWIN_EXPORT ScreenLockerWatcher : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public: