diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-03-11 01:00:24 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-03-11 11:27:49 +0100 |
commit | 116d68f105db025f56c1fd5115ff4924bc22d7c2 (patch) | |
tree | ae04596b19c34eccc60ff7477da6a0166c5f82b1 /tests | |
parent | 52de905d0ec6159d3a1e7ad63fed018b5c6973d2 (diff) | |
parent | bd3c82f8db4391fc1d6d3338827356143fd598dd (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
src/corelib/plugin/qlibrary.cpp
src/corelib/plugin/qlibrary_unix.cpp
src/corelib/plugin/qpluginloader.cpp
Change-Id: I866feaaa2a4936ee5389679724c8471a5b4b583d
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST | 3 | ||||
-rw-r--r-- | tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp | 2 | ||||
-rw-r--r-- | tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 162 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qwidget_window/BLACKLIST | 4 | ||||
-rw-r--r-- | tests/auto/xml/dom/qdom/tst_qdom.cpp | 24 |
5 files changed, 167 insertions, 28 deletions
diff --git a/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST b/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST deleted file mode 100644 index 2317cf886c..0000000000 --- a/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST +++ /dev/null @@ -1,3 +0,0 @@ -[elapsed] -macos -windows-10 diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp index e0d09b0813..50c4d9b467 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp @@ -368,7 +368,7 @@ void tst_QLibrary::errorString_data() QTest::newRow("bad load()") << (int)Load << QString("nosuchlib") << false << QString("Cannot load library nosuchlib: .*"); QTest::newRow("call errorString() on QLibrary with no d-pointer (crashtest)") << (int)(Load | DontSetFileName) << QString() << false << QString("Unknown error"); - QTest::newRow("bad resolve") << (int)Resolve << appDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in \\S+: .*"); + QTest::newRow("bad resolve") << (int)Resolve << appDir + "/mylib" << false << QString("Unknown error"); QTest::newRow("good resolve") << (int)Resolve << appDir + "/mylib" << true << QString("Unknown error"); #ifdef Q_OS_WIN diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 2dcca0209e..8466305832 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -62,6 +62,7 @@ private slots: void lineBreaking(); #ifdef QT_BUILD_INTERNAL void simpleBoundingRect(); + void threeLineBoundingRect_data(); void threeLineBoundingRect(); void boundingRectWithLongLineAndNoWrap(); void forcedBreaks(); @@ -140,6 +141,7 @@ private slots: void showLineAndParagraphSeparatorsCrash(); void koreanWordWrap(); void tooManyDirectionalCharctersCrash_qtbug77819(); + void softHyphens(); private: QFont testFont; @@ -315,18 +317,49 @@ void tst_QTextLayout::simpleBoundingRect() QCOMPARE(layout.boundingRect(), QRectF(0, 0, width, QFontMetrics(testFont).height())); } +void tst_QTextLayout::threeLineBoundingRect_data() +{ + QTest::addColumn<QChar>("wordBoundary1"); + QTest::addColumn<QChar>("wordBoundary2"); + QTest::newRow("2x' '") << QChar(' ') << QChar(' '); + QTest::newRow("2x'\\n'") << QChar('\n') << QChar('\n'); + QTest::newRow("' ' + '\\n'") << QChar(' ') << QChar('\n'); + QTest::newRow("'\\n' + ' '") << QChar('\n') << QChar(' '); + QTest::newRow("2x'\\t'") << QChar('\t') << QChar('\t'); + QTest::newRow("2xsoft hyphen") << QChar(0xad) << QChar(0xad); + QTest::newRow("2x'-'") << QChar('-') << QChar('-'); + QTest::newRow("2x'/'") << QChar('/') << QChar('/'); + QTest::newRow("soft hyphen + ' '") << QChar(0xad) << QChar(' '); + QTest::newRow("soft hyphen + '\\n'") << QChar(0xad) << QChar('\n'); + QTest::newRow("soft hyphen + '-'") << QChar(0xad) << QChar('-'); + QTest::newRow("' ' + soft hyphen") << QChar(' ') << QChar(0xad); + QTest::newRow("'\\n' + soft hyphen") << QChar('\n') << QChar(0xad); + QTest::newRow("'-' + soft hyphen") << QChar('-') << QChar(0xad); +} + void tst_QTextLayout::threeLineBoundingRect() { /* stricter check. break text into three lines */ + QFETCH(QChar, wordBoundary1); + QFETCH(QChar, wordBoundary2); QString firstWord("hello"); - QString secondWord("world"); - QString thirdWord("test"); - QString text(firstWord + ' ' + secondWord + ' ' + thirdWord); - - const int firstLineWidth = firstWord.length() * testFont.pixelSize(); - const int secondLineWidth = secondWord.length() * testFont.pixelSize(); - const int thirdLineWidth = thirdWord.length() * testFont.pixelSize(); + QString secondWord("test"); + QString thirdWord("world"); + QString text(firstWord + wordBoundary1 + secondWord + wordBoundary2 + thirdWord); + + int firstLineWidth = firstWord.length() * testFont.pixelSize(); + int secondLineWidth = secondWord.length() * testFont.pixelSize(); + int thirdLineWidth = thirdWord.length() * testFont.pixelSize(); + // Trailing spaces do not count to line width: + if (!wordBoundary1.isSpace()) + firstLineWidth += testFont.pixelSize(); + if (!wordBoundary2.isSpace()) + secondLineWidth += testFont.pixelSize(); + // But trailing spaces do count to line length: + const int firstLineLength = firstWord.length() + 1; + const int secondLineLength = secondWord.length() + 1; + const int thirdLineLength = thirdWord.length(); const int longestLine = qMax(firstLineWidth, qMax(secondLineWidth, thirdLineWidth)); @@ -339,8 +372,7 @@ void tst_QTextLayout::threeLineBoundingRect() line.setLineWidth(firstLineWidth); line.setPosition(QPoint(0, y)); QCOMPARE(line.textStart(), pos); - // + 1 for trailing space - QCOMPARE(line.textLength(), firstWord.length() + 1); + QCOMPARE(line.textLength(), firstLineLength); QCOMPARE(qRound(line.naturalTextWidth()), firstLineWidth); pos += line.textLength(); @@ -349,9 +381,8 @@ void tst_QTextLayout::threeLineBoundingRect() line = layout.createLine(); line.setLineWidth(secondLineWidth); line.setPosition(QPoint(0, y)); - // + 1 for trailing space QCOMPARE(line.textStart(), pos); - QCOMPARE(line.textLength(), secondWord.length() + 1); + QCOMPARE(line.textLength(), secondLineLength); QCOMPARE(qRound(line.naturalTextWidth()), secondLineWidth); pos += line.textLength(); @@ -360,9 +391,8 @@ void tst_QTextLayout::threeLineBoundingRect() line = layout.createLine(); line.setLineWidth(secondLineWidth); line.setPosition(QPoint(0, y)); - // no trailing space here! QCOMPARE(line.textStart(), pos); - QCOMPARE(line.textLength(), thirdWord.length()); + QCOMPARE(line.textLength(), thirdLineLength); QCOMPARE(qRound(line.naturalTextWidth()), thirdLineWidth); y += qRound(line.ascent() + line.descent()); @@ -2352,5 +2382,111 @@ void tst_QTextLayout::tooManyDirectionalCharctersCrash_qtbug77819() tl.endLayout(); } +void tst_QTextLayout::softHyphens() +{ + QString text = QStringLiteral("xxxx\u00ad") + QStringLiteral("xxxx\u00ad"); + + QFont font; + font.setPixelSize(14); + font.setHintingPreference(QFont::PreferNoHinting); + const float xAdvance = QFontMetricsF(font).horizontalAdvance(QChar('x')); + const float shyAdvance = QFontMetricsF(font).horizontalAdvance(QChar::SoftHyphen); + if (xAdvance < (shyAdvance + 1.0f)) + QSKIP("Default font not suitable for this test."); + QTextLayout layout(text, font); + QTextOption option; + option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); + layout.setTextOption(option); + + // Loose fit + // xxxx- | + // xxxx- | + { + int pos = 0; + int y = 0; + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(qCeil(5 * xAdvance) + 1); + line.setPosition(QPoint(0, y)); + QCOMPARE(line.textStart(), pos); + QCOMPARE(line.textLength(), 5); + QVERIFY(qAbs(line.naturalTextWidth() - (4 * xAdvance + shyAdvance)) <= 1); + + pos += line.textLength(); + y += qRound(line.ascent() + line.descent()); + + line = layout.createLine(); + line.setLineWidth(qCeil(5 * xAdvance) + 1); + line.setPosition(QPoint(0, y)); + QCOMPARE(line.textStart(), pos); + QCOMPARE(line.textLength(), 5); + QVERIFY(qAbs(line.naturalTextWidth() - (4 * xAdvance + shyAdvance)) <= 1); + layout.endLayout(); + } + + // Tight fit + // xxxx-| + // xxxx-| + { + int pos = 0; + int y = 0; + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(qCeil(4 * xAdvance + shyAdvance) + 1); + line.setPosition(QPoint(0, y)); + QCOMPARE(line.textStart(), pos); + QCOMPARE(line.textLength(), 5); + QVERIFY(qAbs(line.naturalTextWidth() - (4 * xAdvance + shyAdvance)) <= 1); + + pos += line.textLength(); + y += qRound(line.ascent() + line.descent()); + + line = layout.createLine(); + line.setLineWidth(qCeil(4 * xAdvance + shyAdvance) + 1); + line.setPosition(QPoint(0, y)); + QCOMPARE(line.textStart(), pos); + QCOMPARE(line.textLength(), 5); + QVERIFY(qAbs(line.naturalTextWidth() - (4 * xAdvance + shyAdvance)) <= 1); + layout.endLayout(); + } + + // Very tight fit + // xxxx| + // xxxx| + // - | + { + int pos = 0; + int y = 0; + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(qCeil(4 * xAdvance) + 2); + line.setPosition(QPoint(0, y)); + QCOMPARE(line.textStart(), pos); + QCOMPARE(line.textLength(), 4); + QVERIFY(qAbs(line.naturalTextWidth() - 4 * xAdvance) <= 1); + + pos += line.textLength(); + y += qRound(line.ascent() + line.descent()); + + line = layout.createLine(); + line.setLineWidth(qCeil(4 * xAdvance) + 2); + line.setPosition(QPoint(0, y)); + QCOMPARE(line.textStart(), pos); + QCOMPARE(line.textLength(), 5); + QVERIFY(qAbs(line.naturalTextWidth() - 4 * xAdvance) <= 1); + + pos += line.textLength(); + y += qRound(line.ascent() + line.descent()); + + line = layout.createLine(); + line.setLineWidth(qCeil(4 * xAdvance) + 2); + line.setPosition(QPoint(0, y)); + QCOMPARE(line.textStart(), pos); + QCOMPARE(line.textLength(), 1); + QVERIFY(qAbs(line.naturalTextWidth() - shyAdvance) <= 1); + layout.endLayout(); + } +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" diff --git a/tests/auto/widgets/kernel/qwidget_window/BLACKLIST b/tests/auto/widgets/kernel/qwidget_window/BLACKLIST index 39d7b695f6..d3bfaba433 100644 --- a/tests/auto/widgets/kernel/qwidget_window/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget_window/BLACKLIST @@ -2,7 +2,3 @@ # QTBUG-66345 opensuse-42.3 ubuntu-16.04 -[setWindowState] -ubuntu-18.04 -rhel-7.6 - diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index a2a5b22cad..1a26376456 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -38,6 +38,7 @@ #include <QtTest/QtTest> #include <QtXml> #include <QVariant> +#include <cmath> QT_FORWARD_DECLARE_CLASS(QDomDocument) QT_FORWARD_DECLARE_CLASS(QDomNode) @@ -419,7 +420,9 @@ void tst_QDom::setGetAttributes() const int intVal = std::numeric_limits<int>::min(); const uint uintVal = std::numeric_limits<uint>::max(); const float floatVal = 0.1234f; - const double doubleVal = 0.1234; + const double doubleVal1 = 1./6.; + const double doubleVal2 = std::nextafter(doubleVal1, 1.); + const double doubleVal3 = std::nextafter(doubleVal2, 1.); rootNode.setAttribute("qstringVal", qstringVal); rootNode.setAttribute("qlonglongVal", qlonglongVal); @@ -427,7 +430,9 @@ void tst_QDom::setGetAttributes() rootNode.setAttribute("intVal", intVal); rootNode.setAttribute("uintVal", uintVal); rootNode.setAttribute("floatVal", floatVal); - rootNode.setAttribute("doubleVal", doubleVal); + rootNode.setAttribute("doubleVal1", doubleVal1); + rootNode.setAttribute("doubleVal2", doubleVal2); + rootNode.setAttribute("doubleVal3", doubleVal3); QDomElement nsNode = doc.createElement("NS"); rootNode.appendChild(nsNode); @@ -437,7 +442,9 @@ void tst_QDom::setGetAttributes() nsNode.setAttributeNS("namespace", "intVal", intVal); nsNode.setAttributeNS("namespace", "uintVal", uintVal); nsNode.setAttributeNS("namespace", "floatVal", floatVal); // not available atm - nsNode.setAttributeNS("namespace", "doubleVal", doubleVal); + nsNode.setAttributeNS("namespace", "doubleVal1", doubleVal1); + nsNode.setAttributeNS("namespace", "doubleVal2", doubleVal2); + nsNode.setAttributeNS("namespace", "doubleVal3", doubleVal3); bool bOk; QCOMPARE(rootNode.attribute("qstringVal"), qstringVal); @@ -451,8 +458,10 @@ void tst_QDom::setGetAttributes() QVERIFY(bOk); QCOMPARE(rootNode.attribute("floatVal").toFloat(&bOk), floatVal); QVERIFY(bOk); - QCOMPARE(rootNode.attribute("doubleVal").toDouble(&bOk), doubleVal); - QVERIFY(bOk); + + QVERIFY(rootNode.attribute("doubleVal1").toDouble(&bOk) == doubleVal1 && bOk); + QVERIFY(rootNode.attribute("doubleVal2").toDouble(&bOk) == doubleVal2 && bOk); + QVERIFY(rootNode.attribute("doubleVal3").toDouble(&bOk) == doubleVal3 && bOk); QCOMPARE(nsNode.attributeNS("namespace", "qstringVal"), qstringVal); QCOMPARE(nsNode.attributeNS("namespace", "qlonglongVal").toLongLong(&bOk), qlonglongVal); @@ -465,8 +474,9 @@ void tst_QDom::setGetAttributes() QVERIFY(bOk); QCOMPARE(nsNode.attributeNS("namespace", "floatVal").toFloat(&bOk), floatVal); QVERIFY(bOk); - QCOMPARE(nsNode.attributeNS("namespace", "doubleVal").toDouble(&bOk), doubleVal); - QVERIFY(bOk); + QVERIFY(nsNode.attributeNS("namespace", "doubleVal1").toDouble(&bOk) == doubleVal1 && bOk); + QVERIFY(nsNode.attributeNS("namespace", "doubleVal2").toDouble(&bOk) == doubleVal2 && bOk); + QVERIFY(nsNode.attributeNS("namespace", "doubleVal3").toDouble(&bOk) == doubleVal3 && bOk); QLocale::setDefault(oldLocale); } |