From e4d4714aae0c9f9602848efb0d746e844dfee415 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 11 Aug 2023 13:05:10 +0200 Subject: [PATCH] Increase setup precision and reduce test precision Reduce test precision to account for rounding errors, and at the same time increase the setup precession by premultiplying in rgba64 instead of argb32, which makes the test randomness trigger more regularly. Task-number: QTBUG-115945 Change-Id: I3e95449ada26ff5bb0acc00412f345733603f4c0 Reviewed-by: Timur Pocheptsov (cherry picked from commit ae9594ea98e723a99b8ad8c056505f4c7deb77c9) Reviewed-by: Qt Cherry-pick Bot --- .../auto/gui/painting/qcolorspace/tst_qcolorspace.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp index 08f45a25525..12178119e10 100644 --- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -349,8 +349,10 @@ void tst_QColorSpace::imageConversion64PM() for (int j = 0; j < 16; ++j) { int a = j * 15; - for (int i = 0; i < 256; ++i) - testImage.setPixel(i, j, qPremultiply(qRgba(i, i, i, a))); + for (int i = 0; i < 256; ++i) { + QRgba64 color = QRgba64::fromRgba(i, i, i, a); + testImage.setPixelColor(i, j, QColor::fromRgba64(color)); + } } testImage.setColorSpace(fromColorSpace); @@ -389,8 +391,8 @@ void tst_QColorSpace::imageConversion64PM() for (int i = 0; i < 256; ++i) { QRgb expected = qPremultiply(qRgba(i, i, i, expectedAlpha)); QRgb p = testImage.pixel(i, j); - QCOMPARE(qRed(p), qGreen(p)); - QCOMPARE(qRed(p), qBlue(p)); + QVERIFY(qAbs(qRed(p) - qGreen(p)) <= 1); + QVERIFY(qAbs(qRed(p) - qBlue(p)) <= 1); QCOMPARE(qAlpha(p), expectedAlpha); QVERIFY((lastRed - qRed(p)) <= 0); QVERIFY((lastGreen - qGreen(p)) <= 0);