diff options
author | Pierre Rossi <pierre.rossi@digia.com> | 2012-10-10 18:57:05 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-10 23:27:03 +0200 |
commit | 9adf7fb708963c7bb27dc1fd54aa879395f6cf57 (patch) | |
tree | a9b5ced9798522f921ac10fbeaf1bb8bea156042 /tests | |
parent | 361ab4fe86a375bf880536d161641a9725de70dd (diff) |
Revert "Handle additional format ranges when itemizing."
This reverts commit 101d04681f4ceb7410681eae684534a206a9d90a.
That change seems to have introduced a few regressions, and
Creator hits an assertion that it introduced because it assumes
the additionalFormats consists of well-formed ranges
(QTCREATORBUG-7995).
Change-Id: Ic4ae761e6e7f6df8a6b5ca565ceb250647420c15
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 108 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp | 7 | ||||
-rw-r--r-- | tests/benchmarks/gui/text/qtext/main.cpp | 2 |
3 files changed, 4 insertions, 113 deletions
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 2f8fab9e64..77f603af4f 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -139,11 +139,6 @@ private slots: void xToCursorForLigatures(); void cursorInNonStopChars(); -#ifndef QT_NO_RAWFONT - void additionalFormatsCapitalizationWithRawFont_data(); - void additionalFormatsCapitalizationWithRawFont(); -#endif - private: QFont testFont; }; @@ -2017,108 +2012,5 @@ void tst_QTextLayout::cursorInNonStopChars() QVERIFY(line.cursorToX(2) == line.cursorToX(3)); } -#ifndef QT_NO_RAWFONT - -typedef QList<QTextLayout::FormatRange> FormatRangeList; -Q_DECLARE_METATYPE(FormatRangeList) - -void tst_QTextLayout::additionalFormatsCapitalizationWithRawFont_data() -{ - QTest::addColumn<QString>("text"); - QTest::addColumn<FormatRangeList>("additionalFormats"); - - QString textSample = QLatin1String("Code Less, Create More."); - - QTest::newRow("No Format") << textSample << FormatRangeList(); - QTextLayout::FormatRange range; - range.start = 0; - range.length = textSample.size(); - range.format.setFontCapitalization(QFont::SmallCaps); - QTest::newRow("SmallCaps") << textSample << (FormatRangeList() << range); - range.format.setFontCapitalization(QFont::Capitalize); - QTest::newRow("Capitalize") << textSample.toLower() << (FormatRangeList() << range); - range.format.setFontCapitalization(QFont::AllLowercase); - QTest::newRow("AllLowercase") << textSample << (FormatRangeList() << range); - - FormatRangeList rangeList; - range.start = 0; - range.length = 5; - range.format.setFontCapitalization(QFont::SmallCaps); - rangeList << range; - range.start = 5; - range.format.setFontCapitalization(QFont::AllLowercase); - rangeList << range; - range.start = 18; - range.format.setFontCapitalization(QFont::Capitalize); - rangeList << range; - QTest::newRow("MixAndMatch") << textSample << rangeList; -} - -void tst_QTextLayout::additionalFormatsCapitalizationWithRawFont() -{ - QFETCH(QString, text); - QFETCH(FormatRangeList, additionalFormats); - - QRawFont rawFont = QRawFont::fromFont(testFont); - - QTextLayout layout(text); - layout.setRawFont(rawFont); - layout.setAdditionalFormats(additionalFormats); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); - - QString expectedChars; - QTextBoundaryFinder splitter(QTextBoundaryFinder::Word,text.constData(), text.length(), 0, 0); - - for (int i = 0; i < text.size(); ++i) { - bool hasFormat = false; - Q_FOREACH (const QTextLayout::FormatRange& range, additionalFormats) { - if (i >= range.start && i < range.start + range.length) { - hasFormat = true; - const QChar ch(text.at(i)); - switch (range.format.fontCapitalization()) { - case QFont::SmallCaps: - case QFont::AllUppercase: - expectedChars += ch.toUpper(); - break; - case QFont::AllLowercase: - expectedChars += ch.toLower(); - break; - case QFont::Capitalize: - splitter.setPosition(i); - if (splitter.boundaryReasons() & QTextBoundaryFinder::StartWord) - expectedChars += ch.toUpper(); - else - expectedChars += ch; - break; - case QFont::MixedCase: - default: - expectedChars += ch; - break; - } - } - } - if (!hasFormat) - expectedChars += text.at(i); - } - - QVERIFY(layout.glyphRuns().size() > 0); - rawFont = layout.glyphRuns().first().rawFont(); - // Can't assume anything about the order of the glyphs we get once they're split into several glyphRuns. - // Let's just compare the sets: - QVector<quint32> expected = rawFont.glyphIndexesForString(expectedChars); - qSort(expected); - QVector<quint32> sortedOutput; - sortedOutput.reserve(expected.size()); - Q_FOREACH (const QGlyphRun& run, layout.glyphRuns()) { - Q_FOREACH (quint32 glyphIndex, run.glyphIndexes()) - sortedOutput.append(glyphIndex); - } - qSort(sortedOutput); - QCOMPARE(sortedOutput, expected); -} -#endif - QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index bc414f5b19..27369adc22 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -2473,11 +2473,10 @@ void tst_QTextEdit::highlightLongLine() edit.setAcceptRichText(false); edit.setWordWrapMode(QTextOption::NoWrap); - QString singleLongLine; - singleLongLine.reserve(100000); + QString singeLongLine; for (int i = 0; i < 10000; ++i) - singleLongLine += "0123456789"; - edit.setPlainText(singleLongLine); + singeLongLine += "0123456789"; + edit.setPlainText(singeLongLine); class NumHighlighter : public QSyntaxHighlighter { public: diff --git a/tests/benchmarks/gui/text/qtext/main.cpp b/tests/benchmarks/gui/text/qtext/main.cpp index c9d5d59891..543b9041da 100644 --- a/tests/benchmarks/gui/text/qtext/main.cpp +++ b/tests/benchmarks/gui/text/qtext/main.cpp @@ -362,7 +362,7 @@ void tst_QText::formattedLayout_data() ranges.append(formatRange); } - QTest::newRow("long-many") << text << ranges; + QTest::newRow("long-many") << m_shortLorem << ranges; } } |