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>
This commit is contained in:
parent
046d819e2e
commit
ec675f5dc7
@ -353,6 +353,9 @@ void tst_QColorSpace::imageConversion64()
|
|||||||
lastGreen = qGreen(p);
|
lastGreen = qGreen(p);
|
||||||
lastBlue = qBlue(p);
|
lastBlue = qBlue(p);
|
||||||
}
|
}
|
||||||
|
QCOMPARE(lastRed, 255);
|
||||||
|
QCOMPARE(lastGreen, 255);
|
||||||
|
QCOMPARE(lastBlue, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QColorSpace::imageConversion64PM_data()
|
void tst_QColorSpace::imageConversion64PM_data()
|
||||||
@ -383,19 +386,20 @@ void tst_QColorSpace::imageConversion64PM()
|
|||||||
int lastGreen = 0;
|
int lastGreen = 0;
|
||||||
int lastBlue = 0;
|
int lastBlue = 0;
|
||||||
for (int j = 0; j < 16; ++j) {
|
for (int j = 0; j < 16; ++j) {
|
||||||
|
const int expectedAlpha = j * 15;
|
||||||
for (int i = 0; i < 256; ++i) {
|
for (int i = 0; i < 256; ++i) {
|
||||||
QRgb p = testImage.pixel(i, j);
|
QRgb p = testImage.pixel(i, j);
|
||||||
QVERIFY(qRed(p) >= lastRed);
|
QVERIFY(qRed(p) >= lastRed);
|
||||||
QVERIFY(qGreen(p) >= lastGreen);
|
QVERIFY(qGreen(p) >= lastGreen);
|
||||||
QVERIFY(qBlue(p) >= lastBlue);
|
QVERIFY(qBlue(p) >= lastBlue);
|
||||||
QCOMPARE(qAlpha(p), j * 15);
|
QCOMPARE(qAlpha(p), expectedAlpha);
|
||||||
lastRed = qRed(p);
|
lastRed = qRed(p);
|
||||||
lastGreen = qGreen(p);
|
lastGreen = qGreen(p);
|
||||||
lastBlue = qBlue(p);
|
lastBlue = qBlue(p);
|
||||||
}
|
}
|
||||||
QVERIFY(lastRed <= j * 15);
|
QVERIFY(lastRed <= expectedAlpha);
|
||||||
QVERIFY(lastGreen <= j * 15);
|
QVERIFY(lastGreen <= expectedAlpha);
|
||||||
QVERIFY(lastBlue <= j * 15);
|
QVERIFY(lastBlue <= expectedAlpha);
|
||||||
lastRed = 0;
|
lastRed = 0;
|
||||||
lastGreen = 0;
|
lastGreen = 0;
|
||||||
lastBlue = 0;
|
lastBlue = 0;
|
||||||
@ -404,21 +408,26 @@ void tst_QColorSpace::imageConversion64PM()
|
|||||||
testImage.convertToColorSpace(fromColorSpace);
|
testImage.convertToColorSpace(fromColorSpace);
|
||||||
QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace));
|
QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace));
|
||||||
for (int j = 0; j < 16; ++j) {
|
for (int j = 0; j < 16; ++j) {
|
||||||
|
const int expectedAlpha = j * 15;
|
||||||
for (int i = 0; i < 256; ++i) {
|
for (int i = 0; i < 256; ++i) {
|
||||||
|
QRgb expected = qPremultiply(qRgba(i, i, i, expectedAlpha));
|
||||||
QRgb p = testImage.pixel(i, j);
|
QRgb p = testImage.pixel(i, j);
|
||||||
QCOMPARE(qRed(p), qGreen(p));
|
QCOMPARE(qRed(p), qGreen(p));
|
||||||
QCOMPARE(qRed(p), qBlue(p));
|
QCOMPARE(qRed(p), qBlue(p));
|
||||||
QCOMPARE(qAlpha(p), j * 15);
|
QCOMPARE(qAlpha(p), expectedAlpha);
|
||||||
QVERIFY((lastRed - qRed(p)) <= 0);
|
QVERIFY((lastRed - qRed(p)) <= 0);
|
||||||
QVERIFY((lastGreen - qGreen(p)) <= 0);
|
QVERIFY((lastGreen - qGreen(p)) <= 0);
|
||||||
QVERIFY((lastBlue - qBlue(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);
|
lastRed = qRed(p);
|
||||||
lastGreen = qGreen(p);
|
lastGreen = qGreen(p);
|
||||||
lastBlue = qBlue(p);
|
lastBlue = qBlue(p);
|
||||||
}
|
}
|
||||||
QVERIFY(lastRed <= j * 15);
|
QCOMPARE(lastRed, expectedAlpha);
|
||||||
QVERIFY(lastGreen <= j * 15);
|
QCOMPARE(lastGreen, expectedAlpha);
|
||||||
QVERIFY(lastBlue <= j * 15);
|
QCOMPARE(lastBlue, expectedAlpha);
|
||||||
lastRed = 0;
|
lastRed = 0;
|
||||||
lastGreen = 0;
|
lastGreen = 0;
|
||||||
lastBlue = 0;
|
lastBlue = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user