diff --git a/autotests/integration/CMakeLists.txt b/autotests/integration/CMakeLists.txt
index e168cad80e..31c49dc392 100644
--- a/autotests/integration/CMakeLists.txt
+++ b/autotests/integration/CMakeLists.txt
@@ -2,7 +2,7 @@ add_definitions(-DKWINBACKENDPATH="${CMAKE_BINARY_DIR}/plugins/platforms/virtual
add_definitions(-DKWINQPAPATH="${CMAKE_BINARY_DIR}/plugins/qpa/")
add_subdirectory(helper)
-add_library(KWinIntegrationTestFramework STATIC kwin_wayland_test.cpp)
+add_library(KWinIntegrationTestFramework STATIC kwin_wayland_test.cpp test_helpers.cpp)
target_link_libraries(KWinIntegrationTestFramework kwin Qt5::Test)
function(integrationTest)
diff --git a/autotests/integration/debug_console_test.cpp b/autotests/integration/debug_console_test.cpp
index 56c844d4cd..2d42e40f04 100644
--- a/autotests/integration/debug_console_test.cpp
+++ b/autotests/integration/debug_console_test.cpp
@@ -27,8 +27,6 @@ along with this program. If not, see .
#include
#include
-#include
-#include
#include
#include
#include
@@ -46,6 +44,7 @@ class DebugConsoleTest : public QObject
Q_OBJECT
private Q_SLOTS:
void initTestCase();
+ void cleanup();
void topLevelTest_data();
void topLevelTest();
void testX11Client();
@@ -73,6 +72,11 @@ void DebugConsoleTest::initTestCase()
waylandServer()->initWorkspace();
}
+void DebugConsoleTest::cleanup()
+{
+ Test::destroyWaylandConnection();
+}
+
void DebugConsoleTest::topLevelTest_data()
{
QTest::addColumn("row");
@@ -308,51 +312,15 @@ void DebugConsoleTest::testWaylandClient()
QVERIFY(rowsInsertedSpy.isValid());
// create our connection
- using namespace KWayland::Client;
- // setup connection
- QScopedPointer connection(new ConnectionThread);
- QSignalSpy connectedSpy(connection.data(), &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- connection->setSocketName(s_socketName);
-
- QScopedPointer thread(new QThread);
- connection->moveToThread(thread.data());
- thread->start();
-
- connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- QScopedPointer queue(new EventQueue);
- QVERIFY(!queue->isValid());
- queue->setup(connection.data());
- QVERIFY(queue->isValid());
-
- Registry registry;
- registry.setEventQueue(queue.data());
- QSignalSpy interfacesAnnouncedSpy(®istry, &Registry::interfacesAnnounced);
- QVERIFY(interfacesAnnouncedSpy.isValid());
- registry.create(connection.data());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(interfacesAnnouncedSpy.wait());
-
- QScopedPointer compositor(registry.createCompositor(registry.interface(Registry::Interface::Compositor).name, registry.interface(Registry::Interface::Compositor).version));
- QVERIFY(compositor->isValid());
- QScopedPointer shm(registry.createShmPool(registry.interface(Registry::Interface::Shm).name, registry.interface(Registry::Interface::Shm).version));
- QVERIFY(shm->isValid());
- QScopedPointer shell(registry.createShell(registry.interface(Registry::Interface::Shell).name, registry.interface(Registry::Interface::Shell).version));
- QVERIFY(shell->isValid());
+ QVERIFY(Test::setupWaylandConnection(s_socketName));
// create the Surface and ShellSurface
- QScopedPointer surface(compositor->createSurface());
+ using namespace KWayland::Client;
+ QScopedPointer surface(Test::createSurface());
QVERIFY(surface->isValid());
- QScopedPointer shellSurface(shell->createSurface(surface.data()));
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QVERIFY(shellSurface->isValid());
- QImage img(10, 10, QImage::Format_ARGB32);
- img.fill(Qt::red);
- surface->attachBuffer(shm->createBuffer(img));
- surface->damage(QRect(0, 0, 10, 10));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), QSize(10, 10), Qt::red);
// now we have the window, it should be added to our model
QVERIFY(rowsInsertedSpy.wait());
@@ -410,18 +378,11 @@ void DebugConsoleTest::testWaylandClient()
surface->attachBuffer(Buffer::Ptr());
surface->commit(Surface::CommitFlag::None);
shellSurface.reset();
- connection->flush();
+ Test::flushWaylandConnection();
qDebug() << rowsRemovedSpy.count();
QEXPECT_FAIL("", "Deleting a ShellSurface does not result in the server removing the ShellClient", Continue);
QVERIFY(rowsRemovedSpy.wait());
- // also destroy the connection to ensure the ShellSurface goes away
surface.reset();
- shell.reset();
- shm.reset();
- compositor.reset();
- connection.take()->deleteLater();
- thread->quit();
- QVERIFY(thread->wait());
QVERIFY(rowsRemovedSpy.wait());
QCOMPARE(rowsRemovedSpy.count(), 1);
diff --git a/autotests/integration/decoration_input_test.cpp b/autotests/integration/decoration_input_test.cpp
index b8b1dd8e31..56939db35e 100644
--- a/autotests/integration/decoration_input_test.cpp
+++ b/autotests/integration/decoration_input_test.cpp
@@ -33,8 +33,6 @@ along with this program. If not, see .
#include
#include
-#include
-#include
#include
#include
#include
@@ -74,14 +72,6 @@ private Q_SLOTS:
private:
AbstractClient *showWindow();
- KWayland::Client::ConnectionThread *m_connection = nullptr;
- KWayland::Client::Compositor *m_compositor = nullptr;
- KWayland::Client::ServerSideDecorationManager *m_deco = nullptr;
- KWayland::Client::Seat *m_seat = nullptr;
- KWayland::Client::ShmPool *m_shm = nullptr;
- KWayland::Client::Shell *m_shell = nullptr;
- KWayland::Client::EventQueue *m_queue = nullptr;
- QThread *m_thread = nullptr;
};
#define MOTION(target) \
@@ -105,11 +95,11 @@ AbstractClient *DecorationInputTest::showWindow()
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
VERIFY(clientAddedSpy.isValid());
- Surface *surface = m_compositor->createSurface(m_compositor);
+ Surface *surface = Test::createSurface(Test::waylandCompositor());
VERIFY(surface);
- ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
+ ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
VERIFY(shellSurface);
- auto deco = m_deco->create(surface, surface);
+ auto deco = Test::waylandServerSideDecoration()->create(surface, surface);
QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged);
VERIFY(decoSpy.isValid());
VERIFY(decoSpy.wait());
@@ -117,13 +107,9 @@ AbstractClient *DecorationInputTest::showWindow()
VERIFY(decoSpy.wait());
COMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
// let's render
- QImage img(QSize(500, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 500, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface, QSize(500, 50), Qt::blue);
- m_connection->flush();
+ Test::flushWaylandConnection();
VERIFY(clientAddedSpy.wait());
AbstractClient *c = workspace()->activeClient();
VERIFY(c);
@@ -166,61 +152,8 @@ void DecorationInputTest::initTestCase()
void DecorationInputTest::init()
{
using namespace KWayland::Client;
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
- QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
- QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
- QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
- QSignalSpy decorationSpy(®istry, &Registry::serverSideDecorationManagerAnnounced);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- QVERIFY(shmSpy.isValid());
- QVERIFY(shellSpy.isValid());
- QVERIFY(compositorSpy.isValid());
- QVERIFY(seatSpy.isValid());
- QVERIFY(decorationSpy.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
- QVERIFY(!compositorSpy.isEmpty());
- QVERIFY(!shmSpy.isEmpty());
- QVERIFY(!shellSpy.isEmpty());
- QVERIFY(!seatSpy.isEmpty());
- QVERIFY(!decorationSpy.isEmpty());
-
- m_compositor = registry.createCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value(), this);
- QVERIFY(m_compositor->isValid());
- m_shm = registry.createShmPool(shmSpy.first().first().value(), shmSpy.first().last().value(), this);
- QVERIFY(m_shm->isValid());
- m_shell = registry.createShell(shellSpy.first().first().value(), shellSpy.first().last().value(), this);
- QVERIFY(m_shell->isValid());
- m_seat = registry.createSeat(seatSpy.first().first().value(), seatSpy.first().last().value(), this);
- QVERIFY(m_seat->isValid());
- m_deco = registry.createServerSideDecorationManager(decorationSpy.first().first().value(), decorationSpy.first().last().value());
- QVERIFY(m_deco->isValid());
- QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
- QVERIFY(hasPointerSpy.isValid());
- QVERIFY(hasPointerSpy.wait());
+ QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::Decoration));
+ QVERIFY(Test::waitForWaylandPointer());
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
@@ -228,26 +161,7 @@ void DecorationInputTest::init()
void DecorationInputTest::cleanup()
{
- delete m_compositor;
- m_compositor = nullptr;
- delete m_deco;
- m_deco = nullptr;
- delete m_seat;
- m_seat = nullptr;
- delete m_shm;
- m_shm = nullptr;
- delete m_shell;
- m_shell = nullptr;
- delete m_queue;
- m_queue = nullptr;
- if (m_thread) {
- m_connection->deleteLater();
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
- m_thread = nullptr;
- m_connection = nullptr;
- }
+ Test::destroyWaylandConnection();
}
void DecorationInputTest::testAxis_data()
diff --git a/autotests/integration/dont_crash_cancel_animation.cpp b/autotests/integration/dont_crash_cancel_animation.cpp
index 6106b9e24e..09342201e5 100644
--- a/autotests/integration/dont_crash_cancel_animation.cpp
+++ b/autotests/integration/dont_crash_cancel_animation.cpp
@@ -33,13 +33,11 @@ along with this program. If not, see .
#include
-#include
#include
#include
#include
#include
#include
-#include
namespace KWin
{
@@ -58,12 +56,6 @@ private Q_SLOTS:
private:
void unlock();
AbstractClient *showWindow();
- KWayland::Client::ConnectionThread *m_connection = nullptr;
- KWayland::Client::Compositor *m_compositor = nullptr;
- KWayland::Client::ShmPool *m_shm = nullptr;
- KWayland::Client::Shell *m_shell = nullptr;
- KWayland::Client::EventQueue *m_queue = nullptr;
- QThread *m_thread = nullptr;
};
void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase()
@@ -83,69 +75,12 @@ void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase()
void DontCrashCancelAnimationFromAnimationEndedTest::init()
{
- using namespace KWayland::Client;
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
- QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
- QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- QVERIFY(shmSpy.isValid());
- QVERIFY(shellSpy.isValid());
- QVERIFY(compositorSpy.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
- QVERIFY(!compositorSpy.isEmpty());
- QVERIFY(!shmSpy.isEmpty());
- QVERIFY(!shellSpy.isEmpty());
-
- m_compositor = registry.createCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value(), this);
- QVERIFY(m_compositor->isValid());
- m_shm = registry.createShmPool(shmSpy.first().first().value(), shmSpy.first().last().value(), this);
- QVERIFY(m_shm->isValid());
- m_shell = registry.createShell(shellSpy.first().first().value(), shellSpy.first().last().value(), this);
- QVERIFY(m_shell->isValid());
+ QVERIFY(Test::setupWaylandConnection(s_socketName));
}
void DontCrashCancelAnimationFromAnimationEndedTest::cleanup()
{
- delete m_compositor;
- m_compositor = nullptr;
- delete m_shm;
- m_shm = nullptr;
- delete m_shell;
- m_shell = nullptr;
- delete m_queue;
- m_queue = nullptr;
- if (m_thread) {
- m_connection->deleteLater();
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
- m_thread = nullptr;
- m_connection = nullptr;
- }
+ Test::destroyWaylandConnection();
}
void DontCrashCancelAnimationFromAnimationEndedTest::testScript()
@@ -169,18 +104,14 @@ void DontCrashCancelAnimationFromAnimationEndedTest::testScript()
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
- Surface *surface = m_compositor->createSurface(m_compositor);
+ Surface *surface = Test::createSurface(Test::waylandCompositor());
QVERIFY(surface);
- ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
+ ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
QVERIFY(shellSurface);
// let's render
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface, QSize(100, 50), Qt::blue);
- m_connection->flush();
+ Test::flushWaylandConnection();
QVERIFY(clientAddedSpy.wait());
AbstractClient *c = workspace()->activeClient();
QVERIFY(c);
diff --git a/autotests/integration/dont_crash_empty_deco.cpp b/autotests/integration/dont_crash_empty_deco.cpp
index 8ca2f2ed90..bdd3c48134 100644
--- a/autotests/integration/dont_crash_empty_deco.cpp
+++ b/autotests/integration/dont_crash_empty_deco.cpp
@@ -28,17 +28,6 @@ along with this program. If not, see .
#include "shell_client.h"
#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
#include
#include
@@ -54,18 +43,7 @@ class DontCrashEmptyDecorationTest : public QObject
private Q_SLOTS:
void initTestCase();
void init();
- void cleanup();
void testBug361551();
-
-private:
- KWayland::Client::ConnectionThread *m_connection = nullptr;
- KWayland::Client::Compositor *m_compositor = nullptr;
- KWayland::Client::ServerSideDecorationManager *m_deco = nullptr;
- KWayland::Client::Seat *m_seat = nullptr;
- KWayland::Client::ShmPool *m_shm = nullptr;
- KWayland::Client::Shell *m_shell = nullptr;
- KWayland::Client::EventQueue *m_queue = nullptr;
- QThread *m_thread = nullptr;
};
void DontCrashEmptyDecorationTest::initTestCase()
@@ -94,91 +72,10 @@ void DontCrashEmptyDecorationTest::initTestCase()
void DontCrashEmptyDecorationTest::init()
{
- using namespace KWayland::Client;
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
- QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
- QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
- QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
- QSignalSpy decorationSpy(®istry, &Registry::serverSideDecorationManagerAnnounced);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- QVERIFY(shmSpy.isValid());
- QVERIFY(shellSpy.isValid());
- QVERIFY(compositorSpy.isValid());
- QVERIFY(seatSpy.isValid());
- QVERIFY(decorationSpy.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
- QVERIFY(!compositorSpy.isEmpty());
- QVERIFY(!shmSpy.isEmpty());
- QVERIFY(!shellSpy.isEmpty());
- QVERIFY(!seatSpy.isEmpty());
- QVERIFY(!decorationSpy.isEmpty());
-
- m_compositor = registry.createCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value(), this);
- QVERIFY(m_compositor->isValid());
- m_shm = registry.createShmPool(shmSpy.first().first().value(), shmSpy.first().last().value(), this);
- QVERIFY(m_shm->isValid());
- m_shell = registry.createShell(shellSpy.first().first().value(), shellSpy.first().last().value(), this);
- QVERIFY(m_shell->isValid());
- m_seat = registry.createSeat(seatSpy.first().first().value(), seatSpy.first().last().value(), this);
- QVERIFY(m_seat->isValid());
- m_deco = registry.createServerSideDecorationManager(decorationSpy.first().first().value(), decorationSpy.first().last().value());
- QVERIFY(m_deco->isValid());
- QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
- QVERIFY(hasPointerSpy.isValid());
- QVERIFY(hasPointerSpy.wait());
-
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
}
-void DontCrashEmptyDecorationTest::cleanup()
-{
- delete m_compositor;
- m_compositor = nullptr;
- delete m_deco;
- m_deco = nullptr;
- delete m_seat;
- m_seat = nullptr;
- delete m_shm;
- m_shm = nullptr;
- delete m_shell;
- m_shell = nullptr;
- delete m_queue;
- m_queue = nullptr;
- if (m_thread) {
- m_connection->deleteLater();
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
- m_thread = nullptr;
- m_connection = nullptr;
- }
-}
-
void DontCrashEmptyDecorationTest::testBug361551()
{
// this test verifies that resizing an X11 window to an invalid size does not result in crash on unmap
diff --git a/autotests/integration/dont_crash_no_border.cpp b/autotests/integration/dont_crash_no_border.cpp
index 47b5f4eda6..653cf0c21f 100644
--- a/autotests/integration/dont_crash_no_border.cpp
+++ b/autotests/integration/dont_crash_no_border.cpp
@@ -29,15 +29,8 @@ along with this program. If not, see .
#include "shell_client.h"
#include
-#include
-#include
-#include
-#include
-#include
#include
#include
-#include
-#include
#include
#include
@@ -57,16 +50,6 @@ private Q_SLOTS:
void init();
void cleanup();
void testCreateWindow();
-
-private:
- KWayland::Client::ConnectionThread *m_connection = nullptr;
- KWayland::Client::Compositor *m_compositor = nullptr;
- KWayland::Client::ServerSideDecorationManager *m_deco = nullptr;
- KWayland::Client::Seat *m_seat = nullptr;
- KWayland::Client::ShmPool *m_shm = nullptr;
- KWayland::Client::Shell *m_shell = nullptr;
- KWayland::Client::EventQueue *m_queue = nullptr;
- QThread *m_thread = nullptr;
};
void DontCrashNoBorder::initTestCase()
@@ -100,62 +83,7 @@ void DontCrashNoBorder::initTestCase()
void DontCrashNoBorder::init()
{
- using namespace KWayland::Client;
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
- QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
- QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
- QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
- QSignalSpy decorationSpy(®istry, &Registry::serverSideDecorationManagerAnnounced);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- QVERIFY(shmSpy.isValid());
- QVERIFY(shellSpy.isValid());
- QVERIFY(compositorSpy.isValid());
- QVERIFY(seatSpy.isValid());
- QVERIFY(decorationSpy.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
- QVERIFY(!compositorSpy.isEmpty());
- QVERIFY(!shmSpy.isEmpty());
- QVERIFY(!shellSpy.isEmpty());
- QVERIFY(!seatSpy.isEmpty());
- QVERIFY(!decorationSpy.isEmpty());
-
- m_compositor = registry.createCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value(), this);
- QVERIFY(m_compositor->isValid());
- m_shm = registry.createShmPool(shmSpy.first().first().value(), shmSpy.first().last().value(), this);
- QVERIFY(m_shm->isValid());
- m_shell = registry.createShell(shellSpy.first().first().value(), shellSpy.first().last().value(), this);
- QVERIFY(m_shell->isValid());
- m_seat = registry.createSeat(seatSpy.first().first().value(), seatSpy.first().last().value(), this);
- QVERIFY(m_seat->isValid());
- m_deco = registry.createServerSideDecorationManager(decorationSpy.first().first().value(), decorationSpy.first().last().value());
- QVERIFY(m_deco->isValid());
- QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
- QVERIFY(hasPointerSpy.isValid());
- QVERIFY(hasPointerSpy.wait());
+ QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Decoration));
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
@@ -163,26 +91,7 @@ void DontCrashNoBorder::init()
void DontCrashNoBorder::cleanup()
{
- delete m_compositor;
- m_compositor = nullptr;
- delete m_deco;
- m_deco = nullptr;
- delete m_seat;
- m_seat = nullptr;
- delete m_shm;
- m_shm = nullptr;
- delete m_shell;
- m_shell = nullptr;
- delete m_queue;
- m_queue = nullptr;
- if (m_thread) {
- m_connection->deleteLater();
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
- m_thread = nullptr;
- m_connection = nullptr;
- }
+ Test::destroyWaylandConnection();
}
void DontCrashNoBorder::testCreateWindow()
@@ -192,25 +101,21 @@ void DontCrashNoBorder::testCreateWindow()
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
- Surface *surface = m_compositor->createSurface(m_compositor);
- QVERIFY(surface);
- ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
+ QScopedPointer surface(Test::createSurface());
+ QVERIFY(!surface.isNull());
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QVERIFY(shellSurface);
- auto deco = m_deco->create(surface, surface);
- QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged);
+ QScopedPointer deco(Test::waylandServerSideDecoration()->create(surface.data()));
+ QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged);
QVERIFY(decoSpy.isValid());
QVERIFY(decoSpy.wait());
deco->requestMode(ServerSideDecoration::Mode::Server);
QVERIFY(decoSpy.wait());
QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
// let's render
- QImage img(QSize(500, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 500, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), QSize(500, 50), Qt::blue);
- m_connection->flush();
+ Test::flushWaylandConnection();
QVERIFY(clientAddedSpy.wait());
AbstractClient *c = workspace()->activeClient();
QVERIFY(c);
diff --git a/autotests/integration/input_stacking_order.cpp b/autotests/integration/input_stacking_order.cpp
index 507d1d7495..de63f2d419 100644
--- a/autotests/integration/input_stacking_order.cpp
+++ b/autotests/integration/input_stacking_order.cpp
@@ -57,13 +57,6 @@ private Q_SLOTS:
private:
void render(KWayland::Client::Surface *surface);
- KWayland::Client::ConnectionThread *m_connection = nullptr;
- KWayland::Client::Compositor *m_compositor = nullptr;
- KWayland::Client::Seat *m_seat = nullptr;
- KWayland::Client::ShmPool *m_shm = nullptr;
- KWayland::Client::Shell *m_shell = nullptr;
- KWayland::Client::EventQueue *m_queue = nullptr;
- QThread *m_thread = nullptr;
};
void InputStackingOrderTest::initTestCase()
@@ -89,56 +82,8 @@ void InputStackingOrderTest::initTestCase()
void InputStackingOrderTest::init()
{
using namespace KWayland::Client;
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
- QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
- QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
- QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- QVERIFY(shmSpy.isValid());
- QVERIFY(shellSpy.isValid());
- QVERIFY(compositorSpy.isValid());
- QVERIFY(seatSpy.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
- QVERIFY(!compositorSpy.isEmpty());
- QVERIFY(!shmSpy.isEmpty());
- QVERIFY(!shellSpy.isEmpty());
- QVERIFY(!seatSpy.isEmpty());
-
- m_compositor = registry.createCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value(), this);
- QVERIFY(m_compositor->isValid());
- m_shm = registry.createShmPool(shmSpy.first().first().value(), shmSpy.first().last().value(), this);
- QVERIFY(m_shm->isValid());
- m_shell = registry.createShell(shellSpy.first().first().value(), shellSpy.first().last().value(), this);
- QVERIFY(m_shell->isValid());
- m_seat = registry.createSeat(seatSpy.first().first().value(), seatSpy.first().last().value(), this);
- QVERIFY(m_seat->isValid());
- QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
- QVERIFY(hasPointerSpy.isValid());
- QVERIFY(hasPointerSpy.wait());
+ QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Seat));
+ QVERIFY(Test::waitForWaylandPointer());
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
@@ -146,34 +91,13 @@ void InputStackingOrderTest::init()
void InputStackingOrderTest::cleanup()
{
- delete m_compositor;
- m_compositor = nullptr;
- delete m_seat;
- m_seat = nullptr;
- delete m_shm;
- m_shm = nullptr;
- delete m_shell;
- m_shell = nullptr;
- delete m_queue;
- m_queue = nullptr;
- if (m_thread) {
- m_connection->deleteLater();
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
- m_thread = nullptr;
- m_connection = nullptr;
- }
+ Test::destroyWaylandConnection();
}
void InputStackingOrderTest::render(KWayland::Client::Surface *surface)
{
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(KWayland::Client::Surface::CommitFlag::None);
- m_connection->flush();
+ Test::render(surface, QSize(100, 50), Qt::blue);
+ Test::flushWaylandConnection();
}
void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange()
@@ -184,7 +108,7 @@ void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange()
// other window should gain focus without a mouse event in between
using namespace KWayland::Client;
// create pointer and signal spy for enter and leave signals
- auto pointer = m_seat->createPointer(m_seat);
+ auto pointer = Test::waylandSeat()->createPointer(Test::waylandSeat());
QVERIFY(pointer);
QVERIFY(pointer->isValid());
QSignalSpy enteredSpy(pointer, &Pointer::entered);
@@ -195,18 +119,18 @@ void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange()
// now create the two windows and make them overlap
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
- Surface *surface1 = m_compositor->createSurface(m_compositor);
+ Surface *surface1 = Test::createSurface(Test::waylandCompositor());
QVERIFY(surface1);
- ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1);
+ ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1);
QVERIFY(shellSurface1);
render(surface1);
QVERIFY(clientAddedSpy.wait());
AbstractClient *window1 = workspace()->activeClient();
QVERIFY(window1);
- Surface *surface2 = m_compositor->createSurface(m_compositor);
+ Surface *surface2 = Test::createSurface(Test::waylandCompositor());
QVERIFY(surface2);
- ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2);
+ ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2);
QVERIFY(shellSurface2);
render(surface2);
QVERIFY(clientAddedSpy.wait());
diff --git a/autotests/integration/kwin_wayland_test.h b/autotests/integration/kwin_wayland_test.h
index c35d742736..2dda319414 100644
--- a/autotests/integration/kwin_wayland_test.h
+++ b/autotests/integration/kwin_wayland_test.h
@@ -25,6 +25,23 @@ along with this program. If not, see .
// Qt
#include
+namespace KWayland
+{
+namespace Client
+{
+class ConnectionThread;
+class Compositor;
+class PlasmaShell;
+class PlasmaWindowManagement;
+class Seat;
+class ServerSideDecorationManager;
+class Shell;
+class ShellSurface;
+class ShmPool;
+class Surface;
+}
+}
+
namespace KWin
{
@@ -50,8 +67,61 @@ private:
QMetaObject::Connection m_xwaylandFailConnection;
};
+namespace Test
+{
+
+enum class AdditionalWaylandInterface {
+ Seat = 1 << 0,
+ Decoration = 1 << 1,
+ PlasmaShell = 1 << 2,
+ WindowManagement = 1 << 3
+};
+Q_DECLARE_FLAGS(AdditionalWaylandInterfaces, AdditionalWaylandInterface)
+/**
+ * Creates a Wayland Connection in a dedicated thread and creates various
+ * client side objects which can be used to create windows.
+ * @param socketName The name of the Wayland socket to connect to.
+ * @returns @c true if created successfully, @c false if there was an error
+ * @see destroyWaylandConnection
+ **/
+bool setupWaylandConnection(const QString &socketName, AdditionalWaylandInterfaces flags = AdditionalWaylandInterfaces());
+
+/**
+ * Destroys the Wayland Connection created with @link{setupWaylandConnection}.
+ * This can be called from cleanup in order to ensure that no Wayland Connection
+ * leaks into the next test method.
+ * @see setupWaylandConnection
+ */
+void destroyWaylandConnection();
+
+KWayland::Client::ConnectionThread *waylandConnection();
+KWayland::Client::Compositor *waylandCompositor();
+KWayland::Client::Shell *waylandShell();
+KWayland::Client::ShmPool *waylandShmPool();
+KWayland::Client::Seat *waylandSeat();
+KWayland::Client::ServerSideDecorationManager *waylandServerSideDecoration();
+KWayland::Client::PlasmaShell *waylandPlasmaShell();
+KWayland::Client::PlasmaWindowManagement *waylandWindowManagement();
+
+bool waitForWaylandPointer();
+bool waitForWaylandTouch();
+
+void flushWaylandConnection();
+
+KWayland::Client::Surface *createSurface(QObject *parent = nullptr);
+KWayland::Client::ShellSurface *createShellSurface(KWayland::Client::Surface *surface, QObject *parent = nullptr);
+
+/**
+ * Creates a shared memory buffer of @p size in @p color and attaches it to the @p surface.
+ * 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);
}
+}
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Test::AdditionalWaylandInterfaces)
+
#define WAYLANDTEST_MAIN_HELPER(TestObject, DPI) \
int main(int argc, char *argv[]) \
{ \
diff --git a/autotests/integration/lockscreen.cpp b/autotests/integration/lockscreen.cpp
index 170c27f673..0fff8b3886 100644
--- a/autotests/integration/lockscreen.cpp
+++ b/autotests/integration/lockscreen.cpp
@@ -30,7 +30,6 @@ along with this program. If not, see .
#include
#include
-#include
#include
#include
#include
@@ -83,8 +82,6 @@ private:
KWayland::Client::Seat *m_seat = nullptr;
KWayland::Client::ShmPool *m_shm = nullptr;
KWayland::Client::Shell *m_shell = nullptr;
- KWayland::Client::EventQueue *m_queue = nullptr;
- QThread *m_thread = nullptr;
};
class HelperEffect : public Effect
@@ -167,16 +164,12 @@ AbstractClient *LockScreenTest::showWindow()
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
VERIFY(clientAddedSpy.isValid());
- Surface *surface = m_compositor->createSurface(m_compositor);
+ Surface *surface = Test::createSurface(m_compositor);
VERIFY(surface);
- ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
+ ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
VERIFY(shellSurface);
// let's render
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface, QSize(100, 50), Qt::blue);
m_connection->flush();
VERIFY(clientAddedSpy.wait());
@@ -212,57 +205,13 @@ void LockScreenTest::initTestCase()
void LockScreenTest::init()
{
- using namespace KWayland::Client;
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
- QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
- QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
- QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- QVERIFY(shmSpy.isValid());
- QVERIFY(shellSpy.isValid());
- QVERIFY(compositorSpy.isValid());
- QVERIFY(seatSpy.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
- QVERIFY(!compositorSpy.isEmpty());
- QVERIFY(!shmSpy.isEmpty());
- QVERIFY(!shellSpy.isEmpty());
- QVERIFY(!seatSpy.isEmpty());
-
- m_compositor = registry.createCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value(), this);
- QVERIFY(m_compositor->isValid());
- m_shm = registry.createShmPool(shmSpy.first().first().value(), shmSpy.first().last().value(), this);
- QVERIFY(m_shm->isValid());
- m_shell = registry.createShell(shellSpy.first().first().value(), shellSpy.first().last().value(), this);
- QVERIFY(m_shell->isValid());
- m_seat = registry.createSeat(seatSpy.first().first().value(), seatSpy.first().last().value(), this);
- QVERIFY(m_seat->isValid());
- QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
- QVERIFY(hasPointerSpy.isValid());
- QVERIFY(hasPointerSpy.wait());
+ QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Seat));
+ QVERIFY(Test::waitForWaylandPointer());
+ m_connection = Test::waylandConnection();
+ m_compositor = Test::waylandCompositor();
+ m_shell = Test::waylandShell();
+ m_shm = Test::waylandShmPool();
+ m_seat = Test::waylandSeat();
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
@@ -270,24 +219,7 @@ void LockScreenTest::init()
void LockScreenTest::cleanup()
{
- delete m_compositor;
- m_compositor = nullptr;
- delete m_seat;
- m_seat = nullptr;
- delete m_shm;
- m_shm = nullptr;
- delete m_shell;
- m_shell = nullptr;
- delete m_queue;
- m_queue = nullptr;
- if (m_thread) {
- m_connection->deleteLater();
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
- m_thread = nullptr;
- m_connection = nullptr;
- }
+ Test::destroyWaylandConnection();
}
void LockScreenTest::testPointer()
diff --git a/autotests/integration/maximize_test.cpp b/autotests/integration/maximize_test.cpp
index 0579409299..b375318c88 100644
--- a/autotests/integration/maximize_test.cpp
+++ b/autotests/integration/maximize_test.cpp
@@ -25,10 +25,7 @@ along with this program. If not, see .
#include "wayland_server.h"
#include "workspace.h"
-#include
#include
-#include
-#include
#include
#include
#include
@@ -39,8 +36,6 @@ along with this program. If not, see .
#include
#include
-#include
-
using namespace KWin;
using namespace KWayland::Client;
@@ -56,15 +51,6 @@ private Q_SLOTS:
void testMaximizedPassedToDeco();
void testInitiallyMaximized();
-
-private:
- KWayland::Client::Compositor *m_compositor = nullptr;
- Shell *m_shell = nullptr;
- ShmPool *m_shm = nullptr;
- EventQueue *m_queue = nullptr;
- ServerSideDecorationManager *m_ssd = nullptr;
- ConnectionThread *m_connection = nullptr;
- QThread *m_thread = nullptr;
};
void TestMaximized::initTestCase()
@@ -87,49 +73,7 @@ void TestMaximized::initTestCase()
void TestMaximized::init()
{
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
-
- m_compositor = registry.createCompositor(registry.interface(Registry::Interface::Compositor).name,
- registry.interface(Registry::Interface::Compositor).version,
- this);
- QVERIFY(m_compositor->isValid());
- m_shm = registry.createShmPool(registry.interface(Registry::Interface::Shm).name,
- registry.interface(Registry::Interface::Shm).version,
- this);
- QVERIFY(m_shm->isValid());
- m_shell = registry.createShell(registry.interface(Registry::Interface::Shell).name,
- registry.interface(Registry::Interface::Shell).version,
- this);
- QVERIFY(m_shell->isValid());
- m_ssd = registry.createServerSideDecorationManager(registry.interface(Registry::Interface::ServerSideDecorationManager).name,
- registry.interface(Registry::Interface::ServerSideDecorationManager).version,
- this);
- QVERIFY(m_ssd);
+ QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Decoration));
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(1280, 512));
@@ -137,28 +81,7 @@ void TestMaximized::init()
void TestMaximized::cleanup()
{
-#define CLEANUP(name) \
- if (name) { \
- delete name; \
- name = nullptr; \
- }
- CLEANUP(m_compositor)
- CLEANUP(m_shm)
- CLEANUP(m_shell)
- CLEANUP(m_ssd)
- CLEANUP(m_queue)
-
- if (m_connection) {
- m_connection->deleteLater();
- m_connection = nullptr;
- }
- if (m_thread) {
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
- m_thread = nullptr;
- }
-#undef CLEANUP
+ Test::destroyWaylandConnection();
}
void TestMaximized::testMaximizedPassedToDeco()
@@ -166,15 +89,11 @@ 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(m_compositor->createSurface());
- QScopedPointer shellSurface(m_shell->createSurface(surface.data()));
- QScopedPointer ssd(m_ssd->create(surface.data()));
+ QScopedPointer surface(Test::createSurface());
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
+ QScopedPointer ssd(Test::waylandServerSideDecoration()->create(surface.data()));
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), QSize(100, 50), Qt::blue);
QSignalSpy sizeChangedSpy(shellSurface.data(), &ShellSurface::sizeChanged);
QVERIFY(sizeChangedSpy.isValid());
@@ -231,8 +150,8 @@ void TestMaximized::testInitiallyMaximized()
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
- QScopedPointer surface(m_compositor->createSurface());
- QScopedPointer shellSurface(m_shell->createSurface(surface.data()));
+ QScopedPointer surface(Test::createSurface());
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QSignalSpy sizeChangedSpy(shellSurface.data(), &ShellSurface::sizeChanged);
QVERIFY(sizeChangedSpy.isValid());
@@ -242,11 +161,7 @@ void TestMaximized::testInitiallyMaximized()
QCOMPARE(shellSurface->size(), QSize(1280, 1024));
// now let's render in an incorrect size
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), QSize(100, 50), Qt::blue);
QVERIFY(clientAddedSpy.isEmpty());
QVERIFY(clientAddedSpy.wait());
diff --git a/autotests/integration/move_resize_window_test.cpp b/autotests/integration/move_resize_window_test.cpp
index a22f7d60aa..ed27a41543 100644
--- a/autotests/integration/move_resize_window_test.cpp
+++ b/autotests/integration/move_resize_window_test.cpp
@@ -30,11 +30,8 @@ along with this program. If not, see .
#include
#include
-#include
-#include
#include
#include
-#include
#include
#include
@@ -71,11 +68,7 @@ private Q_SLOTS:
private:
KWayland::Client::ConnectionThread *m_connection = nullptr;
KWayland::Client::Compositor *m_compositor = nullptr;
- KWayland::Client::ShmPool *m_shm = nullptr;
KWayland::Client::Shell *m_shell = nullptr;
- KWayland::Client::PlasmaShell *m_plasmaShell = nullptr;
- KWayland::Client::EventQueue *m_queue = nullptr;
- QThread *m_thread = nullptr;
};
void MoveResizeWindowTest::initTestCase()
@@ -95,74 +88,17 @@ void MoveResizeWindowTest::initTestCase()
void MoveResizeWindowTest::init()
{
- using namespace KWayland::Client;
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
- QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
- QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- QVERIFY(shmSpy.isValid());
- QVERIFY(shellSpy.isValid());
- QVERIFY(compositorSpy.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
- QVERIFY(!compositorSpy.isEmpty());
- QVERIFY(!shmSpy.isEmpty());
- QVERIFY(!shellSpy.isEmpty());
-
- m_compositor = registry.createCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value(), this);
- QVERIFY(m_compositor->isValid());
- m_shm = registry.createShmPool(shmSpy.first().first().value(), shmSpy.first().last().value(), this);
- QVERIFY(m_shm->isValid());
- m_shell = registry.createShell(shellSpy.first().first().value(), shellSpy.first().last().value(), this);
- QVERIFY(m_shell->isValid());
- m_plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name, registry.interface(Registry::Interface::PlasmaShell).version, this);
- QVERIFY(m_plasmaShell->isValid());
+ QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::PlasmaShell));
+ m_connection = Test::waylandConnection();
+ m_compositor = Test::waylandCompositor();
+ m_shell = Test::waylandShell();
screens()->setCurrent(0);
}
void MoveResizeWindowTest::cleanup()
{
- delete m_compositor;
- m_compositor = nullptr;
- delete m_shm;
- m_shm = nullptr;
- delete m_shell;
- m_shell = nullptr;
- delete m_plasmaShell;
- m_plasmaShell = nullptr;
- delete m_queue;
- m_queue = nullptr;
- if (m_thread) {
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
- m_thread = nullptr;
- }
-
+ Test::destroyWaylandConnection();
}
void MoveResizeWindowTest::testMove()
@@ -172,19 +108,15 @@ void MoveResizeWindowTest::testMove()
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
- QScopedPointer surface(m_compositor->createSurface());
+ QScopedPointer surface(Test::createSurface());
QVERIFY(!surface.isNull());
- QScopedPointer shellSurface(m_shell->createSurface(surface.data()));
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QVERIFY(!shellSurface.isNull());
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
QVERIFY(sizeChangeSpy.isValid());
// let's render
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), QSize(100, 50), Qt::blue);
m_connection->flush();
QVERIFY(clientAddedSpy.wait());
@@ -274,19 +206,15 @@ void MoveResizeWindowTest::testPackTo()
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
- QScopedPointer surface(m_compositor->createSurface());
+ QScopedPointer surface(Test::createSurface());
QVERIFY(!surface.isNull());
- QScopedPointer shellSurface(m_shell->createSurface(surface.data()));
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QVERIFY(!shellSurface.isNull());
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
QVERIFY(sizeChangeSpy.isValid());
// let's render
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), QSize(100, 50), Qt::blue);
m_connection->flush();
QVERIFY(clientAddedSpy.wait());
@@ -322,30 +250,26 @@ void MoveResizeWindowTest::testPackAgainstClient()
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
- QScopedPointer surface1(m_compositor->createSurface());
+ QScopedPointer surface1(Test::createSurface());
QVERIFY(!surface1.isNull());
- QScopedPointer surface2(m_compositor->createSurface());
+ QScopedPointer surface2(Test::createSurface());
QVERIFY(!surface2.isNull());
- QScopedPointer surface3(m_compositor->createSurface());
+ QScopedPointer surface3(Test::createSurface());
QVERIFY(!surface3.isNull());
- QScopedPointer surface4(m_compositor->createSurface());
+ QScopedPointer surface4(Test::createSurface());
QVERIFY(!surface4.isNull());
- QScopedPointer shellSurface1(m_shell->createSurface(surface1.data()));
+ QScopedPointer shellSurface1(Test::createShellSurface(surface1.data()));
QVERIFY(!shellSurface1.isNull());
- QScopedPointer shellSurface2(m_shell->createSurface(surface2.data()));
+ QScopedPointer shellSurface2(Test::createShellSurface(surface2.data()));
QVERIFY(!shellSurface2.isNull());
- QScopedPointer shellSurface3(m_shell->createSurface(surface3.data()));
+ QScopedPointer shellSurface3(Test::createShellSurface(surface3.data()));
QVERIFY(!shellSurface3.isNull());
- QScopedPointer shellSurface4(m_shell->createSurface(surface4.data()));
+ QScopedPointer shellSurface4(Test::createShellSurface(surface4.data()));
QVERIFY(!shellSurface4.isNull());
auto renderWindow = [this, &clientAddedSpy] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) {
// let's render
- QImage img(QSize(10, 10), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 10, 10));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface, QSize(10, 10), Qt::blue);
m_connection->flush();
QVERIFY(clientAddedSpy.wait());
@@ -365,15 +289,11 @@ void MoveResizeWindowTest::testPackAgainstClient()
renderWindow(surface3.data(), QStringLiteral("slotWindowPackRight"), QRect(1270, 507, 10, 10));
renderWindow(surface4.data(), QStringLiteral("slotWindowPackDown"), QRect(635, 1014, 10, 10));
- QScopedPointer surface(m_compositor->createSurface());
+ QScopedPointer surface(Test::createSurface());
QVERIFY(!surface.isNull());
- QScopedPointer shellSurface(m_shell->createSurface(surface.data()));
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QVERIFY(!shellSurface.isNull());
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), QSize(100, 50), Qt::blue);
m_connection->flush();
QVERIFY(clientAddedSpy.wait());
@@ -407,34 +327,26 @@ void MoveResizeWindowTest::testGrowShrink()
QVERIFY(clientAddedSpy.isValid());
// block geometry helper
- QScopedPointer surface1(m_compositor->createSurface());
+ QScopedPointer surface1(Test::createSurface());
QVERIFY(!surface1.isNull());
- QScopedPointer shellSurface1(m_shell->createSurface(surface1.data()));
+ QScopedPointer shellSurface1(Test::createShellSurface(surface1.data()));
QVERIFY(!shellSurface1.isNull());
- QImage img1(QSize(650, 514), QImage::Format_ARGB32);
- img1.fill(Qt::blue);
- surface1->attachBuffer(m_shm->createBuffer(img1));
- surface1->damage(QRect(0, 0, 650, 514));
- surface1->commit(Surface::CommitFlag::None);
+ Test::render(surface1.data(), QSize(650, 514), Qt::blue);
m_connection->flush();
QVERIFY(clientAddedSpy.wait());
clientAddedSpy.clear();
workspace()->slotWindowPackRight();
workspace()->slotWindowPackDown();
- QScopedPointer surface(m_compositor->createSurface());
+ QScopedPointer surface(Test::createSurface());
QVERIFY(!surface.isNull());
- QScopedPointer shellSurface(m_shell->createSurface(surface.data()));
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QVERIFY(!shellSurface.isNull());
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
QVERIFY(sizeChangeSpy.isValid());
// let's render
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), QSize(100, 50), Qt::blue);
m_connection->flush();
QVERIFY(clientAddedSpy.wait());
@@ -449,11 +361,7 @@ void MoveResizeWindowTest::testGrowShrink()
QFETCH(QString, methodCall);
QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData());
QVERIFY(sizeChangeSpy.wait());
- QImage img2(shellSurface->size(), QImage::Format_ARGB32);
- img2.fill(Qt::red);
- surface->attachBuffer(m_shm->createBuffer(img2));
- surface->damage(QRect(QPoint(0, 0), shellSurface->size()));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), shellSurface->size(), Qt::red);
QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged);
QVERIFY(geometryChangedSpy.isValid());
@@ -486,19 +394,15 @@ void MoveResizeWindowTest::testPointerMoveEnd()
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
- QScopedPointer surface(m_compositor->createSurface());
+ QScopedPointer surface(Test::createSurface());
QVERIFY(!surface.isNull());
- QScopedPointer shellSurface(m_shell->createSurface(surface.data()));
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QVERIFY(!shellSurface.isNull());
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
QVERIFY(sizeChangeSpy.isValid());
// let's render
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), QSize(100, 50), Qt::blue);
m_connection->flush();
QVERIFY(clientAddedSpy.wait());
@@ -547,22 +451,18 @@ void MoveResizeWindowTest::testPlasmaShellSurfaceMovable()
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
- QScopedPointer surface(m_compositor->createSurface());
+ QScopedPointer surface(Test::createSurface());
QVERIFY(!surface.isNull());
- QScopedPointer shellSurface(m_shell->createSurface(surface.data()));
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QVERIFY(!shellSurface.isNull());
// and a PlasmaShellSurface
- QScopedPointer plasmaSurface(m_plasmaShell->createSurface(surface.data()));
+ QScopedPointer plasmaSurface(Test::waylandPlasmaShell()->createSurface(surface.data()));
QVERIFY(!plasmaSurface.isNull());
QFETCH(KWayland::Client::PlasmaShellSurface::Role, role);
plasmaSurface->setRole(role);
// let's render
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit(Surface::CommitFlag::None);
+ Test::render(surface.data(), QSize(100, 50), Qt::blue);
m_connection->flush();
QVERIFY(clientAddedSpy.wait());
diff --git a/autotests/integration/plasma_surface_test.cpp b/autotests/integration/plasma_surface_test.cpp
index d14fb425e3..e2554f972e 100644
--- a/autotests/integration/plasma_surface_test.cpp
+++ b/autotests/integration/plasma_surface_test.cpp
@@ -52,11 +52,8 @@ private Q_SLOTS:
private:
ConnectionThread *m_connection = nullptr;
KWayland::Client::Compositor *m_compositor = nullptr;
- ShmPool *m_shm = nullptr;
Shell *m_shell = nullptr;
PlasmaShell *m_plasmaShell = nullptr;
- EventQueue *m_queue = nullptr;
- QThread *m_thread = nullptr;
};
void PlasmaSurfaceTest::initTestCase()
@@ -72,70 +69,15 @@ void PlasmaSurfaceTest::initTestCase()
void PlasmaSurfaceTest::init()
{
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
-
- m_compositor = registry.createCompositor(registry.interface(Registry::Interface::Compositor).name,
- registry.interface(Registry::Interface::Compositor).version,
- this);
- QVERIFY(m_compositor->isValid());
- m_shm = registry.createShmPool(registry.interface(Registry::Interface::Shm).name,
- registry.interface(Registry::Interface::Shm).version,
- this);
- QVERIFY(m_shm->isValid());
- m_shell = registry.createShell(registry.interface(Registry::Interface::Shell).name,
- registry.interface(Registry::Interface::Shell).version,
- this);
- QVERIFY(m_shell->isValid());
- m_plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name,
- registry.interface(Registry::Interface::PlasmaShell).version,
- this);
- QVERIFY(m_plasmaShell->isValid());
+ QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::PlasmaShell));
+ m_compositor = Test::waylandCompositor();
+ m_shell = Test::waylandShell();
+ m_plasmaShell = Test::waylandPlasmaShell();
}
void PlasmaSurfaceTest::cleanup()
{
-#define CLEANUP(name) delete name; name = nullptr;
- CLEANUP(m_plasmaShell)
- CLEANUP(m_shell)
- CLEANUP(m_shm)
- CLEANUP(m_compositor)
- CLEANUP(m_queue)
- if (m_connection) {
- m_connection->deleteLater();
- m_connection = nullptr;
- }
- if (m_thread) {
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
- m_thread = nullptr;
- }
-#undef CLEANUP
+ Test::destroyWaylandConnection();
}
void PlasmaSurfaceTest::testRoleOnAllDesktops_data()
@@ -154,9 +96,9 @@ void PlasmaSurfaceTest::testRoleOnAllDesktops_data()
void PlasmaSurfaceTest::testRoleOnAllDesktops()
{
// this test verifies that a ShellClient is set on all desktops when the role changes
- QScopedPointer surface(m_compositor->createSurface());
+ QScopedPointer surface(Test::createSurface());
QVERIFY(!surface.isNull());
- QScopedPointer shellSurface(m_shell->createSurface(surface.data()));
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QVERIFY(!shellSurface.isNull());
QScopedPointer plasmaSurface(m_plasmaShell->createSurface(surface.data()));
QVERIFY(!plasmaSurface.isNull());
@@ -165,11 +107,7 @@ void PlasmaSurfaceTest::testRoleOnAllDesktops()
QVERIFY(clientAddedSpy.isValid());
// now render to map the window
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit();
+ Test::render(surface.data(), QSize(100, 50), Qt::blue);
QVERIFY(clientAddedSpy.wait());
AbstractClient *c = workspace()->activeClient();
QVERIFY(c);
@@ -189,16 +127,14 @@ void PlasmaSurfaceTest::testRoleOnAllDesktops()
// let's create a second window where we init a little bit different
// first creating the PlasmaSurface then the Shell Surface
- QScopedPointer surface2(m_compositor->createSurface());
+ QScopedPointer surface2(Test::createSurface());
QVERIFY(!surface2.isNull());
QScopedPointer plasmaSurface2(m_plasmaShell->createSurface(surface2.data()));
QVERIFY(!plasmaSurface2.isNull());
plasmaSurface2->setRole(role);
- QScopedPointer shellSurface2(m_shell->createSurface(surface2.data()));
+ QScopedPointer shellSurface2(Test::createShellSurface(surface2.data()));
QVERIFY(!shellSurface2.isNull());
- surface2->attachBuffer(m_shm->createBuffer(img));
- surface2->damage(QRect(0, 0, 100, 50));
- surface2->commit();
+ Test::render(surface2.data(), QSize(100, 50), Qt::blue);
QVERIFY(clientAddedSpy.wait());
QVERIFY(workspace()->activeClient() != c);
@@ -228,9 +164,9 @@ void PlasmaSurfaceTest::testAcceptsFocus_data()
void PlasmaSurfaceTest::testAcceptsFocus()
{
// this test verifies that some surface roles don't get focus
- QScopedPointer surface(m_compositor->createSurface());
+ QScopedPointer surface(Test::createSurface());
QVERIFY(!surface.isNull());
- QScopedPointer shellSurface(m_shell->createSurface(surface.data()));
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
QVERIFY(!shellSurface.isNull());
QScopedPointer plasmaSurface(m_plasmaShell->createSurface(surface.data()));
QVERIFY(!plasmaSurface.isNull());
@@ -241,11 +177,7 @@ void PlasmaSurfaceTest::testAcceptsFocus()
QVERIFY(clientAddedSpy.isValid());
// now render to map the window
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- surface->attachBuffer(m_shm->createBuffer(img));
- surface->damage(QRect(0, 0, 100, 50));
- surface->commit();
+ Test::render(surface.data(), QSize(100, 50), Qt::blue);
QVERIFY(clientAddedSpy.wait());
auto c = clientAddedSpy.first().first().value();
diff --git a/autotests/integration/plasmawindow_test.cpp b/autotests/integration/plasmawindow_test.cpp
index 45f02d7eed..abceb706ce 100644
--- a/autotests/integration/plasmawindow_test.cpp
+++ b/autotests/integration/plasmawindow_test.cpp
@@ -29,12 +29,8 @@ along with this program. If not, see .
#include
#include
-#include
-#include
#include
-#include
#include
-#include
#include
#include
//screenlocker
@@ -67,13 +63,9 @@ private Q_SLOTS:
void testDestroyedButNotUnmapped();
private:
- ConnectionThread *m_connection = nullptr;
PlasmaWindowManagement *m_windowManagement = nullptr;
KWayland::Client::Compositor *m_compositor = nullptr;
Shell *m_shell = nullptr;
- ShmPool *m_shm = nullptr;
- EventQueue *m_queue = nullptr;
- QThread *m_thread = nullptr;
};
void PlasmaWindowTest::initTestCase()
@@ -98,49 +90,10 @@ void PlasmaWindowTest::initTestCase()
void PlasmaWindowTest::init()
{
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
-
- m_windowManagement = registry.createPlasmaWindowManagement(registry.interface(Registry::Interface::PlasmaWindowManagement).name,
- registry.interface(Registry::Interface::PlasmaWindowManagement).version,
- this);
- QVERIFY(m_windowManagement);
- m_compositor = registry.createCompositor(registry.interface(Registry::Interface::Compositor).name,
- registry.interface(Registry::Interface::Compositor).version,
- this);
- QVERIFY(m_compositor);
- m_shm = registry.createShmPool(registry.interface(Registry::Interface::Shm).name,
- registry.interface(Registry::Interface::Shm).version,
- this);
- QVERIFY(m_shm);
- m_shell = registry.createShell(registry.interface(Registry::Interface::Shell).name,
- registry.interface(Registry::Interface::Shell).version,
- this);
- QVERIFY(m_shell);
+ QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::WindowManagement));
+ m_windowManagement = Test::waylandWindowManagement();
+ m_compositor = Test::waylandCompositor();
+ m_shell = Test::waylandShell();
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
@@ -148,27 +101,7 @@ void PlasmaWindowTest::init()
void PlasmaWindowTest::cleanup()
{
-#define CLEANUP(name) \
- if (name) { \
- delete name; \
- name = nullptr; \
- }
- CLEANUP(m_windowManagement)
- CLEANUP(m_shm)
- CLEANUP(m_shell)
- CLEANUP(m_compositor)
- CLEANUP(m_queue)
-#undef CLEANUP
- if (m_connection) {
- m_connection->deleteLater();
- m_connection = nullptr;
- }
- if (m_thread) {
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
- m_thread = nullptr;
- }
+ Test::destroyWaylandConnection();
}
void PlasmaWindowTest::testCreateDestroyX11PlasmaWindow()
@@ -304,35 +237,27 @@ void PlasmaWindowTest::testPopupWindowNoPlasmaWindow()
QVERIFY(plasmaWindowCreatedSpy.isValid());
// first create the parent window
- QScopedPointer parentSurface(m_compositor->createSurface());
- QScopedPointer parentShellSurface(m_shell->createSurface(parentSurface.data()));
+ QScopedPointer parentSurface(Test::createSurface());
+ QScopedPointer parentShellSurface(Test::createShellSurface(parentSurface.data()));
// map that window
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- parentSurface->attachBuffer(m_shm->createBuffer(img));
- parentSurface->damage(QRect(0, 0, 100, 50));
- parentSurface->commit();
+ Test::render(parentSurface.data(), QSize(100, 50), Qt::blue);
// this should create a plasma window
QVERIFY(plasmaWindowCreatedSpy.wait());
// now let's create a popup window for it
- QScopedPointer popupSurface(m_compositor->createSurface());
- QScopedPointer popupShellSurface(m_shell->createSurface(popupSurface.data()));
+ QScopedPointer popupSurface(Test::createSurface());
+ QScopedPointer popupShellSurface(Test::createShellSurface(popupSurface.data()));
popupShellSurface->setTransient(parentSurface.data(), QPoint(0, 0), ShellSurface::TransientFlag::NoFocus);
// let's map it
- popupSurface->attachBuffer(m_shm->createBuffer(img));
- popupSurface->damage(QRect(0, 0, 100, 50));
- popupSurface->commit();
+ Test::render(popupSurface.data(), QSize(100, 50), Qt::blue);
// this should not create a plasma window
QVERIFY(!plasmaWindowCreatedSpy.wait());
// now the same with an already mapped surface when we create the shell surface
- QScopedPointer popup2Surface(m_compositor->createSurface());
- popup2Surface->attachBuffer(m_shm->createBuffer(img));
- popup2Surface->damage(QRect(0, 0, 100, 50));
- popup2Surface->commit();
- QScopedPointer popup2ShellSurface(m_shell->createSurface(popup2Surface.data()));
+ QScopedPointer popup2Surface(Test::createSurface());
+ Test::render(popup2Surface.data(), QSize(100, 50), Qt::blue);
+ QScopedPointer popup2ShellSurface(Test::createShellSurface(popup2Surface.data()));
popup2ShellSurface->setTransient(popupSurface.data(), QPoint(0, 0), ShellSurface::TransientFlag::NoFocus);
// this should not create a plasma window
@@ -409,14 +334,10 @@ void PlasmaWindowTest::testDestroyedButNotUnmapped()
QVERIFY(plasmaWindowCreatedSpy.isValid());
// first create the parent window
- QScopedPointer parentSurface(m_compositor->createSurface());
- QScopedPointer parentShellSurface(m_shell->createSurface(parentSurface.data()));
+ QScopedPointer parentSurface(Test::createSurface());
+ QScopedPointer parentShellSurface(Test::createShellSurface(parentSurface.data()));
// map that window
- QImage img(QSize(100, 50), QImage::Format_ARGB32);
- img.fill(Qt::blue);
- parentSurface->attachBuffer(m_shm->createBuffer(img));
- parentSurface->damage(QRect(0, 0, 100, 50));
- parentSurface->commit();
+ Test::render(parentSurface.data(), QSize(100, 50), Qt::blue);
// this should create a plasma window
QVERIFY(plasmaWindowCreatedSpy.wait());
QCOMPARE(plasmaWindowCreatedSpy.count(), 1);
diff --git a/autotests/integration/pointer_input.cpp b/autotests/integration/pointer_input.cpp
index bd2ede8ce5..3d99daf26d 100644
--- a/autotests/integration/pointer_input.cpp
+++ b/autotests/integration/pointer_input.cpp
@@ -33,8 +33,6 @@ along with this program. If not, see .
#include
#include
-#include
-#include
#include
#include
#include
@@ -75,13 +73,9 @@ private Q_SLOTS:
private:
void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50));
- KWayland::Client::ConnectionThread *m_connection = nullptr;
KWayland::Client::Compositor *m_compositor = nullptr;
KWayland::Client::Seat *m_seat = nullptr;
- KWayland::Client::ShmPool *m_shm = nullptr;
KWayland::Client::Shell *m_shell = nullptr;
- KWayland::Client::EventQueue *m_queue = nullptr;
- QThread *m_thread = nullptr;
};
void PointerInputTest::initTestCase()
@@ -111,57 +105,11 @@ void PointerInputTest::initTestCase()
void PointerInputTest::init()
{
- using namespace KWayland::Client;
- // setup connection
- m_connection = new ConnectionThread;
- QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
- QVERIFY(connectedSpy.isValid());
- m_connection->setSocketName(s_socketName);
-
- m_thread = new QThread(this);
- m_connection->moveToThread(m_thread);
- m_thread->start();
-
- m_connection->initConnection();
- QVERIFY(connectedSpy.wait());
-
- m_queue = new EventQueue(this);
- QVERIFY(!m_queue->isValid());
- m_queue->setup(m_connection);
- QVERIFY(m_queue->isValid());
-
- Registry registry;
- registry.setEventQueue(m_queue);
- QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
- QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
- QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
- QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
- QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
- QVERIFY(allAnnounced.isValid());
- QVERIFY(shmSpy.isValid());
- QVERIFY(shellSpy.isValid());
- QVERIFY(compositorSpy.isValid());
- QVERIFY(seatSpy.isValid());
- registry.create(m_connection->display());
- QVERIFY(registry.isValid());
- registry.setup();
- QVERIFY(allAnnounced.wait());
- QVERIFY(!compositorSpy.isEmpty());
- QVERIFY(!shmSpy.isEmpty());
- QVERIFY(!shellSpy.isEmpty());
- QVERIFY(!seatSpy.isEmpty());
-
- m_compositor = registry.createCompositor(compositorSpy.first().first().value(), compositorSpy.first().last().value(), this);
- QVERIFY(m_compositor->isValid());
- m_shm = registry.createShmPool(shmSpy.first().first().value(), shmSpy.first().last().value(), this);
- QVERIFY(m_shm->isValid());
- m_shell = registry.createShell(shellSpy.first().first().value