From 2d9207e251e151eb8ee4efcdd1ef0f65269ec00b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 7 Sep 2021 20:05:41 +0300 Subject: [PATCH] autotests: Fix testSceneQPainter Scene::qpainterRenderBuffer() was ported to AbstractOutput but not testSceneQPainter, which results in a few broken tests. --- autotests/integration/scene_qpainter_test.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/autotests/integration/scene_qpainter_test.cpp b/autotests/integration/scene_qpainter_test.cpp index 7ca5bcb230..9565e5ebb0 100644 --- a/autotests/integration/scene_qpainter_test.cpp +++ b/autotests/integration/scene_qpainter_test.cpp @@ -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