summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-06-13 09:28:46 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-06-16 12:23:41 +0200
commitec675f5dc7d64bb7ebf7f4cce4f33d4b10dfe439 (patch)
tree8a1ad159f751743b67c0d6020b992d46cafaf054 /tests/auto/gui
parent046d819e2e25d2752b3898dd775eeb560e24b4ce (diff)
Improve tst_QColorSpace::imageConversion64PM test
Makes it able to catch the last bug of saturating color values above a certain value. Change-Id: Ib2a3918623a1defe2981efe61cf8118e019e9d4b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
index 913fe55364..576885de34 100644
--- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
+++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
@@ -353,6 +353,9 @@ void tst_QColorSpace::imageConversion64()
lastGreen = qGreen(p);
lastBlue = qBlue(p);
}
+ QCOMPARE(lastRed, 255);
+ QCOMPARE(lastGreen, 255);
+ QCOMPARE(lastBlue, 255);
}
void tst_QColorSpace::imageConversion64PM_data()
@@ -383,19 +386,20 @@ void tst_QColorSpace::imageConversion64PM()
int lastGreen = 0;
int lastBlue = 0;
for (int j = 0; j < 16; ++j) {
+ const int expectedAlpha = j * 15;
for (int i = 0; i < 256; ++i) {
QRgb p = testImage.pixel(i, j);
QVERIFY(qRed(p) >= lastRed);
QVERIFY(qGreen(p) >= lastGreen);
QVERIFY(qBlue(p) >= lastBlue);
- QCOMPARE(qAlpha(p), j * 15);
+ QCOMPARE(qAlpha(p), expectedAlpha);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
}
- QVERIFY(lastRed <= j * 15);
- QVERIFY(lastGreen <= j * 15);
- QVERIFY(lastBlue <= j * 15);
+ QVERIFY(lastRed <= expectedAlpha);
+ QVERIFY(lastGreen <= expectedAlpha);
+ QVERIFY(lastBlue <= expectedAlpha);
lastRed = 0;
lastGreen = 0;
lastBlue = 0;
@@ -404,21 +408,26 @@ void tst_QColorSpace::imageConversion64PM()
testImage.convertToColorSpace(fromColorSpace);
QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace));
for (int j = 0; j < 16; ++j) {
+ const int expectedAlpha = j * 15;
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));
- QCOMPARE(qAlpha(p), j * 15);
+ QCOMPARE(qAlpha(p), expectedAlpha);
QVERIFY((lastRed - qRed(p)) <= 0);
QVERIFY((lastGreen - qGreen(p)) <= 0);
QVERIFY((lastBlue - qBlue(p)) <= 0);
+ QVERIFY(qAbs(qRed(p) - qRed(expected)) <= 1);
+ QVERIFY(qAbs(qGreen(p) - qGreen(expected)) <= 1);
+ QVERIFY(qAbs(qBlue(p) - qBlue(expected)) <= 1);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
}
- QVERIFY(lastRed <= j * 15);
- QVERIFY(lastGreen <= j * 15);
- QVERIFY(lastBlue <= j * 15);
+ QCOMPARE(lastRed, expectedAlpha);
+ QCOMPARE(lastGreen, expectedAlpha);
+ QCOMPARE(lastBlue, expectedAlpha);
lastRed = 0;
lastGreen = 0;
lastBlue = 0;