diff --git a/autotests/integration/decoration_input_test.cpp b/autotests/integration/decoration_input_test.cpp --- a/autotests/integration/decoration_input_test.cpp +++ b/autotests/integration/decoration_input_test.cpp @@ -92,8 +92,6 @@ #define COMPARE(actual, expected) \ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ return nullptr; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - VERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(Test::waylandCompositor()); VERIFY(surface); @@ -107,13 +105,9 @@ VERIFY(decoSpy.wait()); COMPARE(deco->mode(), ServerSideDecoration::Mode::Server); // let's render - Test::render(surface, QSize(500, 50), Qt::blue); - - Test::flushWaylandConnection(); - VERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); + auto c = Test::renderAndWaitForShown(surface, QSize(500, 50), Qt::blue); VERIFY(c); - COMPARE(clientAddedSpy.first().first().value(), c); + COMPARE(workspace()->activeClient(), c); #undef VERIFY #undef COMPARE diff --git a/autotests/integration/dont_crash_cancel_animation.cpp b/autotests/integration/dont_crash_cancel_animation.cpp --- a/autotests/integration/dont_crash_cancel_animation.cpp +++ b/autotests/integration/dont_crash_cancel_animation.cpp @@ -52,10 +52,6 @@ void init(); void cleanup(); void testScript(); - -private: - void unlock(); - AbstractClient *showWindow(); }; void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase() @@ -101,21 +97,14 @@ using namespace KWayland::Client; // create a window - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - Surface *surface = Test::createSurface(Test::waylandCompositor()); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); // let's render - Test::render(surface, QSize(100, 50), Qt::blue); - - Test::flushWaylandConnection(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); + auto c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); // make sure we animate QTest::qWait(200); diff --git a/autotests/integration/dont_crash_no_border.cpp b/autotests/integration/dont_crash_no_border.cpp --- a/autotests/integration/dont_crash_no_border.cpp +++ b/autotests/integration/dont_crash_no_border.cpp @@ -98,8 +98,6 @@ { // create a window and ensure that this doesn't crash using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); @@ -113,13 +111,9 @@ QVERIFY(decoSpy.wait()); QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server); // let's render - Test::render(surface.data(), QSize(500, 50), Qt::blue); - - Test::flushWaylandConnection(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(500, 50), Qt::blue); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); QVERIFY(!c->isDecorated()); } diff --git a/autotests/integration/kwin_wayland_test.h b/autotests/integration/kwin_wayland_test.h --- a/autotests/integration/kwin_wayland_test.h +++ b/autotests/integration/kwin_wayland_test.h @@ -45,6 +45,8 @@ namespace KWin { +class ShellClient; + class WaylandTestApplication : public Application { Q_OBJECT @@ -116,6 +118,17 @@ * The @p surface gets damaged and committed, thus it's rendered. **/ void render(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32); + +/** + * Waits till a new ShellClient is shown and returns the created ShellClient. + * If no ShellClient gets shown during @p timeout @c null is returned. + **/ +ShellClient *waitForWaylandWindowShown(int timeout = 5000); + +/** + * Combination of @link{render} and @link{waitForWaylandWindowShown}. + **/ +ShellClient *renderAndWaitForShown(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32, int timeout = 5000); } } diff --git a/autotests/integration/lockscreen.cpp b/autotests/integration/lockscreen.cpp --- a/autotests/integration/lockscreen.cpp +++ b/autotests/integration/lockscreen.cpp @@ -161,21 +161,16 @@ #define COMPARE(actual, expected) \ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ return nullptr; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - VERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); VERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); VERIFY(shellSurface); // let's render - Test::render(surface, QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue); - m_connection->flush(); - VERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); VERIFY(c); - COMPARE(clientAddedSpy.first().first().value(), c); + COMPARE(workspace()->activeClient(), c); #undef VERIFY #undef COMPARE diff --git a/autotests/integration/maximize_test.cpp b/autotests/integration/maximize_test.cpp --- a/autotests/integration/maximize_test.cpp +++ b/autotests/integration/maximize_test.cpp @@ -87,20 +87,15 @@ void TestMaximized::testMaximizedPassedToDeco() { // this test verifies that when a ShellClient gets maximized the Decoration receives the signal - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); QScopedPointer surface(Test::createSurface()); QScopedPointer shellSurface(Test::createShellSurface(surface.data())); QScopedPointer ssd(Test::waylandServerSideDecoration()->create(surface.data())); - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); QSignalSpy sizeChangedSpy(shellSurface.data(), &ShellSurface::sizeChanged); QVERIFY(sizeChangedSpy.isValid()); - QVERIFY(clientAddedSpy.isEmpty()); - QVERIFY(clientAddedSpy.wait()); - auto client = clientAddedSpy.first().first().value(); QVERIFY(client); QVERIFY(client->isDecorated()); auto decoration = client->decoration(); @@ -147,9 +142,6 @@ void TestMaximized::testInitiallyMaximized() { // this test verifies that a window created as maximized, will be maximized - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - QScopedPointer surface(Test::createSurface()); QScopedPointer shellSurface(Test::createShellSurface(surface.data())); @@ -161,11 +153,7 @@ QCOMPARE(shellSurface->size(), QSize(1280, 1024)); // now let's render in an incorrect size - Test::render(surface.data(), QSize(100, 50), Qt::blue); - - QVERIFY(clientAddedSpy.isEmpty()); - QVERIFY(clientAddedSpy.wait()); - auto client = clientAddedSpy.first().first().value(); + auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); QVERIFY(client); QCOMPARE(client->geometry(), QRect(0, 0, 100, 50)); QEXPECT_FAIL("", "Should go out of maximzied", Continue); diff --git a/autotests/integration/move_resize_window_test.cpp b/autotests/integration/move_resize_window_test.cpp --- a/autotests/integration/move_resize_window_test.cpp +++ b/autotests/integration/move_resize_window_test.cpp @@ -105,24 +105,18 @@ { using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); QScopedPointer shellSurface(Test::createShellSurface(surface.data())); QVERIFY(!shellSurface.isNull()); QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); QVERIFY(sizeChangeSpy.isValid()); // let's render - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged); QVERIFY(geometryChangedSpy.isValid()); @@ -203,24 +197,18 @@ { using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); QScopedPointer shellSurface(Test::createShellSurface(surface.data())); QVERIFY(!shellSurface.isNull()); QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); QVERIFY(sizeChangeSpy.isValid()); // let's render - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); // let's place it centered @@ -247,9 +235,6 @@ { using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - QScopedPointer surface1(Test::createSurface()); QVERIFY(!surface1.isNull()); QScopedPointer surface2(Test::createSurface()); @@ -267,17 +252,13 @@ QVERIFY(!shellSurface3.isNull()); QScopedPointer shellSurface4(Test::createShellSurface(surface4.data())); QVERIFY(!shellSurface4.isNull()); - auto renderWindow = [this, &clientAddedSpy] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) { + auto renderWindow = [this] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) { // let's render - Test::render(surface, QSize(10, 10), Qt::blue); + auto c = Test::renderAndWaitForShown(surface, QSize(10, 10), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); QCOMPARE(c->geometry().size(), QSize(10, 10)); - clientAddedSpy.clear(); // let's place it centered Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); QCOMPARE(c->geometry(), QRect(635, 507, 10, 10)); @@ -293,13 +274,10 @@ QVERIFY(!surface.isNull()); QScopedPointer shellSurface(Test::createShellSurface(surface.data())); QVERIFY(!shellSurface.isNull()); - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); // let's place it centered Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); QCOMPARE(c->geometry(), QRect(590, 487, 100, 50)); @@ -323,18 +301,14 @@ void MoveResizeWindowTest::testGrowShrink() { using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); // block geometry helper QScopedPointer surface1(Test::createSurface()); QVERIFY(!surface1.isNull()); QScopedPointer shellSurface1(Test::createShellSurface(surface1.data())); QVERIFY(!shellSurface1.isNull()); Test::render(surface1.data(), QSize(650, 514), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - clientAddedSpy.clear(); + QVERIFY(Test::waitForWaylandWindowShown()); workspace()->slotWindowPackRight(); workspace()->slotWindowPackDown(); @@ -346,13 +320,10 @@ QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); QVERIFY(sizeChangeSpy.isValid()); // let's render - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); // let's place it centered Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024)); @@ -391,23 +362,18 @@ // this test verifies that moving a window through pointer only ends if all buttons are released using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); QScopedPointer shellSurface(Test::createShellSurface(surface.data())); QVERIFY(!shellSurface.isNull()); QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); QVERIFY(sizeChangeSpy.isValid()); // let's render - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); QVERIFY(c); + QCOMPARE(c, workspace()->activeClient()); QVERIFY(!c->isMove()); // let's trigger the left button @@ -448,9 +414,6 @@ { // this test verifies that certain window types from PlasmaShellSurface are not moveable or resizable using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); @@ -462,11 +425,8 @@ QFETCH(KWayland::Client::PlasmaShellSurface::Role, role); plasmaSurface->setRole(role); // let's render - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = clientAddedSpy.first().first().value(); QVERIFY(c); QTEST(c->isMovable(), "movable"); QTEST(c->isMovableAcrossScreens(), "movableAcrossScreens"); diff --git a/autotests/integration/plasma_surface_test.cpp b/autotests/integration/plasma_surface_test.cpp --- a/autotests/integration/plasma_surface_test.cpp +++ b/autotests/integration/plasma_surface_test.cpp @@ -103,15 +103,10 @@ QScopedPointer plasmaSurface(m_plasmaShell->createSurface(surface.data())); QVERIFY(!plasmaSurface.isNull()); - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - // now render to map the window - Test::render(surface.data(), QSize(100, 50), Qt::blue); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); + AbstractClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); // currently the role is not yet set, so the window should not be on all desktops QCOMPARE(c->isOnAllDesktops(), false); @@ -135,7 +130,7 @@ QScopedPointer shellSurface2(Test::createShellSurface(surface2.data())); QVERIFY(!shellSurface2.isNull()); Test::render(surface2.data(), QSize(100, 50), Qt::blue); - QVERIFY(clientAddedSpy.wait()); + QVERIFY(Test::waitForWaylandWindowShown()); QVERIFY(workspace()->activeClient() != c); c = workspace()->activeClient(); @@ -173,14 +168,9 @@ QFETCH(PlasmaShellSurface::Role, role); plasmaSurface->setRole(role); - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - // now render to map the window - Test::render(surface.data(), QSize(100, 50), Qt::blue); - QVERIFY(clientAddedSpy.wait()); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - auto c = clientAddedSpy.first().first().value(); QVERIFY(c); QTEST(c->wantsInput(), "wantsInput"); QTEST(c->isActive(), "active"); diff --git a/autotests/integration/quick_tiling_test.cpp b/autotests/integration/quick_tiling_test.cpp --- a/autotests/integration/quick_tiling_test.cpp +++ b/autotests/integration/quick_tiling_test.cpp @@ -131,24 +131,18 @@ { using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); QScopedPointer shellSurface(Test::createShellSurface(surface.data())); QVERIFY(!shellSurface.isNull()); QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); QVERIFY(sizeChangeSpy.isValid()); // let's render - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone); QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged); @@ -205,24 +199,18 @@ { using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); QScopedPointer shellSurface(Test::createShellSurface(surface.data())); QVERIFY(!shellSurface.isNull()); QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); QVERIFY(sizeChangeSpy.isValid()); // let's render - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone); QCOMPARE(c->maximizeMode(), MaximizeRestore); @@ -313,24 +301,18 @@ { using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); QScopedPointer shellSurface(Test::createShellSurface(surface.data())); QVERIFY(!shellSurface.isNull()); QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); QVERIFY(sizeChangeSpy.isValid()); // let's render - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone); QCOMPARE(c->maximizeMode(), MaximizeRestore); @@ -390,24 +372,18 @@ { using namespace KWayland::Client; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(clientAddedSpy.isValid()); - QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); QScopedPointer shellSurface(Test::createShellSurface(surface.data())); QVERIFY(!shellSurface.isNull()); QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged); QVERIFY(sizeChangeSpy.isValid()); // let's render - Test::render(surface.data(), QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - m_connection->flush(); - QVERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); QVERIFY(c); - QCOMPARE(clientAddedSpy.first().first().value(), c); + QCOMPARE(workspace()->activeClient(), c); QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); QCOMPARE(c->quickTileMode(), AbstractClient::QuickTileNone); QCOMPARE(c->maximizeMode(), MaximizeRestore); diff --git a/autotests/integration/struts_test.cpp b/autotests/integration/struts_test.cpp --- a/autotests/integration/struts_test.cpp +++ b/autotests/integration/struts_test.cpp @@ -155,8 +155,6 @@ QFETCH(QVector, windowGeometries); // create the panels - QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(windowCreatedSpy.isValid()); QHash clients; for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) { const QRect windowGeometry = *it; @@ -168,17 +166,13 @@ plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); // map the window - Test::render(surface, windowGeometry.size(), Qt::red, QImage::Format_RGB32); + auto c = Test::renderAndWaitForShown(surface, windowGeometry.size(), Qt::red, QImage::Format_RGB32); - QVERIFY(windowCreatedSpy.wait()); - QCOMPARE(windowCreatedSpy.count(), 1); - auto c = windowCreatedSpy.first().first().value(); QVERIFY(c); QVERIFY(!c->isActive()); QCOMPARE(c->geometry(), windowGeometry); QVERIFY(c->isDock()); QVERIFY(c->hasStrut()); - windowCreatedSpy.clear(); clients.insert(surface, c); } @@ -224,21 +218,13 @@ plasmaSurface->setPosition(windowGeometry.topLeft()); plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); - QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(windowCreatedSpy.isValid()); - // map the window - Test::render(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32); - - QVERIFY(windowCreatedSpy.wait()); - QCOMPARE(windowCreatedSpy.count(), 1); - auto c = windowCreatedSpy.first().first().value(); + auto c = Test::renderAndWaitForShown(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32); QVERIFY(c); QVERIFY(!c->isActive()); QCOMPARE(c->geometry(), windowGeometry); QVERIFY(c->isDock()); QVERIFY(c->hasStrut()); - windowCreatedSpy.clear(); QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 0, 1280, 1000)); QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 0, 1280, 1000)); QCOMPARE(workspace()->clientArea(PlacementArea, 1, 1), QRect(1280, 0, 1280, 1024)); @@ -276,22 +262,13 @@ plasmaSurface->setPosition(windowGeometry.topLeft()); plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); - QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded); - QVERIFY(windowCreatedSpy.isValid()); - // map the first panel - Test::render(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32); - - QVERIFY(windowCreatedSpy.wait()); - QCOMPARE(windowCreatedSpy.count(), 1); - - auto c = windowCreatedSpy.first().first().value(); + auto c = Test::renderAndWaitForShown(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32); QVERIFY(c); QVERIFY(!c->isActive()); QCOMPARE(c->geometry(), windowGeometry); QVERIFY(c->isDock()); QVERIFY(c->hasStrut()); - windowCreatedSpy.clear(); QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 60, 1280, 964)); QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 60, 1280, 964)); @@ -308,18 +285,13 @@ plasmaSurface2->setPosition(windowGeometry2.topLeft()); plasmaSurface2->setRole(PlasmaShellSurface::Role::Panel); - Test::render(surface2.data(), windowGeometry2.size(), Qt::blue, QImage::Format_RGB32); - - QVERIFY(windowCreatedSpy.wait()); - QCOMPARE(windowCreatedSpy.count(), 1); + auto c1 = Test::renderAndWaitForShown(surface2.data(), windowGeometry2.size(), Qt::blue, QImage::Format_RGB32); - auto c1 = windowCreatedSpy.first().first().value(); QVERIFY(c1); QVERIFY(!c1->isActive()); QCOMPARE(c1->geometry(), windowGeometry2); QVERIFY(c1->isDock()); QVERIFY(c1->hasStrut()); - windowCreatedSpy.clear(); QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 60, 1280, 814)); QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 60, 1280, 814)); diff --git a/autotests/integration/test_helpers.cpp b/autotests/integration/test_helpers.cpp --- a/autotests/integration/test_helpers.cpp +++ b/autotests/integration/test_helpers.cpp @@ -18,6 +18,8 @@ along with this program. If not, see . *********************************************************************/ #include "kwin_wayland_test.h" +#include "shell_client.h" +#include "wayland_server.h" #include #include @@ -244,6 +246,32 @@ surface->commit(Surface::CommitFlag::None); } +ShellClient *waitForWaylandWindowShown(int timeout) +{ + QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); + if (!clientAddedSpy.isValid()) { + return nullptr; + } + if (!clientAddedSpy.wait(timeout)) { + return nullptr; + } + return clientAddedSpy.first().first().value(); +} + +ShellClient *renderAndWaitForShown(Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format, int timeout) +{ + QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); + if (!clientAddedSpy.isValid()) { + return nullptr; + } + render(surface, size, color, format); + flushWaylandConnection(); + if (!clientAddedSpy.wait(timeout)) { + return nullptr; + } + return clientAddedSpy.first().first().value(); +} + void flushWaylandConnection() { if (s_waylandConnection.connection) { diff --git a/autotests/integration/touch_input_test.cpp b/autotests/integration/touch_input_test.cpp --- a/autotests/integration/touch_input_test.cpp +++ b/autotests/integration/touch_input_test.cpp @@ -100,21 +100,16 @@ #define COMPARE(actual, expected) \ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ return nullptr; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - VERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(Test::waylandCompositor()); VERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); VERIFY(shellSurface); // let's render - Test::render(surface, QSize(100, 50), Qt::blue); + auto c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue); - Test::flushWaylandConnection(); - VERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); VERIFY(c); - COMPARE(clientAddedSpy.first().first().value(), c); + COMPARE(workspace()->activeClient(), c); #undef VERIFY #undef COMPARE diff --git a/autotests/integration/transient_placement.cpp b/autotests/integration/transient_placement.cpp --- a/autotests/integration/transient_placement.cpp +++ b/autotests/integration/transient_placement.cpp @@ -106,8 +106,6 @@ #define COMPARE(actual, expected) \ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ return nullptr; - QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); - VERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(Test::waylandCompositor()); VERIFY(surface); @@ -126,13 +124,10 @@ COMPARE(deco->mode(), ServerSideDecoration::Mode::Server); } // let's render - Test::render(surface, size, Qt::blue); + auto c = Test::renderAndWaitForShown(surface, size, Qt::blue); - Test::flushWaylandConnection(); - VERIFY(clientAddedSpy.wait()); - AbstractClient *c = workspace()->activeClient(); VERIFY(c); - COMPARE(clientAddedSpy.first().first().value(), c); + COMPARE(workspace()->activeClient(), c); #undef VERIFY #undef COMPARE