diff options
Diffstat (limited to 'tests/auto/gui/text')
6 files changed, 42 insertions, 15 deletions
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index e8244a0e5d..e52cb63384 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -244,8 +244,13 @@ void tst_QFontDatabase::addAppFont() QVERIFY(!newFamilies.isEmpty()); QVERIFY(newFamilies.count() >= oldFamilies.count()); - for (int i = 0; i < addedFamilies.count(); ++i) - QVERIFY(newFamilies.contains(addedFamilies.at(i))); + for (int i = 0; i < addedFamilies.count(); ++i) { + QString family = addedFamilies.at(i); + QVERIFY(newFamilies.contains(family)); + QFont qfont(family); + QFontInfo fi(qfont); + QCOMPARE(fi.family(), family); + } QVERIFY(QFontDatabase::removeApplicationFont(id)); QCOMPARE(fontDbChangedSpy.count(), 2); diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 6192e3cd8d..8667caa1ef 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -202,36 +202,36 @@ void tst_QFontMetrics::bypassShaping() QCOMPARE(textWidth, charsWidth); } -template<class FontMetrics> void elidedMultiLength_helper() +template<class FontMetrics, typename PrimitiveType> void elidedMultiLength_helper() { QString text1 = QLatin1String("Long Text 1\x9cShorter\x9csmall"); QString text1_long = "Long Text 1"; QString text1_short = "Shorter"; QString text1_small = "small"; FontMetrics fm = FontMetrics(QFont()); - int width_long = fm.size(0, text1_long).width(); + PrimitiveType width_long = fm.size(0, text1_long).width(); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, 8000), text1_long); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long + 1), text1_long); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long - 1), text1_short); - int width_short = fm.size(0, text1_short).width(); + PrimitiveType width_short = fm.size(0, text1_short).width(); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short + 1), text1_short); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short - 1), text1_small); // Not even wide enough for "small" - should use ellipsis QChar ellipsisChar(0x2026); QString text1_el = QString::fromLatin1("s") + ellipsisChar; - int width_small = fm.width(text1_el); + PrimitiveType width_small = fm.width(text1_el); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_small + 1), text1_el); } void tst_QFontMetrics::elidedMultiLength() { - elidedMultiLength_helper<QFontMetrics>(); + elidedMultiLength_helper<QFontMetrics, int>(); } void tst_QFontMetrics::elidedMultiLengthF() { - elidedMultiLength_helper<QFontMetricsF>(); + elidedMultiLength_helper<QFontMetricsF, qreal>(); } void tst_QFontMetrics::inFontUcs4() diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp index 7c60c8c9f8..21b2697b90 100644 --- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp +++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp @@ -527,6 +527,7 @@ void tst_QGlyphRun::drawStruckOutText() QFont font; font.setStrikeOut(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); QTextLayout layout(s); layout.setFont(font); @@ -569,6 +570,7 @@ void tst_QGlyphRun::drawOverlinedText() QFont font; font.setOverline(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); QTextLayout layout(s); layout.setFont(font); @@ -611,6 +613,7 @@ void tst_QGlyphRun::drawUnderlinedText() QFont font; font.setUnderline(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); QTextLayout layout(s); layout.setFont(font); diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index 9f84f64ee9..f4e3356ad0 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -716,6 +716,7 @@ void tst_QStaticText::drawStruckOutText() QFont font; font.setStrikeOut(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); { QPainter p(&imageDrawText); @@ -751,6 +752,7 @@ void tst_QStaticText::drawOverlinedText() QFont font; font.setOverline(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); { QPainter p(&imageDrawText); @@ -786,6 +788,7 @@ void tst_QStaticText::drawUnderlinedText() QFont font; font.setUnderline(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); { QPainter p(&imageDrawText); diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index de5b2a8676..ef1ad76161 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -135,6 +135,7 @@ private slots: void setPlainText(); void toPlainText(); + void toRawText(); void deleteTextObjectsOnClear(); @@ -2396,6 +2397,16 @@ void tst_QTextDocument::toPlainText() QCOMPARE(doc->toPlainText(), QLatin1String("Hello World")); } +void tst_QTextDocument::toRawText() +{ + doc->setHtml(" "); + + QString rawText = doc->toRawText(); + QCOMPARE(rawText.size(), 1); + QCOMPARE(rawText.at(0).unicode(), ushort(QChar::Nbsp)); +} + + void tst_QTextDocument::deleteTextObjectsOnClear() { QPointer<QTextTable> table = cursor.insertTable(2, 2); diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index 36907b9258..ee50b98733 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -1104,7 +1104,7 @@ void tst_QTextScriptEngine::controlInSyllable_qtbug14204() const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]); QCOMPARE(log_clusters[0], ushort(0)); QCOMPARE(log_clusters[1], ushort(0)); - QCOMPARE(log_clusters[2], ushort(1)); + QCOMPARE(log_clusters[2], ushort(0)); QCOMPARE(log_clusters[3], ushort(2)); } @@ -1214,6 +1214,9 @@ void tst_QTextScriptEngine::thaiWithZWJ() QFont font(QStringLiteral("Waree")); font.setStyleStrategy(QFont::NoFontMerging); + if (QFontInfo(font).styleName() != QStringLiteral("Book")) + QSKIP("couldn't find 'Waree Book' font"); + QString s(QString::fromUtf8("\xe0\xb8\xa3\xe2\x80\x8d\xe0\xb8\xa3\xe2\x80" "\x8c\x2e\xe0\xb8\xa3\x2e\xe2\x80\x9c\xe0\xb8" "\xa3\xe2\x80\xa6\xe0\xb8\xa3\xe2\x80\x9d\xe0" @@ -1233,20 +1236,22 @@ void tst_QTextScriptEngine::thaiWithZWJ() QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(2)); // Thai: Thai character followed by superscript "a" which is of inherited type //A quick sanity check - check all the characters are individual clusters + // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. + // The current implementation hides them, so we test for that. unsigned short *logClusters = e->layoutData->logClustersPtr; - for (int i = 0; i < 15; i++) + QCOMPARE(logClusters[0], ushort(0)); + QCOMPARE(logClusters[1], ushort(0)); + QCOMPARE(logClusters[2], ushort(2)); + QCOMPARE(logClusters[3], ushort(2)); + for (int i = 4; i < 15; i++) QCOMPARE(logClusters[i], ushort(i)); for (int i = 0; i < 3; i++) QCOMPARE(logClusters[i+15], ushort(0)); - // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. - // The current implementation hides them, so we test for that. // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 and 3. const QGlyphLayout glyphLayout = e->layoutData->glyphLayout; for (int i = 0; i < 18; i++) { - if (i == 17) - QCOMPARE(glyphLayout.advances[i].toInt(), 0); - else if (i == 1 || i == 3) + if (i == 1 || i == 3) QCOMPARE(glyphLayout.advances[i].toInt(), 0); else QVERIFY(glyphLayout.advances[i].toInt() != 0); |