From d59e1d8491b3590145e5da0d8b81dc78cc353137 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 1 Oct 2009 11:32:27 +0200 Subject: Fix tst_QPixmap on 16bit display Pulse machine runs a 16bit display, some comparisons fails. Reviewed-by: Samuel --- tests/auto/qpixmap/tst_qpixmap.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 1bfddc1..8151e62 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -67,6 +67,9 @@ #include #endif +#ifdef Q_WS_X11 +#include +#endif //TESTED_CLASS= //TESTED_FILES= @@ -175,6 +178,12 @@ static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) int size = actual.width() * actual.height(); + int threshold = 2; +#ifdef Q_WS_X11 + if (QX11Info::appDepth() == 16) + threshold = 10; +#endif + QRgb *a = (QRgb *)actualImage.bits(); QRgb *e = (QRgb *)expectedImage.bits(); for (int i = 0; i < size; ++i) { @@ -183,11 +192,11 @@ static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) bool result = true; - if (qAbs(ca.red() - ce.red()) > 2) + if (qAbs(ca.red() - ce.red()) > threshold) result = false; - if (qAbs(ca.green() - ce.green()) > 2) + if (qAbs(ca.green() - ce.green()) > threshold) result = false; - if (qAbs(ca.blue() - ce.blue()) > 2) + if (qAbs(ca.blue() - ce.blue()) > threshold) result = false; if (!result) @@ -293,15 +302,23 @@ void tst_QPixmap::setAlphaChannel() void tst_QPixmap::fromImage_data() { + bool is16bit = false; +#ifdef Q_WS_X11 + if (QX11Info::appDepth() == 16) + is16bit = true; +#endif + QTest::addColumn("format"); QTest::newRow("Format_Mono") << QImage::Format_Mono; QTest::newRow("Format_MonoLSB") << QImage::Format_MonoLSB; // QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8; - QTest::newRow("Format_RGB32") << QImage::Format_RGB32; + if (!is16bit) + QTest::newRow("Format_RGB32") << QImage::Format_RGB32; QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32; QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied; - QTest::newRow("Format_RGB16") << QImage::Format_RGB16; + if (!is16bit) + QTest::newRow("Format_RGB16") << QImage::Format_RGB16; } void tst_QPixmap::fromImage() @@ -986,7 +1003,7 @@ static void compareImages(const QImage &image1, const QImage &image2) QRgb p1 = image1.pixel(x, y); QRgb p2 = image2.pixel(x, y); - bool pixelMatches = + bool pixelMatches = qAbs(qRed(p1) - qRed(p2)) <= fuzz && qAbs(qGreen(p1) - qGreen(p2)) <= fuzz && qAbs(qBlue(p1) - qBlue(p2)) <= fuzz -- cgit v0.12