diff options
Diffstat (limited to 'tests/auto/gui/text')
5 files changed, 119 insertions, 2 deletions
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 8667caa1ef..0a422fca17 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -47,7 +47,11 @@ private slots: void elidedText(); void veryNarrowElidedText(); void averageCharWidth(); + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void bypassShaping(); +#endif + void elidedMultiLength(); void elidedMultiLengthF(); void inFontUcs4(); @@ -187,6 +191,7 @@ void tst_QFontMetrics::averageCharWidth() QVERIFY(fmf.averageCharWidth() != 0); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void tst_QFontMetrics::bypassShaping() { QFont f; @@ -201,6 +206,7 @@ void tst_QFontMetrics::bypassShaping() // This assertion is needed in Qt WebKit's WebCore::Font::offsetForPositionForSimpleText QCOMPARE(textWidth, charsWidth); } +#endif template<class FontMetrics, typename PrimitiveType> void elidedMultiLength_helper() { diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index 764b99646b..2f3da2c196 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -187,6 +187,7 @@ private slots: void cssInheritance(); void lineHeightType(); + void cssLineHeightMultiplier(); private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); void buildRegExpData(); @@ -3398,6 +3399,33 @@ void tst_QTextDocument::lineHeightType() { QTextDocument td; + td.setHtml("<html><head><style type=\"text/css\">body { -qt-line-height-type: fixed; line-height: 10; -qt-line-height-type: fixed; }</style></head><body>Foobar</body></html>"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::FixedHeight)); + QCOMPARE(format.lineHeight(), 10.0); + } + + { + QTextDocument td; + td.setHtml("<html><head><style type=\"text/css\">body { -qt-line-height-type: proportional; line-height: 3; }</style></head><body>Foobar</body></html>"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::ProportionalHeight)); + QCOMPARE(format.lineHeight(), 3.0); + } + + { + QTextDocument td; + td.setHtml("<html><head><style type=\"text/css\">body { line-height: 2.5; -qt-line-height-type: proportional; }</style></head><body>Foobar</body></html>"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::ProportionalHeight)); + QCOMPARE(format.lineHeight(), 2.5); + } + + { + QTextDocument td; td.setHtml("<html><head><style type=\"text/css\">body { line-height: 33; -qt-line-height-type: minimum; }</style></head><body>Foobar</body></html>"); QTextBlock block = td.begin(); QTextBlockFormat format = block.blockFormat(); @@ -3424,5 +3452,26 @@ void tst_QTextDocument::lineHeightType() } } +void tst_QTextDocument::cssLineHeightMultiplier() +{ + { + QTextDocument td; + td.setHtml("<html><head><style type=\"text/css\">body { line-height: 10; }</style></head><body>Foobar</body></html>"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::ProportionalHeight)); + QCOMPARE(format.lineHeight(), 1000.0); + } + + { + QTextDocument td; + td.setHtml("<html><head><style type=\"text/css\">body {line-height: 1.38; }</style></head><body>Foobar</body></html>"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::ProportionalHeight)); + QCOMPARE(format.lineHeight(), 138.0); + } +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index b8af5271ea..b68a014bff 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -1312,7 +1312,7 @@ void tst_QTextLayout::testDefaultTabs() QCOMPARE(line.cursorToX(31), 480.); QTextOption option = layout.textOption(); - option.setTabStop(90); + option.setTabStopDistance(90); layout.setTextOption(option); layout.beginLayout(); line = layout.createLine(); @@ -1351,7 +1351,7 @@ void tst_QTextLayout::testTabs() layout.setCacheEnabled(true); QTextOption option = layout.textOption(); - option.setTabStop(150); + option.setTabStopDistance(150); layout.setTextOption(option); layout.beginLayout(); diff --git a/tests/auto/gui/text/qtextscriptengine/BLACKLIST b/tests/auto/gui/text/qtextscriptengine/BLACKLIST new file mode 100644 index 0000000000..52eb9086a9 --- /dev/null +++ b/tests/auto/gui/text/qtextscriptengine/BLACKLIST @@ -0,0 +1,2 @@ +[thaiWithZWJ] +rhel-7.2 diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index ee50b98733..0371f51961 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -78,6 +78,9 @@ private slots: void thaiIsolatedSaraAm(); void thaiWithZWJ(); void thaiMultipleVowels(); + + void shapingDisabledDevanagari(); + void shapingDisabledLatin(); private: bool haveTestFonts; }; @@ -1280,5 +1283,62 @@ void tst_QTextScriptEngine::thaiMultipleVowels() // If we haven't crashed at this point, then the test has passed. } +void tst_QTextScriptEngine::shapingDisabledLatin() +{ + QString s("fi"); + + QFont font("Calibri"); + font.setStyleStrategy(QFont::PreferNoShaping); + + QTextLayout layout(s); + layout.setFont(font); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QList<QGlyphRun> runs = layout.glyphRuns(); + + QCOMPARE(runs.size(), 1); + QCOMPARE(runs.first().glyphIndexes().size(), 2); +} + +void tst_QTextScriptEngine::shapingDisabledDevanagari() +{ + QString s; + s += QChar(0x0915); // KA + s += QChar(0x094D); // VIRAMA + s += QChar(0x0915); // KA + + + QList<QGlyphRun> normalRuns; + { + QTextLayout layout(s); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + normalRuns = layout.glyphRuns(); + } + + QFont font; + font.setStyleStrategy(QFont::PreferNoShaping); + + QList<QGlyphRun> noShapingRuns; + { + QTextLayout layout(s); + layout.setFont(font); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + noShapingRuns = layout.glyphRuns(); + } + + // Even though shaping is disabled, Devanagari requires it, so the flag should be ignored. + QCOMPARE(normalRuns.size(), 1); + QCOMPARE(noShapingRuns.size(), 1); + QCOMPARE(noShapingRuns.first().glyphIndexes().size(), normalRuns.first().glyphIndexes().size()); +} + QTEST_MAIN(tst_QTextScriptEngine) #include "tst_qtextscriptengine.moc" |