diff options
author | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-03-17 15:54:44 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-17 17:05:20 +0100 |
commit | 05a12c9ebe558303fb1eb92a272e66fa1313b854 (patch) | |
tree | c36f4890714d30c1075f907c14992bfcddc0b1b9 /tests | |
parent | acf1298e21abd2fb12d8364c593fbbff345374bc (diff) |
Stabilize tst_qquickwindow and tst_scenegraph.
Change-Id: I6f1b6c0ed86869149658e3ce07545217ce9797a7
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 40 | ||||
-rw-r--r-- | tests/auto/quick/scenegraph/tst_scenegraph.cpp | 2 |
2 files changed, 39 insertions, 3 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 28945c4cb5..fcab0c7ef2 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1112,6 +1112,43 @@ void tst_qquickwindow::animationsWhileHidden() QTRY_VERIFY(window->isVisible()); } +// When running on native Nvidia graphics cards on linux, the +// distance field glyph pixels have a measurable, but not visible +// pixel error. Use a custom compare function to avoid +// +// This was GT-216 with the ubuntu "nvidia-319" driver package. +// llvmpipe does not show the same issue. +// +bool compareImages(const QImage &ia, const QImage &ib) +{ + if (ia.size() != ib.size()) + qDebug() << "images are of different size" << ia.size() << ib.size(); + Q_ASSERT(ia.size() == ib.size()); + Q_ASSERT(ia.format() == ib.format()); + + int w = ia.width(); + int h = ia.height(); + const int tolerance = 5; + for (int y=0; y<h; ++y) { + const uint *as= (const uint *) ia.constScanLine(y); + const uint *bs= (const uint *) ib.constScanLine(y); + for (int x=0; x<w; ++x) { + uint a = as[x]; + uint b = bs[x]; + + // No tolerance for error in the alpha. + if ((a & 0xff000000) != (b & 0xff000000)) + return false; + if (qAbs(qRed(a) - qRed(b)) > tolerance) + return false; + if (qAbs(qRed(a) - qRed(b)) > tolerance) + return false; + if (qAbs(qRed(a) - qRed(b)) > tolerance) + return false; + } + } + return true; +} void tst_qquickwindow::headless() { @@ -1159,8 +1196,7 @@ void tst_qquickwindow::headless() // Verify that the visual output is the same QImage newContent = window->grabWindow(); - - QCOMPARE(originalContent, newContent); + QVERIFY(compareImages(newContent, originalContent)); } void tst_qquickwindow::noUpdateWhenNothingChanges() diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index 5d393fedb5..c3d237a806 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -119,7 +119,7 @@ bool compareImages(const QImage &ia, const QImage &ib) int w = ia.width(); int h = ia.height(); - const int tolerance = 1; + const int tolerance = 5; for (int y=0; y<h; ++y) { const uint *as= (const uint *) ia.constScanLine(y); const uint *bs= (const uint *) ib.constScanLine(y); |