[autotest/intergration] Wait for pointer enter before simulating button press

The test LockScreenTest::testPointerButton and testPointerAxis both
fail on Neon's CI infrastructure. In order to make the test more reliable
the tests first wait for the pointer enter after unlock before simulating
another button press.
This commit is contained in:
Martin Gräßlin 2016-08-08 11:12:22 +02:00
parent 23bfa05f46
commit a1490905e9

View file

@ -270,6 +270,8 @@ void LockScreenTest::testPointerButton()
QScopedPointer<Pointer> pointer(m_seat->createPointer()); QScopedPointer<Pointer> pointer(m_seat->createPointer());
QVERIFY(!pointer.isNull()); QVERIFY(!pointer.isNull());
QSignalSpy enteredSpy(pointer.data(), &Pointer::entered);
QVERIFY(enteredSpy.isValid());
QSignalSpy buttonChangedSpy(pointer.data(), &Pointer::buttonStateChanged); QSignalSpy buttonChangedSpy(pointer.data(), &Pointer::buttonStateChanged);
QVERIFY(buttonChangedSpy.isValid()); QVERIFY(buttonChangedSpy.isValid());
@ -279,6 +281,7 @@ void LockScreenTest::testPointerButton()
// first move cursor into the center of the window // first move cursor into the center of the window
quint32 timestamp = 1; quint32 timestamp = 1;
MOTION(c->geometry().center()); MOTION(c->geometry().center());
QVERIFY(enteredSpy.wait());
// and simulate a click // and simulate a click
PRESS; PRESS;
QVERIFY(buttonChangedSpy.wait()); QVERIFY(buttonChangedSpy.wait());
@ -294,6 +297,8 @@ void LockScreenTest::testPointerButton()
QVERIFY(!buttonChangedSpy.wait(100)); QVERIFY(!buttonChangedSpy.wait(100));
UNLOCK UNLOCK
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.count(), 2);
// and click again // and click again
PRESS; PRESS;
@ -310,6 +315,8 @@ void LockScreenTest::testPointerAxis()
QVERIFY(!pointer.isNull()); QVERIFY(!pointer.isNull());
QSignalSpy axisChangedSpy(pointer.data(), &Pointer::axisChanged); QSignalSpy axisChangedSpy(pointer.data(), &Pointer::axisChanged);
QVERIFY(axisChangedSpy.isValid()); QVERIFY(axisChangedSpy.isValid());
QSignalSpy enteredSpy(pointer.data(), &Pointer::entered);
QVERIFY(enteredSpy.isValid());
AbstractClient *c = showWindow(); AbstractClient *c = showWindow();
QVERIFY(c); QVERIFY(c);
@ -317,6 +324,7 @@ void LockScreenTest::testPointerAxis()
// first move cursor into the center of the window // first move cursor into the center of the window
quint32 timestamp = 1; quint32 timestamp = 1;
MOTION(c->geometry().center()); MOTION(c->geometry().center());
QVERIFY(enteredSpy.wait());
// and simulate axis // and simulate axis
kwinApp()->platform()->pointerAxisHorizontal(5.0, timestamp++); kwinApp()->platform()->pointerAxisHorizontal(5.0, timestamp++);
QVERIFY(axisChangedSpy.wait()); QVERIFY(axisChangedSpy.wait());
@ -331,6 +339,8 @@ void LockScreenTest::testPointerAxis()
// and unlock // and unlock
UNLOCK UNLOCK
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.count(), 2);
// and move axis again // and move axis again
kwinApp()->platform()->pointerAxisHorizontal(5.0, timestamp++); kwinApp()->platform()->pointerAxisHorizontal(5.0, timestamp++);