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 @@ -124,13 +124,19 @@ KWayland::Client::ShellSurface *createShellSurface(KWayland::Client::Surface *surface, QObject *parent = nullptr); KWayland::Client::XdgShellSurface *createXdgShellV5Surface(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); /** + * Creates a shared memory buffer using the supplied image @p img and attaches it to the @p surface + */ +void render(KWayland::Client::Surface *surface, const QImage &img); + +/** * Waits till a new ShellClient is shown and returns the created ShellClient. * If no ShellClient gets shown during @p timeout @c null is returned. **/ diff --git a/autotests/integration/scene_qpainter_test.cpp b/autotests/integration/scene_qpainter_test.cpp --- a/autotests/integration/scene_qpainter_test.cpp +++ b/autotests/integration/scene_qpainter_test.cpp @@ -223,7 +223,17 @@ // now let's map the window s->setScale(2); - QVERIFY(Test::renderAndWaitForShown(s.data(), QSize(400, 600), Qt::blue)); + + //draw a blue square@400x600 with red rectangle@200x200 in the middle + const QSize size(400,600); + QImage img(size, QImage::Format_ARGB32); + img.fill(Qt::blue); + QPainter surfacePainter(&img); + surfacePainter.fillRect(200,300,200,200, Qt::red); + + //add buffer + Test::render(s.data(), img); + Test::waitForWaylandWindowShown(); // which should trigger a frame if (frameRenderedSpy.isEmpty()) { @@ -233,6 +243,7 @@ referenceImage.fill(Qt::black); QPainter painter(&referenceImage); painter.fillRect(0, 0, 200, 300, Qt::blue); + painter.fillRect(100, 150, 100, 100, Qt::red); painter.fillRect(5, 5, 10, 10, Qt::red); //cursor QCOMPARE(referenceImage, *scene->backend()->buffer()); 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 @@ -295,8 +295,13 @@ { QImage img(size, format); img.fill(color); + render(surface, img); +} + +void render(Surface *surface, const QImage &img) +{ surface->attachBuffer(s_waylandConnection.shm->createBuffer(img)); - surface->damage(QRect(QPoint(0, 0), size)); + surface->damage(QRect(QPoint(0, 0), img.size())); surface->commit(Surface::CommitFlag::None); }