diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-13 18:39:03 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-03-13 19:27:21 +0000 |
commit | 59a3ca679ede2cb9b6a162edf8eba5cf6d9af4a9 (patch) | |
tree | 0d0f76caa042db299cddaa84c14c28e4c80b2ffd /tests/auto/gui | |
parent | 447a508d003ce487f2be69af9ab05aeec272e64d (diff) | |
parent | 50d0f57b77b8088875d7185c5906b5f57985d5fb (diff) |
Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp | 2 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp | 2 | ||||
-rw-r--r-- | tests/auto/gui/text/qstatictext/tst_qstatictext.cpp | 55 |
3 files changed, 34 insertions, 25 deletions
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index ba5cfd1757..c12c8a9cf4 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -109,7 +109,7 @@ void tst_QImageWriter::initTestCase() prefix = QFINDTESTDATA("images/"); if (prefix.isEmpty()) QFAIL("Can't find images directory!"); - writePrefix = m_temporaryDir.path(); + writePrefix = m_temporaryDir.path() + QLatin1Char('/'); } // Testing get/set functions diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp index bd68400047..db0bfaf622 100644 --- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp +++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp @@ -137,7 +137,7 @@ void tst_QKeyEvent::modifiers_data() for (quint64 bitmask = 1; bitmask < (1 << kNumModifiers) ; ++bitmask) { QVector<int> modifierCombination; for (quint64 modifier = 0; modifier < kNumModifiers; ++modifier) { - if (bitmask & (1 << modifier)) + if (bitmask & (quint64(1) << modifier)) modifierCombination.append(modifier); } modifierCombinations.append(modifierCombination); 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() |