From b905fa0f68ddefba999a3945674c75848a8ef2cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 2 Feb 2016 10:22:37 +0100 Subject: [PATCH] [autotests] Adjust lockscreen test to improvements in KSld On the CI system our tests failed due to the greeter failing to start due to OpenGL problems. This was because we waited for a window to show which never happened. Thus the test failed. This change makes use of the new lockStateChanged signal to determine when the screen gets locked/unlocked. It's still possible that the test fails as I'm not able to reproduce the failure condition on the CI system. --- autotests/wayland/lockscreen.cpp | 37 +++++++++++++++----------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/autotests/wayland/lockscreen.cpp b/autotests/wayland/lockscreen.cpp index 9ebfc3bf5c..0822f29f9f 100644 --- a/autotests/wayland/lockscreen.cpp +++ b/autotests/wayland/lockscreen.cpp @@ -218,15 +218,12 @@ void LockScreenTest::testPointer() waylandServer()->backend()->pointerMotion(c->geometry().center(), timestamp++); QVERIFY(enteredSpy.wait()); - // TODO: we need a proper signal to check whether screen is locked QVERIFY(!waylandServer()->isScreenLocked()); + QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); + QVERIFY(lockStateChangedSpy.isValid()); ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); - QVERIFY(clientAddedSpy.wait()); - QVERIFY(clientAddedSpy.last().first().value()->isLockScreen()); + QCOMPARE(lockStateChangedSpy.count(), 1); QVERIFY(waylandServer()->isScreenLocked()); - // two screen setup should give us two lock windows - QVERIFY(clientAddedSpy.wait()); - QVERIFY(clientAddedSpy.last().first().value()->isLockScreen()); QEXPECT_FAIL("", "Adding the lock screen window should send left event", Continue); QVERIFY(leftSpy.wait(100)); @@ -245,11 +242,12 @@ void LockScreenTest::testPointer() // go back on the window waylandServer()->backend()->pointerMotion(c->geometry().center(), timestamp++); // and unlock - QSignalSpy shellClientRemovedSpy(waylandServer(), &WaylandServer::shellClientRemoved); - QVERIFY(shellClientRemovedSpy.isValid()); + QCOMPARE(lockStateChangedSpy.count(), 1); unlock(); - QVERIFY(shellClientRemovedSpy.wait()); - QCOMPARE(shellClientRemovedSpy.count(), 2); + if (lockStateChangedSpy.count() < 2) { + QVERIFY(lockStateChangedSpy.wait()); + } + QCOMPARE(lockStateChangedSpy.count(), 2); QVERIFY(!waylandServer()->isScreenLocked()); QEXPECT_FAIL("", "Focus doesn't move back on surface removal", Continue); @@ -305,15 +303,12 @@ void LockScreenTest::testPointerButton() waylandServer()->backend()->pointerButtonReleased(BTN_LEFT, timestamp++); QVERIFY(buttonChangedSpy.wait()); - // TODO: we need a proper signal to check whether screen is locked QVERIFY(!waylandServer()->isScreenLocked()); + QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); + QVERIFY(lockStateChangedSpy.isValid()); ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); - QVERIFY(clientAddedSpy.wait()); - QVERIFY(clientAddedSpy.last().first().value()->isLockScreen()); + QCOMPARE(lockStateChangedSpy.count(), 1); QVERIFY(waylandServer()->isScreenLocked()); - // two screen setup should give us two lock windows - QVERIFY(clientAddedSpy.wait()); - QVERIFY(clientAddedSpy.last().first().value()->isLockScreen()); // and simulate a click waylandServer()->backend()->pointerButtonPressed(BTN_LEFT, timestamp++); @@ -322,13 +317,15 @@ void LockScreenTest::testPointerButton() QVERIFY(!buttonChangedSpy.wait(100)); // and unlock - QSignalSpy shellClientRemovedSpy(waylandServer(), &WaylandServer::shellClientRemoved); - QVERIFY(shellClientRemovedSpy.isValid()); + QCOMPARE(lockStateChangedSpy.count(), 1); unlock(); - QVERIFY(shellClientRemovedSpy.wait()); - QCOMPARE(shellClientRemovedSpy.count(), 2); + if (lockStateChangedSpy.count() < 2) { + QVERIFY(lockStateChangedSpy.wait()); + } + QCOMPARE(lockStateChangedSpy.count(), 2); QVERIFY(!waylandServer()->isScreenLocked()); + // and click again waylandServer()->backend()->pointerButtonPressed(BTN_LEFT, timestamp++); QVERIFY(buttonChangedSpy.wait());