From 9adf7fb708963c7bb27dc1fd54aa879395f6cf57 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 10 Oct 2012 18:57:05 +0200 Subject: 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 --- .../auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 108 --------------------- 1 file changed, 108 deletions(-) (limited to 'tests/auto/gui/text') 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 FormatRangeList; -Q_DECLARE_METATYPE(FormatRangeList) - -void tst_QTextLayout::additionalFormatsCapitalizationWithRawFont_data() -{ - QTest::addColumn("text"); - QTest::addColumn("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 expected = rawFont.glyphIndexesForString(expectedChars); - qSort(expected); - QVector 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" -- cgit v1.2.3