summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp29
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