Improve testWindowScaled test
Summary: Comparing a pure blue square isn't a very effective test as someone cropping the image will still pass. Reviewers: #plasma, graesslin Reviewed By: #plasma, graesslin Subscribers: plasma-devel, kwin, #kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6982
This commit is contained in:
parent
bc003c0228
commit
0809a357c1
3 changed files with 24 additions and 2 deletions
|
@ -124,12 +124,18 @@ QObject *createShellSurface(ShellSurfaceType type, KWayland::Client::Surface *su
|
|||
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.
|
||||
|
|
|
@ -223,7 +223,17 @@ void SceneQPainterTest::testWindowScaled()
|
|||
|
||||
// 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 @@ void SceneQPainterTest::testWindowScaled()
|
|||
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());
|
||||
|
|
|
@ -295,8 +295,13 @@ void render(Surface *surface, const QSize &size, const QColor &color, const QIma
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue