autotests: Improve running time of testPointerInput

master
Vlad Zahorodnii 1 year ago
parent 785fa5c172
commit 076493cc05

@ -607,6 +607,12 @@ bool waitForWaylandKeyboard();
void flushWaylandConnection();
/**
* Ensures that all client requests are processed by the compositor and all events
* sent by the compositor are seen by the client.
*/
bool waylandSync();
std::unique_ptr<KWayland::Client::Surface> createSurface();
KWayland::Client::SubSurface *createSubSurface(KWayland::Client::Surface *surface,
KWayland::Client::Surface *parentSurface, QObject *parent = nullptr);

@ -537,7 +537,8 @@ void PointerInputTest::testModifierClickUnrestrictedMove()
// all of that should not have triggered button events on the surface
QCOMPARE(buttonSpy.count(), 0);
// also waiting shouldn't give us the event
QVERIFY(!buttonSpy.wait(100));
QVERIFY(Test::waylandSync());
QCOMPARE(buttonSpy.count(), 0);
}
void PointerInputTest::testModifierClickUnrestrictedFullscreenMove()
@ -721,7 +722,8 @@ void PointerInputTest::testModifierScrollOpacity()
// axis should have been filtered out
QCOMPARE(axisSpy.count(), 0);
QVERIFY(!axisSpy.wait(100));
QVERIFY(Test::waylandSync());
QCOMPARE(axisSpy.count(), 0);
}
void PointerInputTest::testModifierScrollOpacityGlobalShortcutsDisabled()
@ -961,7 +963,6 @@ void PointerInputTest::testMouseActionInactiveWindow()
QVERIFY(!exclusiveContains(window2->frameGeometry(), QPointF(10, 10)));
input()->pointer()->warp(QPointF(10, 10));
// no focus follows mouse
QVERIFY(!stackingOrderChangedSpy.wait(200));
QVERIFY(stackingOrderChangedSpy.isEmpty());
QVERIFY(activeWindowChangedSpy.isEmpty());
QVERIFY(window2->isActive());
@ -1055,10 +1056,9 @@ void PointerInputTest::testMouseActionActiveWindow()
QVERIFY(buttonSpy.wait());
if (clickRaise) {
QCOMPARE(stackingOrderChangedSpy.count(), 1);
QTRY_COMPARE_WITH_TIMEOUT(workspace()->topWindowOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window2, 200);
QCOMPARE(workspace()->topWindowOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window2);
} else {
QCOMPARE(stackingOrderChangedSpy.count(), 0);
QVERIFY(!stackingOrderChangedSpy.wait(100));
QCOMPARE(workspace()->topWindowOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window1);
}
@ -1237,7 +1237,8 @@ void PointerInputTest::testEffectOverrideCursorImage()
// move cursor to area of window
input()->pointer()->warp(window->frameGeometry().center());
// this should not result in an enter event
QVERIFY(!enteredSpy.wait(100));
QVERIFY(Test::waylandSync());
QCOMPARE(enteredSpy.count(), 1);
// after ending the interception we should get an enter event
effects->stopMouseInterception(effect.get());
@ -1439,7 +1440,8 @@ void PointerInputTest::testWindowUnderCursorWhileButtonPressed()
QVERIFY(popupWindow != window);
QVERIFY(exclusiveContains(window->frameGeometry(), Cursors::self()->mouse()->pos()));
QVERIFY(exclusiveContains(popupWindow->frameGeometry(), Cursors::self()->mouse()->pos()));
QVERIFY(!leftSpy.wait());
QVERIFY(Test::waylandSync());
QCOMPARE(leftSpy.count(), 0);
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
// now that the button is no longer pressed we should get the leave event

@ -771,6 +771,44 @@ void flushWaylandConnection()
}
}
class WaylandSyncPoint : public QObject
{
Q_OBJECT
public:
explicit WaylandSyncPoint(KWayland::Client::ConnectionThread *connection, KWayland::Client::EventQueue *eventQueue)
{
static const wl_callback_listener listener = {
.done = [](void *data, wl_callback *callback, uint32_t callback_data) {
auto syncPoint = static_cast<WaylandSyncPoint *>(data);
Q_EMIT syncPoint->done();
},
};
m_callback = wl_display_sync(connection->display());
eventQueue->addProxy(m_callback);
wl_callback_add_listener(m_callback, &listener, this);
}
~WaylandSyncPoint() override
{
wl_callback_destroy(m_callback);
}
Q_SIGNALS:
void done();
private:
wl_callback *m_callback;
};
bool waylandSync()
{
WaylandSyncPoint syncPoint(s_waylandConnection.connection, s_waylandConnection.queue);
QSignalSpy doneSpy(&syncPoint, &WaylandSyncPoint::done);
return doneSpy.wait();
}
std::unique_ptr<KWayland::Client::Surface> createSurface()
{
if (!s_waylandConnection.compositor) {
@ -1516,3 +1554,5 @@ void touchUp(qint32 id, quint32 time)
}
}
}
#include "test_helpers.moc"

Loading…
Cancel
Save