diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-01 09:32:27 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-01 09:36:14 (GMT) |
commit | d59e1d8491b3590145e5da0d8b81dc78cc353137 (patch) | |
tree | daf7153ac4219f84ec46eb6b4dce418016a107eb /tests/auto/qpixmap/tst_qpixmap.cpp | |
parent | 4b3e0adec89e2d0ce4024d764e7856a077302e28 (diff) | |
download | Qt-d59e1d8491b3590145e5da0d8b81dc78cc353137.zip Qt-d59e1d8491b3590145e5da0d8b81dc78cc353137.tar.gz Qt-d59e1d8491b3590145e5da0d8b81dc78cc353137.tar.bz2 |
Fix tst_QPixmap on 16bit display
Pulse machine runs a 16bit display, some comparisons fails.
Reviewed-by: Samuel
Diffstat (limited to 'tests/auto/qpixmap/tst_qpixmap.cpp')
-rw-r--r-- | tests/auto/qpixmap/tst_qpixmap.cpp | 29 |
1 files 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 <bitdev.h> #endif +#ifdef Q_WS_X11 +#include <QX11Info> +#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<QImage::Format>("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 |