diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-12-07 16:55:53 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-08 08:51:35 +0100 |
commit | 11732d133b6a1e367b43d6a2853b3e297eafbf9f (patch) | |
tree | e27d17f5ba012dfbfd624c4f96bf058e4767504a /tests/auto/gui/image | |
parent | dd2b5b88be78927cb3161a1c1e7219f36417b376 (diff) |
QPixmap test: Make lenientCompare() more verbose.
- Output cause of failure
- Streamline code
Change-Id: I597e8cf0178c2417ea55c2319398a48d839b4474
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/gui/image')
-rw-r--r-- | tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index f386624092..6f14ecef60 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -167,32 +167,28 @@ static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) QImage expectedImage = expected.toImage().convertToFormat(QImage::Format_RGB32); QImage actualImage = actual.toImage().convertToFormat(QImage::Format_RGB32); - if (expectedImage.size() != actualImage.size()) + if (expectedImage.size() != actualImage.size()) { + qWarning("Image size comparison failed: expected: %dx%d, got %dx%d", + expectedImage.size().width(), expectedImage.size().height(), + actualImage.size().width(), actualImage.size().height()); return false; + } - int size = actual.width() * actual.height(); - - int threshold = 2; - if (QPixmap::defaultDepth() == 16) - threshold = 10; + const int size = actual.width() * actual.height(); + const int threshold = QPixmap::defaultDepth() == 16 ? 10 : 2; QRgb *a = (QRgb *)actualImage.bits(); QRgb *e = (QRgb *)expectedImage.bits(); for (int i = 0; i < size; ++i) { - QColor ca(a[i]); - QColor ce(e[i]); - - bool result = true; - - if (qAbs(ca.red() - ce.red()) > threshold) - result = false; - if (qAbs(ca.green() - ce.green()) > threshold) - result = false; - if (qAbs(ca.blue() - ce.blue()) > threshold) - result = false; - - if (!result) + const QColor ca(a[i]); + const QColor ce(e[i]); + if (qAbs(ca.red() - ce.red()) > threshold + || qAbs(ca.green() - ce.green()) > threshold + || qAbs(ca.blue() - ce.blue()) > threshold) { + qWarning("Color mismatch at pixel #%d: Expected: %d,%d,%d, got %d,%d,%d", + i, ce.red(), ce.green(), ce.blue(), ca.red(), ca.green(), ca.blue()); return false; + } } return true; |