diff options
Diffstat (limited to 'tests/auto/gui/text')
6 files changed, 128 insertions, 12 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/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp index ca01e83dbe..39f5e9ecc3 100644 --- a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp +++ b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp @@ -145,7 +145,7 @@ void tst_QTextPieceTable::insertion3() { QString compare; for (int i = 0; i < 20000; ++i) { - int pos = rand() % (i+1); + int pos = QRandomGenerator::global()->bounded(i+1); QChar c((unsigned short)(i & 0xff) + 1); QString str; str += c; @@ -159,7 +159,7 @@ void tst_QTextPieceTable::insertion4() { QString compare; for (int i = 0; i < 20000; ++i) { - int pos = rand() % (i+1); + int pos = QRandomGenerator::global()->generate() % (i+1); QChar c((unsigned short)((i % 26) + (i>25?'A':'a'))); QString str; str += c; @@ -178,7 +178,7 @@ void tst_QTextPieceTable::insertion5() { QString compare; for (int i = 0; i < 20000; ++i) { - int pos = rand() % (i+1); + int pos = QRandomGenerator::global()->generate() % (i+1); QChar c((unsigned short)((i % 26) + (i>25?'A':'a'))); QString str; str += c; @@ -236,8 +236,8 @@ void tst_QTextPieceTable::removal3() QString compare; int l = 0; for (int i = 0; i < 20000; ++i) { - bool remove = l && (rand() % 2); - int pos = rand() % (remove ? l : (l+1)); + bool remove = l && (QRandomGenerator::global()->bounded(2)); + int pos = QRandomGenerator::global()->bounded(remove ? l : (l+1)); QChar c((unsigned short)((i % 26) + (i>25?'A':'a'))); QString str; str += c; @@ -263,8 +263,8 @@ void tst_QTextPieceTable::removal4() QString compare; int l = 0; for (int i = 0; i < 20000; ++i) { - bool remove = l && (rand() % 2); - int pos = (l > 1) ? rand() % (remove ? l-1 : l) : 0; + bool remove = l && (QRandomGenerator::global()->bounded(2)); + int pos = (l > 1) ? QRandomGenerator::global()->bounded(remove ? l-1 : l) : 0; QChar c((unsigned short)((i % 26) + (i>25?'A':'a'))); QString str; if (c != 'a') { @@ -472,13 +472,12 @@ void tst_QTextPieceTable::undoRedo10() void tst_QTextPieceTable::undoRedo11() { - srand(3); const int loops = 20; QString compare; int l = 0; for (int i = 0; i < loops; ++i) { - bool remove = l && (rand() % 2); - int pos = (l > 1) ? rand() % (remove ? l-1 : l) : 0; + bool remove = l && (QRandomGenerator::global()->bounded(2)); + int pos = (l > 1) ? QRandomGenerator::global()->bounded(remove ? l-1 : l) : 0; QChar c((unsigned short)((i % 26) + (i>25?'A':'a'))); QString str; str += c; 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" |