diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-09-05 15:31:08 +0200 |
---|---|---|
committer | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-09-06 10:11:04 +0200 |
commit | af44559780765c7121a49c2e0764cf24e740312d (patch) | |
tree | a4f2f50ddfe969f33a4d4accd392523c6809fd5a /tests/auto/quick/rendernode | |
parent | 8784a4a46ea1357bde546c9a1c88bd060e863f30 (diff) | |
parent | b30d7c9ee8fbc3a395c74b618f2ab176ae1e7f7e (diff) |
Merge branch 'stable' into dev
Conflicts:
src/qml/debugger/qv8debugservice.cpp
src/qml/qml/v8/qv8engine.cpp
tests/auto/quick/qquickitem/qquickitem.pro
Change-Id: Ic4a1dcdd8b8a84155d2f2abefdf1da5c3a56af31
Diffstat (limited to 'tests/auto/quick/rendernode')
-rw-r--r-- | tests/auto/quick/rendernode/tst_rendernode.cpp | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp index 04b32499ff..90a9488047 100644 --- a/tests/auto/quick/rendernode/tst_rendernode.cpp +++ b/tests/auto/quick/rendernode/tst_rendernode.cpp @@ -44,6 +44,7 @@ #include <QtQuick/qquickitem.h> #include <QtQuick/qquickview.h> #include <QtGui/qopenglcontext.h> +#include <QtGui/qscreen.h> #include <private/qsgrendernode_p.h> #include "../../shared/util.h" @@ -59,6 +60,10 @@ public: QQuickView view; view.setSource(testFileUrl(fileName)); + const QRect screenGeometry = view.screen()->availableGeometry(); + const QSize size = view.size(); + const QPoint offset = QPoint(size.width() / 2, size.height() / 2); + view.setFramePosition(screenGeometry.center() - offset); view.showNormal(); QTest::qWaitForWindowExposed(&view); @@ -185,15 +190,27 @@ tst_rendernode::tst_rendernode() qmlRegisterType<MessUpItem>("Test", 1, 0, "MessUpItem"); } -static void fuzzyCompareColor(QRgb x, QRgb y) +static bool fuzzyCompareColor(QRgb x, QRgb y, QByteArray *errorMessage) { - QVERIFY(qAbs(qRed(x) - qRed(y)) < 4); - QVERIFY(qAbs(qGreen(x) - qGreen(y)) < 4); - QVERIFY(qAbs(qBlue(x) - qBlue(y)) < 4); + enum { fuzz = 4 }; + if (qAbs(qRed(x) - qRed(y)) >= fuzz || qAbs(qGreen(x) - qGreen(y)) >= fuzz || qAbs(qBlue(x) - qBlue(y)) >= fuzz) { + QString s; + QDebug(&s).nospace() << hex << "Color mismatch 0x" << x << " 0x" << y << dec << " (fuzz=" << fuzz << ")."; + *errorMessage = s.toLocal8Bit(); + return false; + } + return true; +} + +static inline QByteArray msgColorMismatchAt(const QByteArray &colorMsg, int x, int y) +{ + return colorMsg + QByteArrayLiteral(" at ") + QByteArray::number(x) +',' + QByteArray::number(y); } void tst_rendernode::renderOrder() { + if (QGuiApplication::primaryScreen()->depth() < 24) + QSKIP("This test does not work at display depths < 24"); QImage fb = runTest("RenderOrder.qml"); int x1 = fb.width() / 8; int x2 = fb.width() * 3 / 8; @@ -204,18 +221,24 @@ void tst_rendernode::renderOrder() int y3 = fb.height() * 5 / 8; int y4 = fb.height() * 7 / 8; - fuzzyCompareColor(fb.pixel(x1, y1), qRgb(0x7f, 0x00, 0x00)); + QByteArray errorMessage; + QVERIFY2(fuzzyCompareColor(fb.pixel(x1, y1), qRgb(0x7f, 0x00, 0x00), &errorMessage), + msgColorMismatchAt(errorMessage, x1, y1).constData()); QCOMPARE(fb.pixel(x2, y2), qRgb(0xff, 0xff, 0xff)); QCOMPARE(fb.pixel(x3, y2), qRgb(0x00, 0x00, 0xff)); QCOMPARE(fb.pixel(x4, y1), qRgb(0x00, 0x00, 0xff)); QCOMPARE(fb.pixel(x1, y4), qRgb(0xff, 0x00, 0x00)); QCOMPARE(fb.pixel(x2, y3), qRgb(0xff, 0xff, 0xff)); - fuzzyCompareColor(fb.pixel(x3, y3), qRgb(0x7f, 0x7f, 0xff)); - fuzzyCompareColor(fb.pixel(x4, y4), qRgb(0x00, 0x00, 0x7f)); + QVERIFY2(fuzzyCompareColor(fb.pixel(x3, y3), qRgb(0x7f, 0x7f, 0xff), &errorMessage), + msgColorMismatchAt(errorMessage, x3, y3).constData()); + QVERIFY2(fuzzyCompareColor(fb.pixel(x4, y4), qRgb(0x00, 0x00, 0x7f), &errorMessage), + msgColorMismatchAt(errorMessage, x4, y4).constData()); } void tst_rendernode::messUpState() { + if (QGuiApplication::primaryScreen()->depth() < 24) + QSKIP("This test does not work at display depths < 24"); QImage fb = runTest("MessUpState.qml"); int x1 = 0; int x2 = fb.width() / 2; @@ -231,7 +254,9 @@ void tst_rendernode::messUpState() QCOMPARE(fb.pixel(x2, y1), qRgb(0x00, 0x00, 0x00)); QCOMPARE(fb.pixel(x2, y2), qRgb(0x00, 0x00, 0x00)); - fuzzyCompareColor(fb.pixel(x2, y3), qRgb(0x7f, 0x00, 0x7f)); + QByteArray errorMessage; + QVERIFY2(fuzzyCompareColor(fb.pixel(x2, y3), qRgb(0x7f, 0x00, 0x7f), &errorMessage), + msgColorMismatchAt(errorMessage, x2, y3).constData()); QCOMPARE(fb.pixel(x2, y4), qRgb(0x00, 0x00, 0x00)); QCOMPARE(fb.pixel(x2, y5), qRgb(0x00, 0x00, 0x00)); } |