From c793d5d61930b1d61d1b2ecfbb3b1ac92d740c7c Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 3 Dec 2020 11:37:28 +0200 Subject: [PATCH] autotests: Fix PointerInputTest The "Active screen follows mouse" option may make the test fail. We want it to pass no matter what the current value of the option is. --- autotests/integration/pointer_input.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/autotests/integration/pointer_input.cpp b/autotests/integration/pointer_input.cpp index 89b0451f8d..9871f8daa1 100644 --- a/autotests/integration/pointer_input.cpp +++ b/autotests/integration/pointer_input.cpp @@ -319,8 +319,6 @@ void PointerInputTest::testUpdateFocusAfterScreenChange() // this test verifies that a pointer enter event is generated when the cursor changes to another // screen due to removal of screen using namespace KWayland::Client; - // ensure cursor is on second screen - Cursors::self()->mouse()->setPos(1500, 300); // create pointer and signal spy for enter and motion auto pointer = m_seat->createPointer(m_seat); @@ -328,6 +326,8 @@ void PointerInputTest::testUpdateFocusAfterScreenChange() QVERIFY(pointer->isValid()); QSignalSpy enteredSpy(pointer, &Pointer::entered); QVERIFY(enteredSpy.isValid()); + QSignalSpy leftSpy(pointer, &Pointer::left); + QVERIFY(leftSpy.isValid()); // create a window QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded); @@ -340,7 +340,13 @@ void PointerInputTest::testUpdateFocusAfterScreenChange() QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); + QVERIFY(window->frameGeometry().contains(Cursors::self()->mouse()->pos())); + QTRY_COMPARE(enteredSpy.count(), 1); + + // move the cursor to the second screen + Cursors::self()->mouse()->setPos(1500, 300); QVERIFY(!window->frameGeometry().contains(Cursors::self()->mouse()->pos())); + QVERIFY(leftSpy.wait()); QSignalSpy screensChangedSpy(screens(), &Screens::changed); QVERIFY(screensChangedSpy.isValid()); @@ -357,7 +363,7 @@ void PointerInputTest::testUpdateFocusAfterScreenChange() QVERIFY(window->frameGeometry().contains(Cursors::self()->mouse()->pos())); // and we should get an enter event - QTRY_COMPARE(enteredSpy.count(), 1); + QTRY_COMPARE(enteredSpy.count(), 2); } void PointerInputTest::testModifierClickUnrestrictedMove_data()