summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-02-21 15:15:29 +0100
committerKonstantin Ritt <ritt.ks@gmail.com>2015-05-30 10:56:24 +0000
commit87d57d19941fba4a921020480ca5761f23536c93 (patch)
tree9157982715d32e8a9c014fbdc104d9721aac525f /tests
parent9eff0dd19d6507ec400f036dd27efe960e4e5f78 (diff)
Fix users of QTextLayout::additionalFormats to use the new API
QTextLayout::additionalFormats setters and getters using QList<FormatRange> have been deprecated; port to the QVector versions. Moved op== definition for FormatRange needed in tst_qsyntaxhighlighter.cpp to a friend declaration in FormatRange itself, because MSVC 2008 doesn't find it otherwise. Change-Id: Ibab6589df057f02377d895079b56395859e3401e Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp31
-rw-r--r--tests/benchmarks/gui/text/qtext/main.cpp14
2 files changed, 18 insertions, 27 deletions
diff --git a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
index 014ed4c7c8..c0b0738e2a 100644
--- a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
+++ b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
@@ -120,7 +120,7 @@ void tst_QSyntaxHighlighter::cleanup()
class TestHighlighter : public QSyntaxHighlighter
{
public:
- inline TestHighlighter(const QList<QTextLayout::FormatRange> &fmts, QTextDocument *parent)
+ inline TestHighlighter(const QVector<QTextLayout::FormatRange> &fmts, QTextDocument *parent)
: QSyntaxHighlighter(parent), formats(fmts), highlighted(false), callCount(0) {}
inline TestHighlighter(QObject *parent)
: QSyntaxHighlighter(parent) {}
@@ -138,24 +138,15 @@ public:
++callCount;
}
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
bool highlighted;
int callCount;
QString highlightedText;
};
-QT_BEGIN_NAMESPACE
-bool operator==(const QTextLayout::FormatRange &lhs, const QTextLayout::FormatRange &rhs)
-{
- return lhs.start == rhs.start
- && lhs.length == rhs.length
- && lhs.format == rhs.format;
-}
-QT_END_NAMESPACE
-
void tst_QSyntaxHighlighter::basic()
{
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
QTextLayout::FormatRange range;
range.start = 0;
range.length = 2;
@@ -179,7 +170,7 @@ void tst_QSyntaxHighlighter::basic()
QVERIFY(hl->highlighted);
QVERIFY(lout->documentChangedCalled);
- QVERIFY(doc->begin().layout()->additionalFormats() == formats);
+ QVERIFY(doc->begin().layout()->formats() == formats);
}
class CommentTestHighlighter : public QSyntaxHighlighter
@@ -222,7 +213,7 @@ void tst_QSyntaxHighlighter::basicTwo()
void tst_QSyntaxHighlighter::removeFormatsOnDelete()
{
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
QTextLayout::FormatRange range;
range.start = 0;
range.length = 9;
@@ -237,9 +228,9 @@ void tst_QSyntaxHighlighter::removeFormatsOnDelete()
QVERIFY(lout->documentChangedCalled);
lout->documentChangedCalled = false;
- QVERIFY(!doc->begin().layout()->additionalFormats().isEmpty());
+ QVERIFY(!doc->begin().layout()->formats().isEmpty());
delete hl;
- QVERIFY(doc->begin().layout()->additionalFormats().isEmpty());
+ QVERIFY(doc->begin().layout()->formats().isEmpty());
QVERIFY(lout->documentChangedCalled);
}
@@ -405,7 +396,7 @@ void tst_QSyntaxHighlighter::highlightToEndOfDocument2()
void tst_QSyntaxHighlighter::preservePreeditArea()
{
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
QTextLayout::FormatRange range;
range.start = 0;
range.length = 8;
@@ -432,12 +423,12 @@ void tst_QSyntaxHighlighter::preservePreeditArea()
hl->callCount = 0;
cursor.beginEditBlock();
- layout->setAdditionalFormats(formats);
+ layout->setFormats(formats);
cursor.endEditBlock();
QCOMPARE(hl->callCount, 1);
- formats = layout->additionalFormats();
+ formats = layout->formats();
QCOMPARE(formats.count(), 3);
range = formats.at(0);
@@ -483,7 +474,7 @@ void tst_QSyntaxHighlighter::avoidUnnecessaryRehighlight()
void tst_QSyntaxHighlighter::noContentsChangedDuringHighlight()
{
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
QTextLayout::FormatRange range;
range.start = 0;
range.length = 10;
diff --git a/tests/benchmarks/gui/text/qtext/main.cpp b/tests/benchmarks/gui/text/qtext/main.cpp
index 224d9619ec..f20b3f6cce 100644
--- a/tests/benchmarks/gui/text/qtext/main.cpp
+++ b/tests/benchmarks/gui/text/qtext/main.cpp
@@ -42,7 +42,7 @@
#include <QBuffer>
#include <qtest.h>
-Q_DECLARE_METATYPE(QList<QTextLayout::FormatRange>)
+Q_DECLARE_METATYPE(QVector<QTextLayout::FormatRange>)
class tst_QText: public QObject
{
@@ -324,13 +324,13 @@ void tst_QText::layout()
void tst_QText::formattedLayout_data()
{
QTest::addColumn<QString>("text");
- QTest::addColumn<QList<QTextLayout::FormatRange> >("ranges");
+ QTest::addColumn<QVector<QTextLayout::FormatRange> >("ranges");
QTextCharFormat format;
format.setForeground(QColor("steelblue"));
{
- QList<QTextLayout::FormatRange> ranges;
+ QVector<QTextLayout::FormatRange> ranges;
QTextLayout::FormatRange formatRange;
formatRange.format = format;
@@ -341,7 +341,7 @@ void tst_QText::formattedLayout_data()
QTest::newRow("short-single") << m_shortLorem << ranges;
}
{
- QList<QTextLayout::FormatRange> ranges;
+ QVector<QTextLayout::FormatRange> ranges;
QString text = m_lorem.repeated(100);
const int width = 1;
@@ -360,15 +360,15 @@ void tst_QText::formattedLayout_data()
void tst_QText::formattedLayout()
{
QFETCH(QString, text);
- QFETCH(QList<QTextLayout::FormatRange>, ranges);
+ QFETCH(QVector<QTextLayout::FormatRange>, ranges);
QTextLayout layout(text);
- layout.setAdditionalFormats(ranges);
+ layout.setFormats(ranges);
setupTextLayout(&layout);
QBENCHMARK {
QTextLayout layout(text);
- layout.setAdditionalFormats(ranges);
+ layout.setFormats(ranges);
setupTextLayout(&layout);
}
}