autotests: Fix testSceneQPainter

Scene::qpainterRenderBuffer() was ported to AbstractOutput but not
testSceneQPainter, which results in a few broken tests.
This commit is contained in:
Vlad Zahorodnii 2021-09-07 20:05:41 +03:00
parent 6d35d63acb
commit 2d9207e251

View file

@ -105,7 +105,8 @@ void SceneQPainterTest::testStartFrame()
const QImage cursorImage = cursor->image();
QVERIFY(!cursorImage.isNull());
p.drawImage(cursor->pos() - cursor->hotspot(), cursorImage);
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
const auto outputs = kwinApp()->platform()->enabledOutputs();
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(outputs.constFirst()));
}
void SceneQPainterTest::testCursorMoving()
@ -136,7 +137,8 @@ void SceneQPainterTest::testCursorMoving()
const QImage cursorImage = cursor->image();
QVERIFY(!cursorImage.isNull());
p.drawImage(QPoint(45, 45) - cursor->hotspot(), cursorImage);
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
const auto outputs = kwinApp()->platform()->enabledOutputs();
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(outputs.constFirst()));
}
void SceneQPainterTest::testWindow()
@ -174,13 +176,14 @@ void SceneQPainterTest::testWindow()
p->setCursor(cs.data(), QPoint(5, 5));
QVERIFY(frameRenderedSpy.wait());
painter.fillRect(KWin::Cursors::self()->mouse()->pos().x() - 5, KWin::Cursors::self()->mouse()->pos().y() - 5, 10, 10, Qt::red);
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
const auto outputs = kwinApp()->platform()->enabledOutputs();
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(outputs.constFirst()));
// let's move the cursor again
KWin::Cursors::self()->mouse()->setPos(10, 10);
QVERIFY(frameRenderedSpy.wait());
painter.fillRect(0, 0, 200, 300, Qt::blue);
painter.fillRect(5, 5, 10, 10, Qt::red);
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(outputs.constFirst()));
}
void SceneQPainterTest::testWindowScaled()
@ -230,7 +233,8 @@ void SceneQPainterTest::testWindowScaled()
painter.fillRect(100, 150, 100, 100, Qt::red);
painter.fillRect(5, 5, 10, 10, Qt::red); //cursor
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
const auto outputs = kwinApp()->platform()->enabledOutputs();
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(outputs.constFirst()));
}
void SceneQPainterTest::testCompositorRestart()
@ -274,7 +278,8 @@ void SceneQPainterTest::testCompositorRestart()
const QImage cursorImage = cursor->image();
QVERIFY(!cursorImage.isNull());
painter.drawImage(QPoint(400, 400) - cursor->hotspot(), cursorImage);
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(0));
const auto outputs = kwinApp()->platform()->enabledOutputs();
QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(outputs.constFirst()));
}
struct XcbConnectionDeleter
@ -363,7 +368,7 @@ void SceneQPainterTest::testX11Window()
QVERIFY(frameRenderedSpy.wait());
const QPoint startPos = client->pos() + client->clientPos();
auto image = scene->qpainterRenderBuffer(0);
auto image = scene->qpainterRenderBuffer(kwinApp()->platform()->enabledOutputs().constFirst());
QCOMPARE(image->copy(QRect(startPos, client->clientSize())), compareImage);
// and destroy the window again