From 34de2c2b5c8b08643a4ccf4bb2a88c89b1931b03 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 18 Aug 2017 15:15:19 +0100 Subject: [PATCH] Track outputs in kwin integration tests Summary: Split from the last review, as in order to track output's removed (in any way that's useful) the registry needs to be on the heap and the change grew. Test Plan: Every test that previously passed on my system still does Though currently that's not every test (for some reason) which was my main motivation for splitting. Reviewers: #plasma, graesslin Reviewed By: #plasma, graesslin Subscribers: plasma-devel, kwin, #kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D7377 --- autotests/integration/test_helpers.cpp | 54 +++++++++++++++++--------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/autotests/integration/test_helpers.cpp b/autotests/integration/test_helpers.cpp index 576e1687dd..6383f29ff0 100644 --- a/autotests/integration/test_helpers.cpp +++ b/autotests/integration/test_helpers.cpp @@ -33,6 +33,7 @@ along with this program. If not, see . #include #include #include +#include #include #include #include @@ -66,7 +67,9 @@ static struct { PlasmaShell *plasmaShell = nullptr; PlasmaWindowManagement *windowManagement = nullptr; PointerConstraints *pointerConstraints = nullptr; + Registry *registry = nullptr; QThread *thread = nullptr; + QVector outputs; } s_waylandConnection; bool setupWaylandConnection(AdditionalWaylandInterfaces flags) @@ -103,67 +106,78 @@ bool setupWaylandConnection(AdditionalWaylandInterfaces flags) return false; } - Registry registry; - registry.setEventQueue(s_waylandConnection.queue); - QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced); + Registry *registry = new Registry; + s_waylandConnection.registry = registry; + registry->setEventQueue(s_waylandConnection.queue); + + QObject::connect(registry, &Registry::outputAnnounced, [=](quint32 name, quint32 version) { + auto output = registry->createOutput(name, version, s_waylandConnection.registry); + s_waylandConnection.outputs << output; + QObject::connect(output, &Output::removed, [=]() { + output->deleteLater(); + s_waylandConnection.outputs.removeOne(output); + }); + }); + + QSignalSpy allAnnounced(registry, &Registry::interfacesAnnounced); if (!allAnnounced.isValid()) { return false; } - registry.create(s_waylandConnection.connection); - if (!registry.isValid()) { + registry->create(s_waylandConnection.connection); + if (!registry->isValid()) { return false; } - registry.setup(); + registry->setup(); if (!allAnnounced.wait()) { return false; } - s_waylandConnection.compositor = registry.createCompositor(registry.interface(Registry::Interface::Compositor).name, registry.interface(Registry::Interface::Compositor).version); + s_waylandConnection.compositor = registry->createCompositor(registry->interface(Registry::Interface::Compositor).name, registry->interface(Registry::Interface::Compositor).version); if (!s_waylandConnection.compositor->isValid()) { return false; } - s_waylandConnection.shm = registry.createShmPool(registry.interface(Registry::Interface::Shm).name, registry.interface(Registry::Interface::Shm).version); + s_waylandConnection.shm = registry->createShmPool(registry->interface(Registry::Interface::Shm).name, registry->interface(Registry::Interface::Shm).version); if (!s_waylandConnection.shm->isValid()) { return false; } - s_waylandConnection.shell = registry.createShell(registry.interface(Registry::Interface::Shell).name, registry.interface(Registry::Interface::Shell).version); + s_waylandConnection.shell = registry->createShell(registry->interface(Registry::Interface::Shell).name, registry->interface(Registry::Interface::Shell).version); if (!s_waylandConnection.shell->isValid()) { return false; } - s_waylandConnection.xdgShellV5 = registry.createXdgShell(registry.interface(Registry::Interface::XdgShellUnstableV5).name, registry.interface(Registry::Interface::XdgShellUnstableV5).version); + s_waylandConnection.xdgShellV5 = registry->createXdgShell(registry->interface(Registry::Interface::XdgShellUnstableV5).name, registry->interface(Registry::Interface::XdgShellUnstableV5).version); if (!s_waylandConnection.xdgShellV5->isValid()) { return false; } if (flags.testFlag(AdditionalWaylandInterface::Seat)) { - s_waylandConnection.seat = registry.createSeat(registry.interface(Registry::Interface::Seat).name, registry.interface(Registry::Interface::Seat).version); + s_waylandConnection.seat = registry->createSeat(registry->interface(Registry::Interface::Seat).name, registry->interface(Registry::Interface::Seat).version); if (!s_waylandConnection.seat->isValid()) { return false; } } if (flags.testFlag(AdditionalWaylandInterface::Decoration)) { - s_waylandConnection.decoration = registry.createServerSideDecorationManager(registry.interface(Registry::Interface::ServerSideDecorationManager).name, - registry.interface(Registry::Interface::ServerSideDecorationManager).version); + s_waylandConnection.decoration = registry->createServerSideDecorationManager(registry->interface(Registry::Interface::ServerSideDecorationManager).name, + registry->interface(Registry::Interface::ServerSideDecorationManager).version); if (!s_waylandConnection.decoration->isValid()) { return false; } } if (flags.testFlag(AdditionalWaylandInterface::PlasmaShell)) { - s_waylandConnection.plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name, - registry.interface(Registry::Interface::PlasmaShell).version); + s_waylandConnection.plasmaShell = registry->createPlasmaShell(registry->interface(Registry::Interface::PlasmaShell).name, + registry->interface(Registry::Interface::PlasmaShell).version); if (!s_waylandConnection.plasmaShell->isValid()) { return false; } } if (flags.testFlag(AdditionalWaylandInterface::WindowManagement)) { - s_waylandConnection.windowManagement = registry.createPlasmaWindowManagement(registry.interface(Registry::Interface::PlasmaWindowManagement).name, - registry.interface(Registry::Interface::PlasmaWindowManagement).version); + s_waylandConnection.windowManagement = registry->createPlasmaWindowManagement(registry->interface(Registry::Interface::PlasmaWindowManagement).name, + registry->interface(Registry::Interface::PlasmaWindowManagement).version); if (!s_waylandConnection.windowManagement->isValid()) { return false; } } if (flags.testFlag(AdditionalWaylandInterface::PointerConstraints)) { - s_waylandConnection.pointerConstraints = registry.createPointerConstraints(registry.interface(Registry::Interface::PointerConstraintsUnstableV1).name, - registry.interface(Registry::Interface::PointerConstraintsUnstableV1).version); + s_waylandConnection.pointerConstraints = registry->createPointerConstraints(registry->interface(Registry::Interface::PointerConstraintsUnstableV1).name, + registry->interface(Registry::Interface::PointerConstraintsUnstableV1).version); if (!s_waylandConnection.pointerConstraints->isValid()) { return false; } @@ -196,6 +210,8 @@ void destroyWaylandConnection() s_waylandConnection.shm = nullptr; delete s_waylandConnection.queue; s_waylandConnection.queue = nullptr; + delete s_waylandConnection.registry; + s_waylandConnection.registry = nullptr; if (s_waylandConnection.thread) { QSignalSpy spy(s_waylandConnection.connection, &QObject::destroyed); s_waylandConnection.connection->deleteLater();