diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-10 16:39:05 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-11 20:08:50 +0100 |
commit | 50d0f57b77b8088875d7185c5906b5f57985d5fb (patch) | |
tree | 16d21bb5f558461511258f493159658ccecc696a /tests/auto/gui/text/qstatictext/tst_qstatictext.cpp | |
parent | 713282dfe41fbad1c1c940cec54227cd7c267831 (diff) | |
parent | 45dc347a95fd674cefcf5d1ac63b01557fcb2fef (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
This change partially reverts 1bfc7f68 about QT_HAS_BUILTIN define
and undef in src/corelib/tools/qsimd_p.h.
This change is also squashed with "Fall back to c++11 standard
compiler flag for host builds" which is done by Peter Seiderer.
Conflicts:
mkspecs/features/default_post.prf
src/3rdparty/sqlite/0001-Fixing-the-SQLite3-build-for-WEC2013-again.patch
src/3rdparty/sqlite/sqlite3.c
src/corelib/tools/qsimd_p.h
src/gui/kernel/qevent.cpp
src/gui/kernel/qwindowsysteminterface.cpp
src/gui/kernel/qwindowsysteminterface_p.h
src/plugins/bearer/blackberry/blackberry.pro
src/plugins/platforms/cocoa/qcocoasystemsettings.mm
src/plugins/platformthemes/gtk2/gtk2.pro
src/plugins/styles/bb10style/bb10style.pro
src/sql/drivers/sqlite2/qsql_sqlite2.cpp
tools/configure/configureapp.cpp
Task-number: QTBUG-51644
Done-with: Peter Seiderer <ps.report@gmx.net>
Change-Id: I6100d6ace31b2e8d41a95f0b5d5ebf8f1fd88b44
Diffstat (limited to 'tests/auto/gui/text/qstatictext/tst_qstatictext.cpp')
-rw-r--r-- | tests/auto/gui/text/qstatictext/tst_qstatictext.cpp | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index 7f4a11c5a5..096b820004 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -592,6 +592,29 @@ void tst_QStaticText::plainTextVsRichText() QCOMPARE(imagePlainText, imageRichText); } +static bool checkPixels(const QImage &image, + Qt::GlobalColor expectedColor1, Qt::GlobalColor expectedColor2, + QByteArray *errorMessage) +{ + const QRgb expectedRgb1 = QColor(expectedColor1).rgba(); + const QRgb expectedRgb2 = QColor(expectedColor2).rgba(); + + for (int x = 0, w = image.width(); x < w; ++x) { + for (int y = 0, h = image.height(); y < h; ++y) { + const QRgb pixel = image.pixel(x, y); + if (pixel != expectedRgb1 && pixel != expectedRgb2) { + QString message; + QDebug(&message) << "Color mismatch in image" << image + << "at" << x << ',' << y << ':' << showbase << hex << pixel + << "(expected: " << expectedRgb1 << ',' << expectedRgb2 << ')'; + *errorMessage = message.toLocal8Bit(); + return false; + } + } + } + return true; +} + void tst_QStaticText::setPenPlainText_data() { QTest::addColumn<QImage::Format>("format"); @@ -622,13 +645,9 @@ void tst_QStaticText::setPenPlainText() p.drawStaticText(0, 0, staticText); } - for (int x=0; x<image.width(); ++x) { - for (int y=0; y<image.height(); ++y) { - QRgb pixel = image.pixel(x, y); - QVERIFY(pixel == QColor(Qt::white).rgba() - || pixel == QColor(Qt::yellow).rgba()); - } - } + QByteArray errorMessage; + QVERIFY2(checkPixels(image, Qt::yellow, Qt::white, &errorMessage), + errorMessage.constData()); } void tst_QStaticText::setPenRichText() @@ -650,14 +669,9 @@ void tst_QStaticText::setPenRichText() p.drawStaticText(0, 0, staticText); } - QImage img = image.toImage(); - for (int x=0; x<img.width(); ++x) { - for (int y=0; y<img.height(); ++y) { - QRgb pixel = img.pixel(x, y); - QVERIFY(pixel == QColor(Qt::white).rgba() - || pixel == QColor(Qt::green).rgba()); - } - } + QByteArray errorMessage; + QVERIFY2(checkPixels(image.toImage(), Qt::green, Qt::white, &errorMessage), + errorMessage.constData()); } void tst_QStaticText::richTextOverridesPen() @@ -679,14 +693,9 @@ void tst_QStaticText::richTextOverridesPen() p.drawStaticText(0, 0, staticText); } - QImage img = image.toImage(); - for (int x=0; x<img.width(); ++x) { - for (int y=0; y<img.height(); ++y) { - QRgb pixel = img.pixel(x, y); - QVERIFY(pixel == QColor(Qt::white).rgba() - || pixel == QColor(Qt::red).rgba()); - } - } + QByteArray errorMessage; + QVERIFY2(checkPixels(image.toImage(), Qt::red, Qt::white, &errorMessage), + errorMessage.constData()); } void tst_QStaticText::drawStruckOutText() |